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);
321 Index: GlobalParams.h
322 ===================================================================
323 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
324 retrieving revision 1.5
325 retrieving revision 1.6
327 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
328 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
330 GBool loadPlugin(char *type, char *name);
333 + //----- config file base path
337 //----- static tables
339 NameToCharCode * // mapping from char name to
341 - void parseFile(GString *fileName, FILE *f);
342 +public: void parseFile(GString *fileName, FILE *f); private:
344 ===================================================================
345 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
346 retrieving revision 1.4
347 retrieving revision 1.5
349 --- Lexer.cc 3 Dec 2005 10:11:33 -0000 1.4
350 +++ Lexer.cc 14 Mar 2006 12:43:23 -0000 1.5
352 curStr.streamReset();
355 +static int illegalChars = 0;
358 if (!curStr.isNone()) {
364 + error(0, "Illegal characters in hex string (%d)", illegalChars);
368 int Lexer::getChar() {
370 } else if (c2 >= 'a' && c2 <= 'f') {
373 - error(getPos(), "Illegal digit in hex char in name");
375 + //error(getPos(), "Illegal digit in hex char in name");
381 else if (c >= 'a' && c <= 'f')
384 - error(getPos(), "Illegal character <%02x> in hex string", c);
387 + //error(getPos(), "Illegal character <%02x> in hex string", c);
390 if (n == tokBufSize) {
394 obj->initCmd(tokBuf);
396 - error(getPos(), "Illegal character '>'");
398 + //error(getPos(), "Illegal character '>'");
406 - error(getPos(), "Illegal character '%c'", c);
407 + //error(getPos(), "Illegal character '%c'", c);
421 ===================================================================
422 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
423 retrieving revision 1.5
424 retrieving revision 1.6
426 --- Link.cc 3 Dec 2005 10:11:33 -0000 1.5
427 +++ Link.cc 26 Mar 2006 08:26:59 -0000 1.6
435 - error(-1, "Illegal annotation destination");
436 + error(-1, "Illegal annotation destination %d", destObj->getType());
447 - error(-1, "Illegal annotation destination");
448 + error(-1, "Illegal annotation destination %d", destObj->getType());
453 ===================================================================
454 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
455 retrieving revision 1.7
456 retrieving revision 1.9
458 --- OutputDev.h 3 Dec 2005 10:11:33 -0000 1.7
459 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000 1.9
461 virtual void setDefaultCTM(double *ctm);
464 - virtual void startPage(int pageNum, GfxState *state) {}
465 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
468 virtual void endPage() {}
470 ===================================================================
471 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Page.cc,v
472 retrieving revision 1.5
473 retrieving revision 1.6
475 --- Page.cc 3 Dec 2005 10:11:33 -0000 1.5
476 +++ Page.cc 3 Dec 2005 10:30:41 -0000 1.6
481 + /* if the crop box is larger than the media box, cut it down to
484 + mediaBox.x1 <= cropBox.x2 &&
485 + mediaBox.y1 <= cropBox.y2 &&
486 + cropBox.x1 <= mediaBox.x2 &&
487 + cropBox.y1 <= mediaBox.y2) {
488 + if(mediaBox.x1 >= cropBox.x1) cropBox.x1 = mediaBox.x1;
489 + if(mediaBox.y1 >= cropBox.y1) cropBox.y1 = mediaBox.y1;
490 + if(mediaBox.x2 <= cropBox.x2) cropBox.x2 = mediaBox.x2;
491 + if(mediaBox.y2 <= cropBox.y2) cropBox.y2 = mediaBox.y2;
496 readBox(dict, "BleedBox", &bleedBox);
498 ===================================================================
499 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
500 retrieving revision 1.7
501 retrieving revision 1.8
503 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
504 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
510 +extern "C" int unlink(char *filename);
515 ===================================================================
516 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/config.h,v
517 retrieving revision 1.5
518 retrieving revision 1.6
520 --- config.h 3 Dec 2005 10:11:33 -0000 1.5
521 +++ config.h 3 Dec 2005 10:30:41 -0000 1.6
524 // user config file name, relative to the user's home directory
525 #if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
526 -#define xpdfUserConfigFile "xpdfrc"
527 +#define xpdfUserConfigFile "pdf2swf.conf"
529 -#define xpdfUserConfigFile ".xpdfrc"
530 +#define xpdfUserConfigFile ".pdf2swf.conf"
533 // system config file name (set via the configure script)
534 -#ifdef SYSTEM_XPDFRC
535 -#define xpdfSysConfigFile SYSTEM_XPDFRC
537 +#define xpdfSysConfigFile "/etc/pdf2swf.conf"
539 // under Windows, we get the directory with the executable and then
540 // append this file name
541 -#define xpdfSysConfigFile "xpdfrc"
542 +#define xpdfSysConfigFile "pdf2swf.conf"
545 //------------------------------------------------------------------------
547 ===================================================================
548 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
549 retrieving revision 1.12
550 retrieving revision 1.13
551 diff -u -r1.12 -r1.13
552 --- gfile.cc 3 Dec 2005 10:11:33 -0000 1.12
553 +++ gfile.cc 3 Dec 2005 10:30:41 -0000 1.13
558 +static char* getTempDir()
561 + char*dir = getenv("TMP");
562 + if(!dir) dir = getenv("TEMP");
563 + if(!dir) dir = getenv("tmp");
564 + if(!dir) dir = getenv("temp");
565 + if(!dir) dir = "C:\\";
567 + char* dir = "/tmp/";
572 +char* mktmpname(char*ptr) {
573 + static char tmpbuf[128];
574 + char*dir = getTempDir();
575 + int l = strlen(dir);
579 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
587 + // used to be mktemp. This does remove the warnings, but
588 + // It's not exactly an improvement.
590 + sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
593 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
595 + static int count = 1;
596 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
604 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
606 //---------- Win32 ----------
608 // with this file name after the tmpnam call and before the fopen
609 // call. I will happily accept fixes to this function for non-Unix
611 - if (!(s = tmpnam(NULL))) {
612 + if (!(s = mktmpname(NULL))) {
615 *name = new GString(s);
617 (*name)->append("/XXXXXX")->append(ext);
618 fd = mkstemps((*name)->getCString(), strlen(ext));
620 - if (!(s = tmpnam(NULL))) {
621 + if (!(s = mktmpname(NULL))) {
624 *name = new GString(s);
626 (*name)->append("/XXXXXX");
627 fd = mkstemp((*name)->getCString());
628 #else // HAVE_MKSTEMP
629 - if (!(s = tmpnam(NULL))) {
630 + if (!(s = mktmpname(NULL))) {
633 *name = new GString(s);
635 ===================================================================
636 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
637 retrieving revision 1.9
638 retrieving revision 1.10
640 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
641 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
643 // Get current directory.
644 extern GString *getCurrentDir();
646 +/* create a temporary filename */
647 +char* mktmpname(char*ptr);
649 // Append a file name to a path string. <path> may be an empty
650 // string, denoting the current directory). Returns <path>.
651 extern GString *appendToPath(GString *path, char *fileName);
652 --- pdf/xpdf-3.01.16/GlobalParams.h 2006-11-12 11:20:54.000000000 +0100
653 +++ j 2006-11-12 11:19:40.000000000 +0100
657 void createDefaultKeyBindings();
658 - void parseFile(GString *fileName, FILE *f);
659 +public: void parseFile(GString *fileName, FILE *f); private:
660 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
661 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
662 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
663 --- SplashOutputDev.h.orig 2006-11-12 12:07:22.000000000 +0100
664 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
666 //----- initialization and control
669 - virtual void startPage(int pageNum, GfxState *state);
670 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
673 virtual void endPage();
674 --- SplashOutputDev.cc.orig 2006-11-12 12:07:06.000000000 +0100
675 +++ SplashOutputDev.cc 2006-11-12 12:09:36.000000000 +0100
680 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
681 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
685 --- TextOutputDev.h.orig 2006-11-12 12:23:01.000000000 +0100
686 +++ TextOutputDev.h 2006-11-12 12:25:31.000000000 +0100
688 //----- initialization and control
691 - virtual void startPage(int pageNum, GfxState *state);
692 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
695 virtual void endPage();
696 --- TextOutputDev.cc.orig 2006-11-12 12:22:53.000000000 +0100
697 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
698 @@ -3805,7 +3805,7 @@
702 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
703 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
704 text->startPage(state);
707 --- CoreOutputDev.cc.orig 2006-11-12 12:21:59.000000000 +0100
708 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
711 void CoreOutputDev::clear() {
713 - startPage(0, NULL);
714 + startPage(0, NULL, 0,0,0,0);