From 8032fd96d450ac015c0153f1fa57e974d67b4993 Mon Sep 17 00:00:00 2001 From: Martin Kretzschmar Date: Mon, 31 Mar 2003 23:23:17 +0000 Subject: update * ANNOUNCE, CHANGES, README, aconf-win32.h: update * xpdf/CharCodeToUnicode.cc, xpdf/Decrypt.cc, xpdf/FTFont.cc, xpdf/FTFont.h, xpdf/FontEncodingTables.cc, xpdf/Gfx.cc, xpdf/GfxFont.cc, xpdf/GfxState.cc, xpdf/GfxState.h, xpdf/GlobalParams.cc, xpdf/GlobalParams.h, xpdf/Link.cc, xpdf/NameToUnicodeTable.h, xpdf/Stream.cc, xpdf/TextOutputDev.cc, xpdf/TextOutputDev.h, xpdf/XOutputDev.cc, xpdf/config.h, xpdf/pdftotext.cc, xpdf/xpdf.cc, xpdf/Outline.cc, xpdf/XPDFApp.cc, xpdf/XPDFApp.h, xpdf/XPDFCore.cc, xpdf/XPDFCore.h, xpdf/XPDFViewer.cc, xpdf/XPDFViewer.h: update. * goo/gfile.cc: update. * goo/Makefile.am: use GMutex.h * doc/pdffonts.1, doc/pdffonts.cat, doc/pdfimages.1, doc/pdfimages.cat, doc/pdfinfo.1, doc/pdfinfo.cat, doc/pdftopbm.1, doc/pdftopbm.cat, doc/pdftops.1, doc/pdftops.cat, doc/pdftotext.1, doc/pdftotext.cat, doc/pdftotext.hlp, doc/xpdf.1, doc/xpdf.cat, doc/xpdf.hlp, doc/xpdfrc.5, doc/xpdfrc.cat, doc/xpdfrc.hlp: update --- (limited to 'pdf/xpdf/GlobalParams.cc') diff --git a/pdf/xpdf/GlobalParams.cc b/pdf/xpdf/GlobalParams.cc index b50c15b..ded583f 100644 --- a/pdf/xpdf/GlobalParams.cc +++ b/pdf/xpdf/GlobalParams.cc @@ -31,6 +31,14 @@ #include "FontEncodingTables.h" #include "GlobalParams.h" +#if MULTITHREADED +# define globalParamsLock gLockMutex(&mutex) +# define globalParamsUnlock gUnlockMutex(&mutex) +#else +# define globalParamsLock +# define globalParamsUnlock +#endif + #include "NameToUnicodeTable.h" #include "UnicodeMapTables.h" #include "DisplayFontTable.h" @@ -124,6 +132,10 @@ GlobalParams::GlobalParams(char *cfgFileName) { FILE *f; int i; +#if MULTITHREADED + gInitMutex(&mutex); +#endif + initBuiltinFontTables(); // scan the encoding in reverse because we want the lowest-numbered @@ -276,7 +288,7 @@ void GlobalParams::parseFile(GString *fileName, FILE *f) { FILE *f2; line = 1; - while (fgets(buf, sizeof(buf) - 1, f)) { + while (getLine(buf, sizeof(buf) - 1, f)) { // break the line into tokens tokens = new GList(); @@ -293,7 +305,7 @@ void GlobalParams::parseFile(GString *fileName, FILE *f) { for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ; } tokens->append(new GString(p1, p2 - p1)); - p1 = p2 + 1; + p1 = *p2 ? p2 + 1 : p2; } if (tokens->getLength() > 0 && @@ -329,12 +341,18 @@ void GlobalParams::parseFile(GString *fileName, FILE *f) { parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line); } else if (!cmd->cmp("displayFontTT")) { parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line); + } else if (!cmd->cmp("displayNamedCIDFontX")) { + parseDisplayFont(tokens, displayNamedCIDFonts, + displayFontX, fileName, line); } else if (!cmd->cmp("displayCIDFontX")) { parseDisplayFont(tokens, displayCIDFonts, displayFontX, fileName, line); - } else if (!cmd->cmp("displayNamedCIDFontX")) { + } else if (!cmd->cmp("displayNamedCIDFontT1")) { parseDisplayFont(tokens, displayNamedCIDFonts, - displayFontX, fileName, line); + displayFontT1, fileName, line); + } else if (!cmd->cmp("displayCIDFontT1")) { + parseDisplayFont(tokens, displayCIDFonts, + displayFontT1, fileName, line); } else if (!cmd->cmp("psFile")) { parsePSFile(tokens, fileName, line); } else if (!cmd->cmp("psFont")) { @@ -428,7 +446,7 @@ void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName, return; } line2 = 1; - while (fgets(buf, sizeof(buf), f)) { + while (getLine(buf, sizeof(buf), f)) { tok1 = strtok(buf, " \t\r\n"); tok2 = strtok(NULL, " \t\r\n"); if (tok1 && tok2) { @@ -794,6 +812,10 @@ GlobalParams::~GlobalParams() { delete cidToUnicodeCache; delete unicodeMapCache; delete cMapCache; + +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif } //------------------------------------------------------------------------ @@ -870,7 +892,12 @@ FILE *GlobalParams::findToUnicodeFile(GString *name) { } DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) { - return (DisplayFontParam *)displayFonts->lookup(fontName); + DisplayFontParam *dfp; + + globalParamsLock; + dfp = (DisplayFontParam *)displayFonts->lookup(fontName); + globalParamsUnlock; + return dfp; } DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName, @@ -884,6 +911,51 @@ DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName, return dfp; } +GString *GlobalParams::getPSFile() { + GString *s; + + globalParamsLock; + s = psFile ? psFile->copy() : (GString *)NULL; + globalParamsUnlock; + return s; +} + +int GlobalParams::getPSPaperWidth() { + int w; + + globalParamsLock; + w = psPaperWidth; + globalParamsUnlock; + return w; +} + +int GlobalParams::getPSPaperHeight() { + int h; + + globalParamsLock; + h = psPaperHeight; + globalParamsUnlock; + return h; +} + +GBool GlobalParams::getPSDuplex() { + GBool d; + + globalParamsLock; + d = psDuplex; + globalParamsUnlock; + return d; +} + +PSLevel GlobalParams::getPSLevel() { + PSLevel level; + + globalParamsLock; + level = psLevel; + globalParamsUnlock; + return level; +} + PSFontParam *GlobalParams::getPSFont(GString *fontName) { return (PSFontParam *)psFonts->lookup(fontName); } @@ -917,6 +989,78 @@ PSFontParam *GlobalParams::getPSFont16(GString *fontName, return p; } +GBool GlobalParams::getPSEmbedType1() { + GBool e; + + globalParamsLock; + e = psEmbedType1; + globalParamsUnlock; + return e; +} + +GBool GlobalParams::getPSEmbedTrueType() { + GBool e; + + globalParamsLock; + e = psEmbedTrueType; + globalParamsUnlock; + return e; +} + +GBool GlobalParams::getPSEmbedCIDPostScript() { + GBool e; + + globalParamsLock; + e = psEmbedCIDPostScript; + globalParamsUnlock; + return e; +} + +GBool GlobalParams::getPSEmbedCIDTrueType() { + GBool e; + + globalParamsLock; + e = psEmbedCIDTrueType; + globalParamsUnlock; + return e; +} + +GBool GlobalParams::getPSOPI() { + GBool opi; + + globalParamsLock; + opi = psOPI; + globalParamsUnlock; + return opi; +} + +GBool GlobalParams::getPSASCIIHex() { + GBool ah; + + globalParamsLock; + ah = psASCIIHex; + globalParamsUnlock; + return ah; +} + +EndOfLineKind GlobalParams::getTextEOL() { + EndOfLineKind eol; + + globalParamsLock; + eol = textEOL; + globalParamsUnlock; + return eol; +} + +GBool GlobalParams::getTextKeepTinyChars() { + GBool tiny; + + globalParamsLock; + tiny = textKeepTinyChars; + globalParamsUnlock; + return tiny; +} + GString *GlobalParams::findFontFile(GString *fontName, char *ext1, char *ext2) { GString *dir, *fileName; @@ -947,26 +1091,105 @@ GString *GlobalParams::findFontFile(GString *fontName, return NULL; } +GString *GlobalParams::getInitialZoom() { + GString *s; + + globalParamsLock; + s = initialZoom->copy(); + globalParamsUnlock; + return s; +} + +FontRastControl GlobalParams::getT1libControl() { + FontRastControl c; + + globalParamsLock; + c = t1libControl; + globalParamsUnlock; + return c; +} + +FontRastControl GlobalParams::getFreeTypeControl() { + FontRastControl c; + + globalParamsLock; + c = freetypeControl; + globalParamsUnlock; + return c; +} + +GBool GlobalParams::getMapNumericCharNames() { + GBool map; + + globalParamsLock; + map = mapNumericCharNames; + globalParamsUnlock; + return map; +} + +GBool GlobalParams::getPrintCommands() { + GBool p; + + globalParamsLock; + p = printCommands; + globalParamsUnlock; + return p; +} + +GBool GlobalParams::getErrQuiet() { + GBool q; + + globalParamsLock; + q = errQuiet; + globalParamsUnlock; + return q; +} + CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) { - return cidToUnicodeCache->getCIDToUnicode(collection); + CharCodeToUnicode *ctu; + + globalParamsLock; + ctu = cidToUnicodeCache->getCIDToUnicode(collection); + globalParamsUnlock; + return ctu; } UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) { UnicodeMap *map; + globalParamsLock; + map = getUnicodeMap2(encodingName); + globalParamsUnlock; + return map; +} + +UnicodeMap *GlobalParams::getUnicodeMap2(GString *encodingName) { + UnicodeMap *map; + if ((map = getResidentUnicodeMap(encodingName))) { map->incRefCnt(); - return map; + } else { + map = unicodeMapCache->getUnicodeMap(encodingName); } - return unicodeMapCache->getUnicodeMap(encodingName); + return map; } CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) { - return cMapCache->getCMap(collection, cMapName); + CMap *cMap; + + globalParamsLock; + cMap = cMapCache->getCMap(collection, cMapName); + globalParamsUnlock; + return cMap; } UnicodeMap *GlobalParams::getTextEncoding() { - return getUnicodeMap(textEncoding); + UnicodeMap *map; + + globalParamsLock; + map = getUnicodeMap2(textEncoding); + globalParamsUnlock; + return map; } //------------------------------------------------------------------------ @@ -976,20 +1199,25 @@ UnicodeMap *GlobalParams::getTextEncoding() { void GlobalParams::addDisplayFont(DisplayFontParam *param) { DisplayFontParam *old; + globalParamsLock; if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) { delete old; } displayFonts->add(param->name, param); + globalParamsUnlock; } void GlobalParams::setPSFile(char *file) { + globalParamsLock; if (psFile) { delete psFile; } psFile = new GString(file); + globalParamsUnlock; } GBool GlobalParams::setPSPaperSize(char *size) { + globalParamsLock; if (!strcmp(size, "letter")) { psPaperWidth = 612; psPaperHeight = 792; @@ -1003,57 +1231,82 @@ GBool GlobalParams::setPSPaperSize(char *size) { psPaperWidth = 842; psPaperHeight = 1190; } else { + globalParamsUnlock; return gFalse; } + globalParamsUnlock; return gTrue; } void GlobalParams::setPSPaperWidth(int width) { + globalParamsLock; psPaperWidth = width; + globalParamsUnlock; } void GlobalParams::setPSPaperHeight(int height) { + globalParamsLock; psPaperHeight = height; + globalParamsUnlock; } void GlobalParams::setPSDuplex(GBool duplex) { + globalParamsLock; psDuplex = duplex; + globalParamsUnlock; } void GlobalParams::setPSLevel(PSLevel level) { + globalParamsLock; psLevel = level; + globalParamsUnlock; } void GlobalParams::setPSEmbedType1(GBool embed) { + globalParamsLock; psEmbedType1 = embed; + globalParamsUnlock; } void GlobalParams::setPSEmbedTrueType(GBool embed) { + globalParamsLock; psEmbedTrueType = embed; + globalParamsUnlock; } void GlobalParams::setPSEmbedCIDPostScript(GBool embed) { + globalParamsLock; psEmbedCIDPostScript = embed; + globalParamsUnlock; } void GlobalParams::setPSEmbedCIDTrueType(GBool embed) { + globalParamsLock; psEmbedCIDTrueType = embed; + globalParamsUnlock; } void GlobalParams::setPSOPI(GBool opi) { + globalParamsLock; psOPI = opi; + globalParamsUnlock; } void GlobalParams::setPSASCIIHex(GBool hex) { + globalParamsLock; psASCIIHex = hex; + globalParamsUnlock; } void GlobalParams::setTextEncoding(char *encodingName) { + globalParamsLock; delete textEncoding; textEncoding = new GString(encodingName); + globalParamsUnlock; } GBool GlobalParams::setTextEOL(char *s) { + globalParamsLock; if (!strcmp(s, "unix")) { textEOL = eolUnix; } else if (!strcmp(s, "dos")) { @@ -1061,26 +1314,42 @@ GBool GlobalParams::setTextEOL(char *s) { } else if (!strcmp(s, "mac")) { textEOL = eolMac; } else { + globalParamsUnlock; return gFalse; } + globalParamsUnlock; return gTrue; } void GlobalParams::setTextKeepTinyChars(GBool keep) { + globalParamsLock; textKeepTinyChars = keep; + globalParamsUnlock; } void GlobalParams::setInitialZoom(char *s) { + globalParamsLock; delete initialZoom; initialZoom = new GString(s); + globalParamsUnlock; } GBool GlobalParams::setT1libControl(char *s) { - return setFontRastControl(&t1libControl, s); + GBool ok; + + globalParamsLock; + ok = setFontRastControl(&t1libControl, s); + globalParamsUnlock; + return ok; } GBool GlobalParams::setFreeTypeControl(char *s) { - return setFontRastControl(&freetypeControl, s); + GBool ok; + + globalParamsLock; + ok = setFontRastControl(&freetypeControl, s); + globalParamsUnlock; + return ok; } GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) { @@ -1099,13 +1368,19 @@ GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) { } void GlobalParams::setMapNumericCharNames(GBool map) { + globalParamsLock; mapNumericCharNames = map; + globalParamsUnlock; } void GlobalParams::setPrintCommands(GBool printCommandsA) { + globalParamsLock; printCommands = printCommandsA; + globalParamsUnlock; } void GlobalParams::setErrQuiet(GBool errQuietA) { + globalParamsLock; errQuiet = errQuietA; + globalParamsUnlock; } -- cgit v0.9.1