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->startPage(pageNum, state, 0,0,0,0);
19 out->setDefaultCTM(state->getCTM());
20 out->updateAll(state);
21 for (i = 0; i < 6; ++i) {
23 abortCheckCbkData = abortCheckCbkDataA;
29 state->moveTo(cropBox->x1, cropBox->y1);
30 state->lineTo(cropBox->x2, cropBox->y1);
31 state->lineTo(cropBox->x2, cropBox->y2);
41 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
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
48 --- GfxFont.h 3 Dec 2005 10:11:33 -0000 1.6
49 +++ GfxFont.h 3 Dec 2005 10:30:41 -0000 1.7
51 CharCodeToUnicode *getToUnicode();
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]; }
57 // Returns true if the PDF font specified an encoding.
58 GBool getHasEncoding() { return hasEncoding; }
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
65 --- GfxState.cc 3 Dec 2005 10:11:33 -0000 1.10
66 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000 1.12
73 //------------------------------------------------------------------------
76 - 0.11 * color->c[2] + 0.5));
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);
91 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
92 double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
95 GfxIndexedColorSpace *indexedCS;
96 GfxSeparationColorSpace *sepCS;
97 int maxPixel, indexHigh;
98 + int maxPixelForAlloc;
102 @@ -3111,6 +3125,7 @@
103 // bits per component and color space
105 maxPixel = (1 << bits) - 1;
106 + maxPixelForAlloc = (1 << (bits>8?bits:8));
107 colorSpace = colorSpaceA;
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 @@
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
143 --- GlobalParams.cc 3 Dec 2005 10:11:33 -0000 1.4
144 +++ GlobalParams.cc 18 Dec 2005 08:31:22 -0000 1.7
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));
160 + path->append('\\');
163 + path->append('\\');
169 + this->path = new GString();
173 while (getLine(buf, sizeof(buf) - 1, f)) {
179 +static GString* qualify_filename(GString*path, GString*filename)
181 + GString*fullpath = 0;
182 + char*prefix = "/usr/local/share/xpdf/";
184 + if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') {
185 + /* relative path */
186 + fullpath = path->copy();
187 + fullpath->append(filename);
188 + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
189 + /* xpdf default path */
190 + char*s = strchr(filename->getCString()+strlen(prefix), '/');
192 + fullpath = path->copy();
193 + fullpath->append(s+1);
195 + fullpath = filename->copy();
198 + /* absolute path */
199 + fullpath = filename->copy();
201 + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
205 void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
209 fileName->getCString(), line);
212 - name = (GString *)tokens->get(1);
213 + name = qualify_filename(this->path, (GString *)tokens->get(1));
214 if (!(f = fopen(name->getCString(), "r"))) {
215 error(-1, "Couldn't open 'nameToUnicode' file '%s'",
217 @@ -705,10 +754,12 @@
219 collection = (GString *)tokens->get(1);
220 name = (GString *)tokens->get(2);
222 if ((old = (GString *)cidToUnicodes->remove(collection))) {
225 - cidToUnicodes->add(collection->copy(), name->copy());
227 + cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
230 void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
232 if ((old = (GString *)unicodeToUnicodes->remove(font))) {
235 - unicodeToUnicodes->add(font->copy(), file->copy());
237 + unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
240 void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
242 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
245 - unicodeMaps->add(encodingName->copy(), name->copy());
247 + unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
250 void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
251 @@ -760,23 +813,30 @@
253 cMapDirs->add(collection->copy(), list);
255 - list->append(dir->copy());
257 + list->append(qualify_filename(this->path, dir));
260 void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
264 if (tokens->getLength() != 2) {
265 error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
266 fileName->getCString(), line);
269 - toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
271 + dir = (GString *)tokens->get(1);
273 + toUnicodeDirs->append(qualify_filename(this->path, dir));
276 void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
277 DisplayFontParamKind kind,
278 GString *fileName, int line) {
279 DisplayFontParam *param, *old;
282 if (tokens->getLength() < 2) {
284 @@ -788,13 +848,15 @@
285 if (tokens->getLength() != 3) {
288 - param->t1.fileName = ((GString *)tokens->get(2))->copy();
289 + file = (GString *)tokens->get(2);
290 + param->t1.fileName = qualify_filename(this->path, file);
293 if (tokens->getLength() != 3) {
296 - param->tt.fileName = ((GString *)tokens->get(2))->copy();
297 + file = (GString *)tokens->get(2);
298 + param->tt.fileName = qualify_filename(this->path, file);
303 ===================================================================
304 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
305 retrieving revision 1.4
306 retrieving revision 1.5
308 --- Lexer.cc 3 Dec 2005 10:11:33 -0000 1.4
309 +++ Lexer.cc 14 Mar 2006 12:43:23 -0000 1.5
311 curStr.streamReset();
314 +static int illegalChars = 0;
317 if (!curStr.isNone()) {
323 + error(0, "Illegal characters in hex string (%d)", illegalChars);
327 int Lexer::getChar() {
329 } else if (c2 >= 'a' && c2 <= 'f') {
332 - error(getPos(), "Illegal digit in hex char in name");
334 + //error(getPos(), "Illegal digit in hex char in name");
340 else if (c >= 'a' && c <= 'f')
343 - error(getPos(), "Illegal character <%02x> in hex string", c);
346 + //error(getPos(), "Illegal character <%02x> in hex string", c);
349 if (n == tokBufSize) {
353 obj->initCmd(tokBuf);
355 - error(getPos(), "Illegal character '>'");
357 + //error(getPos(), "Illegal character '>'");
365 - error(getPos(), "Illegal character '%c'", c);
366 + //error(getPos(), "Illegal character '%c'", c);
380 ===================================================================
381 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
382 retrieving revision 1.5
383 retrieving revision 1.6
385 --- Link.cc 3 Dec 2005 10:11:33 -0000 1.5
386 +++ Link.cc 26 Mar 2006 08:26:59 -0000 1.6
394 - error(-1, "Illegal annotation destination");
395 + error(-1, "Illegal annotation destination %d", destObj->getType());
406 - error(-1, "Illegal annotation destination");
407 + error(-1, "Illegal annotation destination %d", destObj->getType());
412 ===================================================================
413 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
414 retrieving revision 1.7
415 retrieving revision 1.9
417 --- OutputDev.h 3 Dec 2005 10:11:33 -0000 1.7
418 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000 1.9
420 virtual void setDefaultCTM(double *ctm);
423 - virtual void startPage(int pageNum, GfxState *state) {}
424 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
427 virtual void endPage() {}
429 ===================================================================
430 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
431 retrieving revision 1.7
432 retrieving revision 1.8
434 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
435 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
441 +extern "C" int unlink(char *filename);
446 --- config.h.orig 2007-09-09 12:11:20.000000000 +0200
447 +++ config.h 2007-09-09 12:11:40.000000000 +0200
450 // user config file name, relative to the user's home directory
451 #if defined(VMS) || defined(WIN32)
452 -#define xpdfUserConfigFile "xpdfrc"
453 +#define xpdfUserConfigFile "pdf2swf.conf"
455 -#define xpdfUserConfigFile ".xpdfrc"
456 +#define xpdfUserConfigFile ".pdf2swf.conf"
459 // system config file name (set via the configure script)
462 // under Windows, we get the directory with the executable and then
463 // append this file name
464 -#define xpdfSysConfigFile "xpdfrc"
465 +#define xpdfSysConfigFile "pdf2swf.conf"
468 //------------------------------------------------------------------------
470 ===================================================================
471 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
472 retrieving revision 1.12
473 retrieving revision 1.13
474 diff -u -r1.12 -r1.13
475 --- gfile.cc 3 Dec 2005 10:11:33 -0000 1.12
476 +++ gfile.cc 3 Dec 2005 10:30:41 -0000 1.13
481 +static char* getTempDir()
484 + char*dir = getenv("TMP");
485 + if(!dir) dir = getenv("TEMP");
486 + if(!dir) dir = getenv("tmp");
487 + if(!dir) dir = getenv("temp");
488 + if(!dir) dir = "C:\\";
490 + char* dir = "/tmp/";
495 +char* mktmpname(char*ptr) {
496 + static char tmpbuf[128];
497 + char*dir = getTempDir();
498 + int l = strlen(dir);
502 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
510 + // used to be mktemp. This does remove the warnings, but
511 + // It's not exactly an improvement.
513 + sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
516 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
518 + static int count = 1;
519 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
527 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
529 //---------- Win32 ----------
531 // with this file name after the tmpnam call and before the fopen
532 // call. I will happily accept fixes to this function for non-Unix
534 - if (!(s = tmpnam(NULL))) {
535 + if (!(s = mktmpname(NULL))) {
538 *name = new GString(s);
540 (*name)->append("/XXXXXX")->append(ext);
541 fd = mkstemps((*name)->getCString(), strlen(ext));
543 - if (!(s = tmpnam(NULL))) {
544 + if (!(s = mktmpname(NULL))) {
547 *name = new GString(s);
549 (*name)->append("/XXXXXX");
550 fd = mkstemp((*name)->getCString());
551 #else // HAVE_MKSTEMP
552 - if (!(s = tmpnam(NULL))) {
553 + if (!(s = mktmpname(NULL))) {
556 *name = new GString(s);
558 ===================================================================
559 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
560 retrieving revision 1.9
561 retrieving revision 1.10
563 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
564 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
566 // Get current directory.
567 extern GString *getCurrentDir();
569 +/* create a temporary filename */
570 +char* mktmpname(char*ptr);
572 // Append a file name to a path string. <path> may be an empty
573 // string, denoting the current directory). Returns <path>.
574 extern GString *appendToPath(GString *path, char *fileName);
575 Index: GlobalParams.h
576 ===================================================================
577 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
578 retrieving revision 1.5
579 retrieving revision 1.6
581 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
582 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
584 FILE *getUnicodeMapFile(GString *encodingName);
585 FILE *findCMapFile(GString *collection, GString *cMapName);
586 FILE *findToUnicodeFile(GString *name);
587 - DisplayFontParam *getDisplayFont(GString *fontName);
588 - DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
589 + virtual DisplayFontParam *getDisplayFont(GString *fontName);
590 + virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
591 GString *getPSFile();
592 int getPSPaperWidth();
593 int getPSPaperHeight();
595 - void parseFile(GString *fileName, FILE *f);
596 +public: void parseFile(GString *fileName, FILE *f); private:
598 GBool loadPlugin(char *type, char *name);
601 + //----- config file base path
605 //----- static tables
607 NameToCharCode * // mapping from char name to
608 --- SplashOutputDev.h.orig 2006-11-12 12:07:22.000000000 +0100
609 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
611 //----- initialization and control
614 - virtual void startPage(int pageNum, GfxState *state);
615 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
618 virtual void endPage();
619 --- SplashOutputDev.cc.orig 2006-11-12 12:07:06.000000000 +0100
620 +++ SplashOutputDev.cc 2006-11-12 12:09:36.000000000 +0100
625 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
626 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
630 --- TextOutputDev.h.orig 2006-11-12 12:23:01.000000000 +0100
631 +++ TextOutputDev.h 2006-11-12 12:25:31.000000000 +0100
633 //----- initialization and control
636 - virtual void startPage(int pageNum, GfxState *state);
637 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
640 virtual void endPage();
641 --- TextOutputDev.cc.orig 2006-11-12 12:22:53.000000000 +0100
642 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
643 @@ -3805,7 +3805,7 @@
647 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
648 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
649 text->startPage(state);
652 --- CoreOutputDev.cc.orig 2006-11-12 12:21:59.000000000 +0100
653 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
656 void CoreOutputDev::clear() {
658 - startPage(0, NULL);
659 + startPage(0, NULL, 0,0,0,0);
661 --- SplashFTFontEngine.cc 2006-11-19 22:30:44.000000000 +0100
662 +++ SplashFTFontEngine.cc 2006-11-19 22:30:56.000000000 +0100
673 --- SplashOutputDev.cc.orig 2007-09-09 12:29:45.000000000 +0200
674 +++ SplashOutputDev.cc 2007-09-09 12:30:02.000000000 +0200
682 #include "GlobalParams.h"
683 --- SplashFontFile.cc.orig 2007-09-09 12:33:00.000000000 +0200
684 +++ SplashFontFile.cc 2007-09-09 12:33:07.000000000 +0200
690 -# include <unistd.h>
694 #include "SplashFontFile.h"
695 #include "SplashFontFileID.h"
696 --- SplashFont.orig.h 2007-09-09 14:23:47.000000000 +0200
697 +++ SplashFont.h 2007-09-09 14:24:28.000000000 +0200
699 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
700 SplashGlyphBitmap *bitmap) = 0;
702 + // return the number of characters in this font
703 + virtual int getNumChars() = 0;
705 // Return the path for a glyph.
706 virtual SplashPath *getGlyphPath(int c) = 0;
708 --- SplashFTFont.orig.h 2007-09-09 14:23:47.000000000 +0200
709 +++ SplashFTFont.h 2007-09-09 14:25:19.000000000 +0200
711 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
712 SplashGlyphBitmap *bitmap);
714 + // return the number of characters in this font
715 + virtual int getNumChars();
717 // Return the path for a glyph.
718 virtual SplashPath *getGlyphPath(int c);
720 --- SplashFTFont.cc.orig.h 2007-09-09 14:23:50.000000000 +0200
721 +++ SplashFTFont.cc 2007-09-09 14:27:35.000000000 +0200
726 +int SplashFTFont::getNumChars()
728 + SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
729 + return ff->face->num_glyphs;
732 SplashPath *SplashFTFont::getGlyphPath(int c) {
733 static FT_Outline_Funcs outlineFuncs = {
734 #if FREETYPE_MINOR <= 1
735 --- orig/GfxFont.h 2007-07-28 00:11:06.000000000 +0200
736 +++ GfxFont.h 2007-09-09 18:31:31.000000000 +0200
738 virtual int getNextChar(char *s, int len, CharCode *code,
739 Unicode *u, int uSize, int *uLen,
740 double *dx, double *dy, double *ox, double *oy) = 0;
741 + virtual CharCodeToUnicode* getCTU() = 0;
746 virtual int getNextChar(char *s, int len, CharCode *code,
747 Unicode *u, int uSize, int *uLen,
748 double *dx, double *dy, double *ox, double *oy);
749 + virtual CharCodeToUnicode* getCTU();
751 // Return the encoding.
752 char **getEncoding() { return enc; }
754 virtual int getNextChar(char *s, int len, CharCode *code,
755 Unicode *u, int uSize, int *uLen,
756 double *dx, double *dy, double *ox, double *oy);
757 + virtual CharCodeToUnicode* getCTU();
759 // Return the writing mode (0=horizontal, 1=vertical).
760 virtual int getWMode();
761 --- orig/GfxFont.cc 2007-07-28 00:11:06.000000000 +0200
762 +++ GfxFont.cc 2007-09-09 18:33:37.000000000 +0200
767 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
771 CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
774 @@ -1417,6 +1421,10 @@
778 +CharCodeToUnicode* GfxCIDFont::getCTU() {
782 int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
783 Unicode *u, int uSize, int *uLen,
784 double *dx, double *dy, double *ox, double *oy) {
785 --- OutputDev.h.orig Sat Jul 28 00:11:08 2007
786 +++ OutputDev.h Sun Sep 9 13:50:40 2007
790 #include "CharTypes.h"