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
7 --- Gfx.cc 3 Dec 2005 10:11:33 -0000 1.9
8 +++ Gfx.cc 3 Dec 2005 10:30:41 -0000 1.10
13 - out->startPage(pageNum, state);
15 + out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
17 out->setDefaultCTM(state->getCTM());
18 out->updateAll(state);
19 for (i = 0; i < 6; ++i) {
21 abortCheckCbkData = abortCheckCbkDataA;
27 state->moveTo(cropBox->x1, cropBox->y1);
28 state->lineTo(cropBox->x2, cropBox->y1);
29 state->lineTo(cropBox->x2, cropBox->y2);
39 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
41 ===================================================================
42 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxFont.h,v
43 retrieving revision 1.6
44 retrieving revision 1.7
46 --- GfxFont.h 3 Dec 2005 10:11:33 -0000 1.6
47 +++ GfxFont.h 3 Dec 2005 10:30:41 -0000 1.7
49 CharCodeToUnicode *getToUnicode();
51 // Return the character name associated with <code>.
52 - char *getCharName(int code) { return enc[code]; }
53 + char *getCharName(int code) { return code>=256?0:enc[code]; }
55 // Returns true if the PDF font specified an encoding.
56 GBool getHasEncoding() { return hasEncoding; }
58 ===================================================================
59 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxState.cc,v
60 retrieving revision 1.10
61 retrieving revision 1.12
63 --- GfxState.cc 3 Dec 2005 10:11:33 -0000 1.10
64 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000 1.12
71 //------------------------------------------------------------------------
74 - 0.11 * color->c[2] + 0.5));
77 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
78 + unsigned char r,g,b;
79 + float c = color->c[0];
80 + float m = color->c[1];
81 + float y = color->c[2];
82 + float k = color->c[3];
83 + convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
89 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
90 double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
93 GfxIndexedColorSpace *indexedCS;
94 GfxSeparationColorSpace *sepCS;
95 int maxPixel, indexHigh;
96 + int maxPixelForAlloc;
100 @@ -3111,6 +3125,7 @@
101 // bits per component and color space
103 maxPixel = (1 << bits) - 1;
104 + maxPixelForAlloc = (1 << (bits>8?bits:8));
105 colorSpace = colorSpaceA;
108 @@ -3163,7 +3178,7 @@
109 lookup2 = indexedCS->getLookup();
110 colorSpace2->getDefaultRanges(x, y, indexHigh);
111 for (k = 0; k < nComps2; ++k) {
112 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
113 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
114 sizeof(GfxColorComp));
115 for (i = 0; i <= maxPixel; ++i) {
116 j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
117 @@ -3182,7 +3197,7 @@
118 nComps2 = colorSpace2->getNComps();
119 sepFunc = sepCS->getFunc();
120 for (k = 0; k < nComps2; ++k) {
121 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
122 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
123 sizeof(GfxColorComp));
124 for (i = 0; i <= maxPixel; ++i) {
125 x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
126 @@ -3192,7 +3207,7 @@
129 for (k = 0; k < nComps; ++k) {
130 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
131 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
132 sizeof(GfxColorComp));
133 for (i = 0; i <= maxPixel; ++i) {
134 lookup[k][i] = dblToCol(decodeLow[k] +
135 Index: GlobalParams.cc
136 ===================================================================
137 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.cc,v
138 retrieving revision 1.4
139 retrieving revision 1.7
141 --- GlobalParams.cc 3 Dec 2005 10:11:33 -0000 1.4
142 +++ GlobalParams.cc 18 Dec 2005 08:31:22 -0000 1.7
149 + char* cfgFileName = fileName->getCString();
150 + char* pos1 = strrchr(cfgFileName, '/');
151 + char* pos2 = strrchr(cfgFileName, '\\');
152 + char* p = pos1>pos2?pos1:pos2;
153 + int pos = p ? p-cfgFileName : -1;
154 + GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
158 + path->append('\\');
161 + path->append('\\');
167 + this->path = new GString();
171 while (getLine(buf, sizeof(buf) - 1, f)) {
177 +static GString* qualify_filename(GString*path, GString*filename)
179 + GString*fullpath = 0;
180 + char*prefix = "/usr/local/share/xpdf/";
182 + if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') {
183 + /* relative path */
184 + fullpath = path->copy();
185 + fullpath->append(filename);
186 + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
187 + /* xpdf default path */
188 + char*s = strchr(filename->getCString()+strlen(prefix), '/');
190 + fullpath = path->copy();
191 + fullpath->append(s+1);
193 + fullpath = filename->copy();
196 + /* absolute path */
197 + fullpath = filename->copy();
199 + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
203 void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
207 fileName->getCString(), line);
210 - name = (GString *)tokens->get(1);
211 + name = qualify_filename(this->path, (GString *)tokens->get(1));
212 if (!(f = fopen(name->getCString(), "r"))) {
213 error(-1, "Couldn't open 'nameToUnicode' file '%s'",
215 @@ -705,10 +754,12 @@
217 collection = (GString *)tokens->get(1);
218 name = (GString *)tokens->get(2);
220 if ((old = (GString *)cidToUnicodes->remove(collection))) {
223 - cidToUnicodes->add(collection->copy(), name->copy());
225 + cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
228 void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
230 if ((old = (GString *)unicodeToUnicodes->remove(font))) {
233 - unicodeToUnicodes->add(font->copy(), file->copy());
235 + unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
238 void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
240 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
243 - unicodeMaps->add(encodingName->copy(), name->copy());
245 + unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
248 void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
249 @@ -760,23 +813,30 @@
251 cMapDirs->add(collection->copy(), list);
253 - list->append(dir->copy());
255 + list->append(qualify_filename(this->path, dir));
258 void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
262 if (tokens->getLength() != 2) {
263 error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
264 fileName->getCString(), line);
267 - toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
269 + dir = (GString *)tokens->get(1);
271 + toUnicodeDirs->append(qualify_filename(this->path, dir));
274 void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
275 DisplayFontParamKind kind,
276 GString *fileName, int line) {
277 DisplayFontParam *param, *old;
280 if (tokens->getLength() < 2) {
282 @@ -788,13 +848,15 @@
283 if (tokens->getLength() != 3) {
286 - param->t1.fileName = ((GString *)tokens->get(2))->copy();
287 + file = (GString *)tokens->get(2);
288 + param->t1.fileName = qualify_filename(this->path, file);
291 if (tokens->getLength() != 3) {
294 - param->tt.fileName = ((GString *)tokens->get(2))->copy();
295 + file = (GString *)tokens->get(2);
296 + param->tt.fileName = qualify_filename(this->path, file);
301 ===================================================================
302 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
303 retrieving revision 1.4
304 retrieving revision 1.5
306 --- Lexer.cc 3 Dec 2005 10:11:33 -0000 1.4
307 +++ Lexer.cc 14 Mar 2006 12:43:23 -0000 1.5
309 curStr.streamReset();
312 +static int illegalChars = 0;
315 if (!curStr.isNone()) {
321 + error(0, "Illegal characters in hex string (%d)", illegalChars);
325 int Lexer::getChar() {
327 } else if (c2 >= 'a' && c2 <= 'f') {
330 - error(getPos(), "Illegal digit in hex char in name");
332 + //error(getPos(), "Illegal digit in hex char in name");
338 else if (c >= 'a' && c <= 'f')
341 - error(getPos(), "Illegal character <%02x> in hex string", c);
344 + //error(getPos(), "Illegal character <%02x> in hex string", c);
347 if (n == tokBufSize) {
351 obj->initCmd(tokBuf);
353 - error(getPos(), "Illegal character '>'");
355 + //error(getPos(), "Illegal character '>'");
363 - error(getPos(), "Illegal character '%c'", c);
364 + //error(getPos(), "Illegal character '%c'", c);
378 ===================================================================
379 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
380 retrieving revision 1.5
381 retrieving revision 1.6
383 --- Link.cc 3 Dec 2005 10:11:33 -0000 1.5
384 +++ Link.cc 26 Mar 2006 08:26:59 -0000 1.6
392 - error(-1, "Illegal annotation destination");
393 + error(-1, "Illegal annotation destination %d", destObj->getType());
404 - error(-1, "Illegal annotation destination");
405 + error(-1, "Illegal annotation destination %d", destObj->getType());
410 ===================================================================
411 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
412 retrieving revision 1.7
413 retrieving revision 1.9
415 --- OutputDev.h 3 Dec 2005 10:11:33 -0000 1.7
416 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000 1.9
418 virtual void setDefaultCTM(double *ctm);
421 - virtual void startPage(int pageNum, GfxState *state) {}
422 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
425 virtual void endPage() {}
427 ===================================================================
428 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
429 retrieving revision 1.7
430 retrieving revision 1.8
432 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
433 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
439 +extern "C" int unlink(char *filename);
444 ===================================================================
445 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/config.h,v
446 retrieving revision 1.5
447 retrieving revision 1.6
449 --- config.h 3 Dec 2005 10:11:33 -0000 1.5
450 +++ config.h 3 Dec 2005 10:30:41 -0000 1.6
453 // user config file name, relative to the user's home directory
454 #if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
455 -#define xpdfUserConfigFile "xpdfrc"
456 +#define xpdfUserConfigFile "pdf2swf.conf"
458 -#define xpdfUserConfigFile ".xpdfrc"
459 +#define xpdfUserConfigFile ".pdf2swf.conf"
462 // system config file name (set via the configure script)
463 -#ifdef SYSTEM_XPDFRC
464 -#define xpdfSysConfigFile SYSTEM_XPDFRC
466 +#define xpdfSysConfigFile "/etc/pdf2swf.conf"
468 // under Windows, we get the directory with the executable and then
469 // append this file name
470 -#define xpdfSysConfigFile "xpdfrc"
471 +#define xpdfSysConfigFile "pdf2swf.conf"
474 //------------------------------------------------------------------------
476 ===================================================================
477 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
478 retrieving revision 1.12
479 retrieving revision 1.13
480 diff -u -r1.12 -r1.13
481 --- gfile.cc 3 Dec 2005 10:11:33 -0000 1.12
482 +++ gfile.cc 3 Dec 2005 10:30:41 -0000 1.13
487 +static char* getTempDir()
490 + char*dir = getenv("TMP");
491 + if(!dir) dir = getenv("TEMP");
492 + if(!dir) dir = getenv("tmp");
493 + if(!dir) dir = getenv("temp");
494 + if(!dir) dir = "C:\\";
496 + char* dir = "/tmp/";
501 +char* mktmpname(char*ptr) {
502 + static char tmpbuf[128];
503 + char*dir = getTempDir();
504 + int l = strlen(dir);
508 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
516 + // used to be mktemp. This does remove the warnings, but
517 + // It's not exactly an improvement.
519 + sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
522 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
524 + static int count = 1;
525 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
533 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
535 //---------- Win32 ----------
537 // with this file name after the tmpnam call and before the fopen
538 // call. I will happily accept fixes to this function for non-Unix
540 - if (!(s = tmpnam(NULL))) {
541 + if (!(s = mktmpname(NULL))) {
544 *name = new GString(s);
546 (*name)->append("/XXXXXX")->append(ext);
547 fd = mkstemps((*name)->getCString(), strlen(ext));
549 - if (!(s = tmpnam(NULL))) {
550 + if (!(s = mktmpname(NULL))) {
553 *name = new GString(s);
555 (*name)->append("/XXXXXX");
556 fd = mkstemp((*name)->getCString());
557 #else // HAVE_MKSTEMP
558 - if (!(s = tmpnam(NULL))) {
559 + if (!(s = mktmpname(NULL))) {
562 *name = new GString(s);
564 ===================================================================
565 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
566 retrieving revision 1.9
567 retrieving revision 1.10
569 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
570 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
572 // Get current directory.
573 extern GString *getCurrentDir();
575 +/* create a temporary filename */
576 +char* mktmpname(char*ptr);
578 // Append a file name to a path string. <path> may be an empty
579 // string, denoting the current directory). Returns <path>.
580 extern GString *appendToPath(GString *path, char *fileName);
581 Index: GlobalParams.h
582 ===================================================================
583 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
584 retrieving revision 1.5
585 retrieving revision 1.6
587 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
588 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
590 - void parseFile(GString *fileName, FILE *f);
591 +public: void parseFile(GString *fileName, FILE *f); private:
593 GBool loadPlugin(char *type, char *name);
596 + //----- config file base path
600 //----- static tables
602 NameToCharCode * // mapping from char name to
603 --- SplashOutputDev.h.orig 2006-11-12 12:07:22.000000000 +0100
604 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
606 //----- initialization and control
609 - virtual void startPage(int pageNum, GfxState *state);
610 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
613 virtual void endPage();
614 --- SplashOutputDev.cc.orig 2006-11-12 12:07:06.000000000 +0100
615 +++ SplashOutputDev.cc 2006-11-12 12:09:36.000000000 +0100
620 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
621 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
625 --- TextOutputDev.h.orig 2006-11-12 12:23:01.000000000 +0100
626 +++ TextOutputDev.h 2006-11-12 12:25:31.000000000 +0100
628 //----- initialization and control
631 - virtual void startPage(int pageNum, GfxState *state);
632 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
635 virtual void endPage();
636 --- TextOutputDev.cc.orig 2006-11-12 12:22:53.000000000 +0100
637 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
638 @@ -3805,7 +3805,7 @@
642 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
643 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
644 text->startPage(state);
647 --- CoreOutputDev.cc.orig 2006-11-12 12:21:59.000000000 +0100
648 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
651 void CoreOutputDev::clear() {
653 - startPage(0, NULL);
654 + startPage(0, NULL, 0,0,0,0);
656 --- SplashFTFontEngine.cc 2006-11-19 22:30:44.000000000 +0100
657 +++ SplashFTFontEngine.cc 2006-11-19 22:30:56.000000000 +0100
668 --- xpdf/pdftoppm.cc.orig 2007-03-07 18:00:34.000000000 +0100
669 +++ xpdf/pdftoppm.cc 2007-03-07 18:00:41.000000000 +0100
671 splashOut->startDoc(doc->getXRef());
672 for (pg = firstPage; pg <= lastPage; ++pg) {
673 doc->displayPage(splashOut, pg, resolution, resolution, 0,
674 - gFalse, gTrue, gFalse);
675 + /*usemediabox*/gTrue, gTrue, gFalse);
676 sprintf(ppmFile, "%.*s-%06d.%s",
677 (int)sizeof(ppmFile) - 32, ppmRoot, pg,
678 mono ? "pbm" : gray ? "pgm" : "ppm");