2 ===================================================================
3 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/FoFiType1C.cc,v
4 retrieving revision 1.3
5 retrieving revision 1.4
7 --- FoFiType1C.cc 3 Dec 2005 10:11:33 -0000 1.3
8 +++ FoFiType1C.cc 3 Dec 2005 10:30:41 -0000 1.4
10 (*outputFunc)(outputStream,
11 "0 1 255 {1 index exch /.notdef put} for\n", 40);
12 enc = newEncoding ? newEncoding : encoding;
14 + fprintf(stderr, "convertToType1: Warning: No Encoding\n");
16 for (i = 0; i < 256; ++i) {
18 + if (enc && enc[i]) {
19 sprintf(buf, "dup %d /%s put\n", i, enc[i]);
20 (*outputFunc)(outputStream, buf, strlen(buf));
23 ===================================================================
24 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Gfx.cc,v
25 retrieving revision 1.9
26 retrieving revision 1.10
28 --- Gfx.cc 3 Dec 2005 10:11:33 -0000 1.9
29 +++ Gfx.cc 3 Dec 2005 10:30:41 -0000 1.10
34 - out->startPage(pageNum, state);
36 + out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
38 out->setDefaultCTM(state->getCTM());
39 out->updateAll(state);
40 for (i = 0; i < 6; ++i) {
42 abortCheckCbkData = abortCheckCbkDataA;
48 state->moveTo(cropBox->x1, cropBox->y1);
49 state->lineTo(cropBox->x2, cropBox->y1);
50 state->lineTo(cropBox->x2, cropBox->y2);
60 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
62 ===================================================================
63 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxFont.h,v
64 retrieving revision 1.6
65 retrieving revision 1.7
67 --- GfxFont.h 3 Dec 2005 10:11:33 -0000 1.6
68 +++ GfxFont.h 3 Dec 2005 10:30:41 -0000 1.7
70 CharCodeToUnicode *getToUnicode();
72 // Return the character name associated with <code>.
73 - char *getCharName(int code) { return enc[code]; }
74 + char *getCharName(int code) { return code>=256?0:enc[code]; }
76 // Returns true if the PDF font specified an encoding.
77 GBool getHasEncoding() { return hasEncoding; }
79 ===================================================================
80 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxState.cc,v
81 retrieving revision 1.10
82 retrieving revision 1.12
84 --- GfxState.cc 3 Dec 2005 10:11:33 -0000 1.10
85 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000 1.12
92 //------------------------------------------------------------------------
95 - 0.11 * color->c[2] + 0.5));
98 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
99 + unsigned char r,g,b;
100 + float c = color->c[0];
101 + float m = color->c[1];
102 + float y = color->c[2];
103 + float k = color->c[3];
104 + convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
110 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
111 double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
113 @@ -3099,6 +3112,7 @@
114 GfxIndexedColorSpace *indexedCS;
115 GfxSeparationColorSpace *sepCS;
116 int maxPixel, indexHigh;
117 + int maxPixelForAlloc;
121 @@ -3111,6 +3125,7 @@
122 // bits per component and color space
124 maxPixel = (1 << bits) - 1;
125 + maxPixelForAlloc = (1 << (bits>8?bits:8));
126 colorSpace = colorSpaceA;
129 @@ -3163,7 +3178,7 @@
130 lookup2 = indexedCS->getLookup();
131 colorSpace2->getDefaultRanges(x, y, indexHigh);
132 for (k = 0; k < nComps2; ++k) {
133 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
134 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
135 sizeof(GfxColorComp));
136 for (i = 0; i <= maxPixel; ++i) {
137 j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
138 @@ -3182,7 +3197,7 @@
139 nComps2 = colorSpace2->getNComps();
140 sepFunc = sepCS->getFunc();
141 for (k = 0; k < nComps2; ++k) {
142 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
143 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
144 sizeof(GfxColorComp));
145 for (i = 0; i <= maxPixel; ++i) {
146 x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
147 @@ -3192,7 +3207,7 @@
150 for (k = 0; k < nComps; ++k) {
151 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
152 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
153 sizeof(GfxColorComp));
154 for (i = 0; i <= maxPixel; ++i) {
155 lookup[k][i] = dblToCol(decodeLow[k] +
156 Index: GlobalParams.cc
157 ===================================================================
158 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.cc,v
159 retrieving revision 1.4
160 retrieving revision 1.7
162 --- GlobalParams.cc 3 Dec 2005 10:11:33 -0000 1.4
163 +++ GlobalParams.cc 18 Dec 2005 08:31:22 -0000 1.7
170 + char* cfgFileName = fileName->getCString();
171 + char* pos1 = strrchr(cfgFileName, '/');
172 + char* pos2 = strrchr(cfgFileName, '\\');
173 + char* p = pos1>pos2?pos1:pos2;
174 + int pos = p ? p-cfgFileName : -1;
175 + GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
179 + path->append('\\');
182 + path->append('\\');
188 + this->path = new GString();
192 while (getLine(buf, sizeof(buf) - 1, f)) {
198 +static GString* qualify_filename(GString*path, GString*filename)
200 + GString*fullpath = 0;
201 + char*prefix = "/usr/local/share/xpdf/";
203 + if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') {
204 + /* relative path */
205 + fullpath = path->copy();
206 + fullpath->append(filename);
207 + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
208 + /* xpdf default path */
209 + char*s = strchr(filename->getCString()+strlen(prefix), '/');
211 + fullpath = path->copy();
212 + fullpath->append(s+1);
214 + fullpath = filename->copy();
217 + /* absolute path */
218 + fullpath = filename->copy();
220 + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
224 void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
228 fileName->getCString(), line);
231 - name = (GString *)tokens->get(1);
232 + name = qualify_filename(this->path, (GString *)tokens->get(1));
233 if (!(f = fopen(name->getCString(), "r"))) {
234 error(-1, "Couldn't open 'nameToUnicode' file '%s'",
236 @@ -705,10 +754,12 @@
238 collection = (GString *)tokens->get(1);
239 name = (GString *)tokens->get(2);
241 if ((old = (GString *)cidToUnicodes->remove(collection))) {
244 - cidToUnicodes->add(collection->copy(), name->copy());
246 + cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
249 void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
251 if ((old = (GString *)unicodeToUnicodes->remove(font))) {
254 - unicodeToUnicodes->add(font->copy(), file->copy());
256 + unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
259 void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
261 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
264 - unicodeMaps->add(encodingName->copy(), name->copy());
266 + unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
269 void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
270 @@ -760,23 +813,30 @@
272 cMapDirs->add(collection->copy(), list);
274 - list->append(dir->copy());
276 + list->append(qualify_filename(this->path, dir));
279 void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
283 if (tokens->getLength() != 2) {
284 error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
285 fileName->getCString(), line);
288 - toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
290 + dir = (GString *)tokens->get(1);
292 + toUnicodeDirs->append(qualify_filename(this->path, dir));
295 void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
296 DisplayFontParamKind kind,
297 GString *fileName, int line) {
298 DisplayFontParam *param, *old;
301 if (tokens->getLength() < 2) {
303 @@ -788,13 +848,15 @@
304 if (tokens->getLength() != 3) {
307 - param->t1.fileName = ((GString *)tokens->get(2))->copy();
308 + file = (GString *)tokens->get(2);
309 + param->t1.fileName = qualify_filename(this->path, file);
312 if (tokens->getLength() != 3) {
315 - param->tt.fileName = ((GString *)tokens->get(2))->copy();
316 + file = (GString *)tokens->get(2);
317 + param->tt.fileName = qualify_filename(this->path, file);
322 ===================================================================
323 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
324 retrieving revision 1.4
325 retrieving revision 1.5
327 --- Lexer.cc 3 Dec 2005 10:11:33 -0000 1.4
328 +++ Lexer.cc 14 Mar 2006 12:43:23 -0000 1.5
330 curStr.streamReset();
333 +static int illegalChars = 0;
336 if (!curStr.isNone()) {
342 + error(0, "Illegal characters in hex string (%d)", illegalChars);
346 int Lexer::getChar() {
348 } else if (c2 >= 'a' && c2 <= 'f') {
351 - error(getPos(), "Illegal digit in hex char in name");
353 + //error(getPos(), "Illegal digit in hex char in name");
359 else if (c >= 'a' && c <= 'f')
362 - error(getPos(), "Illegal character <%02x> in hex string", c);
365 + //error(getPos(), "Illegal character <%02x> in hex string", c);
368 if (n == tokBufSize) {
372 obj->initCmd(tokBuf);
374 - error(getPos(), "Illegal character '>'");
376 + //error(getPos(), "Illegal character '>'");
384 - error(getPos(), "Illegal character '%c'", c);
385 + //error(getPos(), "Illegal character '%c'", c);
399 ===================================================================
400 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
401 retrieving revision 1.5
402 retrieving revision 1.6
404 --- Link.cc 3 Dec 2005 10:11:33 -0000 1.5
405 +++ Link.cc 26 Mar 2006 08:26:59 -0000 1.6
413 - error(-1, "Illegal annotation destination");
414 + error(-1, "Illegal annotation destination %d", destObj->getType());
425 - error(-1, "Illegal annotation destination");
426 + error(-1, "Illegal annotation destination %d", destObj->getType());
431 ===================================================================
432 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
433 retrieving revision 1.7
434 retrieving revision 1.9
436 --- OutputDev.h 3 Dec 2005 10:11:33 -0000 1.7
437 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000 1.9
439 virtual void setDefaultCTM(double *ctm);
442 - virtual void startPage(int pageNum, GfxState *state) {}
443 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
446 virtual void endPage() {}
448 ===================================================================
449 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Page.cc,v
450 retrieving revision 1.5
451 retrieving revision 1.6
453 --- Page.cc 3 Dec 2005 10:11:33 -0000 1.5
454 +++ Page.cc 3 Dec 2005 10:30:41 -0000 1.6
459 + /* if the crop box is larger than the media box, cut it down to
462 + mediaBox.x1 <= cropBox.x2 &&
463 + mediaBox.y1 <= cropBox.y2 &&
464 + cropBox.x1 <= mediaBox.x2 &&
465 + cropBox.y1 <= mediaBox.y2) {
466 + if(mediaBox.x1 >= cropBox.x1) cropBox.x1 = mediaBox.x1;
467 + if(mediaBox.y1 >= cropBox.y1) cropBox.y1 = mediaBox.y1;
468 + if(mediaBox.x2 <= cropBox.x2) cropBox.x2 = mediaBox.x2;
469 + if(mediaBox.y2 <= cropBox.y2) cropBox.y2 = mediaBox.y2;
474 readBox(dict, "BleedBox", &bleedBox);
476 ===================================================================
477 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
478 retrieving revision 1.7
479 retrieving revision 1.8
481 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
482 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
488 +extern "C" int unlink(char *filename);
493 ===================================================================
494 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/config.h,v
495 retrieving revision 1.5
496 retrieving revision 1.6
498 --- config.h 3 Dec 2005 10:11:33 -0000 1.5
499 +++ config.h 3 Dec 2005 10:30:41 -0000 1.6
502 // user config file name, relative to the user's home directory
503 #if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
504 -#define xpdfUserConfigFile "xpdfrc"
505 +#define xpdfUserConfigFile "pdf2swf.conf"
507 -#define xpdfUserConfigFile ".xpdfrc"
508 +#define xpdfUserConfigFile ".pdf2swf.conf"
511 // system config file name (set via the configure script)
512 -#ifdef SYSTEM_XPDFRC
513 -#define xpdfSysConfigFile SYSTEM_XPDFRC
515 +#define xpdfSysConfigFile "/etc/pdf2swf.conf"
517 // under Windows, we get the directory with the executable and then
518 // append this file name
519 -#define xpdfSysConfigFile "xpdfrc"
520 +#define xpdfSysConfigFile "pdf2swf.conf"
523 //------------------------------------------------------------------------
525 ===================================================================
526 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
527 retrieving revision 1.12
528 retrieving revision 1.13
529 diff -u -r1.12 -r1.13
530 --- gfile.cc 3 Dec 2005 10:11:33 -0000 1.12
531 +++ gfile.cc 3 Dec 2005 10:30:41 -0000 1.13
536 +static char* getTempDir()
539 + char*dir = getenv("TMP");
540 + if(!dir) dir = getenv("TEMP");
541 + if(!dir) dir = getenv("tmp");
542 + if(!dir) dir = getenv("temp");
543 + if(!dir) dir = "C:\\";
545 + char* dir = "/tmp/";
550 +char* mktmpname(char*ptr) {
551 + static char tmpbuf[128];
552 + char*dir = getTempDir();
553 + int l = strlen(dir);
557 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
565 + // used to be mktemp. This does remove the warnings, but
566 + // It's not exactly an improvement.
568 + sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
571 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
573 + static int count = 1;
574 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
582 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
584 //---------- Win32 ----------
586 // with this file name after the tmpnam call and before the fopen
587 // call. I will happily accept fixes to this function for non-Unix
589 - if (!(s = tmpnam(NULL))) {
590 + if (!(s = mktmpname(NULL))) {
593 *name = new GString(s);
595 (*name)->append("/XXXXXX")->append(ext);
596 fd = mkstemps((*name)->getCString(), strlen(ext));
598 - if (!(s = tmpnam(NULL))) {
599 + if (!(s = mktmpname(NULL))) {
602 *name = new GString(s);
604 (*name)->append("/XXXXXX");
605 fd = mkstemp((*name)->getCString());
606 #else // HAVE_MKSTEMP
607 - if (!(s = tmpnam(NULL))) {
608 + if (!(s = mktmpname(NULL))) {
611 *name = new GString(s);
613 ===================================================================
614 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
615 retrieving revision 1.9
616 retrieving revision 1.10
618 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
619 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
621 // Get current directory.
622 extern GString *getCurrentDir();
624 +/* create a temporary filename */
625 +char* mktmpname(char*ptr);
627 // Append a file name to a path string. <path> may be an empty
628 // string, denoting the current directory). Returns <path>.
629 extern GString *appendToPath(GString *path, char *fileName);
630 Index: GlobalParams.h
631 ===================================================================
632 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
633 retrieving revision 1.5
634 retrieving revision 1.6
636 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
637 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
639 - void parseFile(GString *fileName, FILE *f);
640 +public: void parseFile(GString *fileName, FILE *f); private:
642 GBool loadPlugin(char *type, char *name);
645 + //----- config file base path
649 //----- static tables
651 NameToCharCode * // mapping from char name to
652 --- SplashOutputDev.h.orig 2006-11-12 12:07:22.000000000 +0100
653 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
655 //----- initialization and control
658 - virtual void startPage(int pageNum, GfxState *state);
659 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
662 virtual void endPage();
663 --- SplashOutputDev.cc.orig 2006-11-12 12:07:06.000000000 +0100
664 +++ SplashOutputDev.cc 2006-11-12 12:09:36.000000000 +0100
669 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
670 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
674 --- TextOutputDev.h.orig 2006-11-12 12:23:01.000000000 +0100
675 +++ TextOutputDev.h 2006-11-12 12:25:31.000000000 +0100
677 //----- initialization and control
680 - virtual void startPage(int pageNum, GfxState *state);
681 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
684 virtual void endPage();
685 --- TextOutputDev.cc.orig 2006-11-12 12:22:53.000000000 +0100
686 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
687 @@ -3805,7 +3805,7 @@
691 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
692 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
693 text->startPage(state);
696 --- CoreOutputDev.cc.orig 2006-11-12 12:21:59.000000000 +0100
697 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
700 void CoreOutputDev::clear() {
702 - startPage(0, NULL);
703 + startPage(0, NULL, 0,0,0,0);