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/Page.cc,v
429 retrieving revision 1.5
430 retrieving revision 1.6
432 --- Page.cc 3 Dec 2005 10:11:33 -0000 1.5
433 +++ Page.cc 3 Dec 2005 10:30:41 -0000 1.6
438 + /* if the crop box is larger than the media box, cut it down to
441 + mediaBox.x1 <= cropBox.x2 &&
442 + mediaBox.y1 <= cropBox.y2 &&
443 + cropBox.x1 <= mediaBox.x2 &&
444 + cropBox.y1 <= mediaBox.y2) {
445 + if(mediaBox.x1 >= cropBox.x1) cropBox.x1 = mediaBox.x1;
446 + if(mediaBox.y1 >= cropBox.y1) cropBox.y1 = mediaBox.y1;
447 + if(mediaBox.x2 <= cropBox.x2) cropBox.x2 = mediaBox.x2;
448 + if(mediaBox.y2 <= cropBox.y2) cropBox.y2 = mediaBox.y2;
453 readBox(dict, "BleedBox", &bleedBox);
455 ===================================================================
456 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
457 retrieving revision 1.7
458 retrieving revision 1.8
460 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
461 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
467 +extern "C" int unlink(char *filename);
472 ===================================================================
473 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/config.h,v
474 retrieving revision 1.5
475 retrieving revision 1.6
477 --- config.h 3 Dec 2005 10:11:33 -0000 1.5
478 +++ config.h 3 Dec 2005 10:30:41 -0000 1.6
481 // user config file name, relative to the user's home directory
482 #if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
483 -#define xpdfUserConfigFile "xpdfrc"
484 +#define xpdfUserConfigFile "pdf2swf.conf"
486 -#define xpdfUserConfigFile ".xpdfrc"
487 +#define xpdfUserConfigFile ".pdf2swf.conf"
490 // system config file name (set via the configure script)
491 -#ifdef SYSTEM_XPDFRC
492 -#define xpdfSysConfigFile SYSTEM_XPDFRC
494 +#define xpdfSysConfigFile "/etc/pdf2swf.conf"
496 // under Windows, we get the directory with the executable and then
497 // append this file name
498 -#define xpdfSysConfigFile "xpdfrc"
499 +#define xpdfSysConfigFile "pdf2swf.conf"
502 //------------------------------------------------------------------------
504 ===================================================================
505 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
506 retrieving revision 1.12
507 retrieving revision 1.13
508 diff -u -r1.12 -r1.13
509 --- gfile.cc 3 Dec 2005 10:11:33 -0000 1.12
510 +++ gfile.cc 3 Dec 2005 10:30:41 -0000 1.13
515 +static char* getTempDir()
518 + char*dir = getenv("TMP");
519 + if(!dir) dir = getenv("TEMP");
520 + if(!dir) dir = getenv("tmp");
521 + if(!dir) dir = getenv("temp");
522 + if(!dir) dir = "C:\\";
524 + char* dir = "/tmp/";
529 +char* mktmpname(char*ptr) {
530 + static char tmpbuf[128];
531 + char*dir = getTempDir();
532 + int l = strlen(dir);
536 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
544 + // used to be mktemp. This does remove the warnings, but
545 + // It's not exactly an improvement.
547 + sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
550 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
552 + static int count = 1;
553 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
561 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
563 //---------- Win32 ----------
565 // with this file name after the tmpnam call and before the fopen
566 // call. I will happily accept fixes to this function for non-Unix
568 - if (!(s = tmpnam(NULL))) {
569 + if (!(s = mktmpname(NULL))) {
572 *name = new GString(s);
574 (*name)->append("/XXXXXX")->append(ext);
575 fd = mkstemps((*name)->getCString(), strlen(ext));
577 - if (!(s = tmpnam(NULL))) {
578 + if (!(s = mktmpname(NULL))) {
581 *name = new GString(s);
583 (*name)->append("/XXXXXX");
584 fd = mkstemp((*name)->getCString());
585 #else // HAVE_MKSTEMP
586 - if (!(s = tmpnam(NULL))) {
587 + if (!(s = mktmpname(NULL))) {
590 *name = new GString(s);
592 ===================================================================
593 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
594 retrieving revision 1.9
595 retrieving revision 1.10
597 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
598 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
600 // Get current directory.
601 extern GString *getCurrentDir();
603 +/* create a temporary filename */
604 +char* mktmpname(char*ptr);
606 // Append a file name to a path string. <path> may be an empty
607 // string, denoting the current directory). Returns <path>.
608 extern GString *appendToPath(GString *path, char *fileName);
609 Index: GlobalParams.h
610 ===================================================================
611 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
612 retrieving revision 1.5
613 retrieving revision 1.6
615 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
616 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
618 - void parseFile(GString *fileName, FILE *f);
619 +public: void parseFile(GString *fileName, FILE *f); private:
621 GBool loadPlugin(char *type, char *name);
624 + //----- config file base path
628 //----- static tables
630 NameToCharCode * // mapping from char name to
631 --- SplashOutputDev.h.orig 2006-11-12 12:07:22.000000000 +0100
632 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
634 //----- initialization and control
637 - virtual void startPage(int pageNum, GfxState *state);
638 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
641 virtual void endPage();
642 --- SplashOutputDev.cc.orig 2006-11-12 12:07:06.000000000 +0100
643 +++ SplashOutputDev.cc 2006-11-12 12:09:36.000000000 +0100
648 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
649 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
653 --- TextOutputDev.h.orig 2006-11-12 12:23:01.000000000 +0100
654 +++ TextOutputDev.h 2006-11-12 12:25:31.000000000 +0100
656 //----- initialization and control
659 - virtual void startPage(int pageNum, GfxState *state);
660 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
663 virtual void endPage();
664 --- TextOutputDev.cc.orig 2006-11-12 12:22:53.000000000 +0100
665 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
666 @@ -3805,7 +3805,7 @@
670 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
671 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
672 text->startPage(state);
675 --- CoreOutputDev.cc.orig 2006-11-12 12:21:59.000000000 +0100
676 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
679 void CoreOutputDev::clear() {
681 - startPage(0, NULL);
682 + startPage(0, NULL, 0,0,0,0);
684 --- SplashFTFontEngine.cc 2006-11-19 22:30:44.000000000 +0100
685 +++ SplashFTFontEngine.cc 2006-11-19 22:30:56.000000000 +0100