diff options
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc | 243 |
1 files changed, 25 insertions, 218 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc index fcacd7f1e71..e7cc594b12d 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc @@ -8,6 +8,10 @@ #include <aconf.h> +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + #include <string.h> #include <stdio.h> #include <stdarg.h> @@ -40,12 +44,10 @@ #include "GlobalParams.h" #ifdef _WIN32 -#ifndef __GNUC__ # undef strcasecmp # undef strncasecmp # define strcasecmp _stricmp # define strncasecmp _strnicmp -#endif #else # include <strings.h> #endif @@ -103,14 +105,14 @@ static struct { {NULL} }; -static const char *displayFontDirs[] = { -#ifdef BASE14_FONT_DIR - BASE14_FONT_DIR, -#endif #ifdef _WIN32 +static const char *displayFontDirs[] = { "c:/windows/fonts", "c:/winnt/fonts", -#else // _WIN32 + NULL +}; +#else +static const char *displayFontDirs[] = { "/usr/share/ghostscript/fonts", "/usr/local/share/ghostscript/fonts", "/usr/share/fonts/default/Type1", @@ -119,9 +121,9 @@ static const char *displayFontDirs[] = { #if defined(__sun) && defined(__SVR4) "/usr/sfw/share/ghostscript/fonts", #endif -#endif // _WIN32 NULL }; +#endif #ifdef __APPLE__ static const char *macSystemFontPath = "/System/Library/Fonts"; @@ -181,7 +183,7 @@ public: ~SysFontInfo(); GString *mungeName1(GString *in); GString *mungeName2(GString *in); - void mungeName3(GString *nameA, GBool *bold, GBool *italic); + void mungeName3(GString *name, GBool *bold, GBool *italic); int match(GString *nameA); }; @@ -258,24 +260,24 @@ GString *SysFontInfo::mungeName2(GString *in) { // Remove trailing bold/italic/regular/roman tags from the name. // (Note: the names have already been uppercased by mungeName1/2.) -void SysFontInfo::mungeName3(GString *nameA, GBool *bold, GBool *italic) { +void SysFontInfo::mungeName3(GString *name, GBool *bold, GBool *italic) { *bold = gFalse; *italic = gFalse; - int n = nameA->getLength(); + int n = name->getLength(); while (1) { - if (n >= 4 && !strcmp(nameA->getCString() + n - 4, "BOLD")) { - nameA->del(n - 4, 4); + if (n >= 4 && !strcmp(name->getCString() + n - 4, "BOLD")) { + name->del(n - 4, 4); n -= 4; *bold = gTrue; - } else if (n >= 6 && !strcmp(nameA->getCString() + n - 6, "ITALIC")) { - nameA->del(n - 6, 6); + } else if (n >= 6 && !strcmp(name->getCString() + n - 6, "ITALIC")) { + name->del(n - 6, 6); n -= 6; *italic = gTrue; - } else if (n >= 7 && !strcmp(nameA->getCString() + n - 7, "REGULAR")) { - nameA->del(n - 7, 7); + } else if (n >= 7 && !strcmp(name->getCString() + n - 7, "REGULAR")) { + name->del(n - 7, 7); n -= 7; - } else if (n >= 5 && !strcmp(nameA->getCString() + n - 5, "ROMAN")) { - nameA->del(n - 5, 5); + } else if (n >= 5 && !strcmp(name->getCString() + n - 5, "ROMAN")) { + name->del(n - 5, 5); n -= 5; } else { break; @@ -657,7 +659,7 @@ GlobalParams::GlobalParams(const char *cfgFileName) { base14SysFonts = new GHash(gTrue); sysFonts = new SysFontList(); #if HAVE_PAPER_H - const char *paperName; + char *paperName; const struct paper *paperType; paperinit(); if ((paperName = systempapername())) { @@ -713,21 +715,6 @@ GlobalParams::GlobalParams(const char *cfgFileName) { textKeepTinyChars = gTrue; initialZoom = new GString("125"); defaultFitZoom = 0; - zoomScaleFactor = 1; - zoomValues = new GList(); - zoomValues->append(new GString("25")); - zoomValues->append(new GString("50")); - zoomValues->append(new GString("75")); - zoomValues->append(new GString("100")); - zoomValues->append(new GString("110")); - zoomValues->append(new GString("125")); - zoomValues->append(new GString("150")); - zoomValues->append(new GString("175")); - zoomValues->append(new GString("200")); - zoomValues->append(new GString("300")); - zoomValues->append(new GString("400")); - zoomValues->append(new GString("600")); - zoomValues->append(new GString("800")); initialDisplayMode = new GString("continuous"); initialToolbarState = gTrue; initialSidebarState = gTrue; @@ -761,7 +748,6 @@ GlobalParams::GlobalParams(const char *cfgFileName) { fullScreenMatteColor = new GString("#000000"); selectionColor = new GString("#8080ff"); reverseVideoInvertImages = gFalse; - allowLinksToChangeZoom = gTrue; launchCommand = NULL; movieCommand = NULL; defaultPrinter = NULL; @@ -769,15 +755,10 @@ GlobalParams::GlobalParams(const char *cfgFileName) { mapUnknownCharNames = gFalse; mapExtTrueTypeFontsViaUnicode = gTrue; useTrueTypeUnicodeMapping = gFalse; - ignoreWrongSizeToUnicode = gFalse; droppedFonts = new GHash(gTrue); - separateRotatedText = gFalse; createDefaultKeyBindings(); popupMenuCmds = new GList(); -#ifndef PDF_PARSER_ONLY - initStateFilePaths(); -#endif - saveSessionOnQuit = gTrue; + tabStateFile = appendToPath(getHomeDir(), ".xpdf.tab-state"); savePageNumbers = gTrue; printCommands = gFalse; printStatusInfo = gFalse; @@ -1036,27 +1017,6 @@ void GlobalParams::createDefaultKeyBindings() { xpdfKeyContextAny, "zoomFitWidth")); } -#ifndef PDF_PARSER_ONLY -void GlobalParams::initStateFilePaths() { -#ifdef _WIN32 - char path[MAX_PATH]; - if (SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, - SHGFP_TYPE_CURRENT, path) != S_OK) { - return; - } - GString *dir = appendToPath(new GString(path), "xpdf"); - CreateDirectoryA(dir->getCString(), NULL); - pagesFile = appendToPath(dir->copy(), "xpdf.pages"); - tabStateFile = appendToPath(dir->copy(), "xpdf.tab-state"); - sessionFile = appendToPath(dir, "xpdf.session"); -#else - pagesFile = appendToPath(getHomeDir(), ".xpdf.pages"); - tabStateFile = appendToPath(getHomeDir(), ".xpdf.tab-state"); - sessionFile = appendToPath(getHomeDir(), ".xpdf.session"); -#endif -} -#endif - void GlobalParams::parseFile(GString *fileName, FILE *f) { int line; char buf[512]; @@ -1197,10 +1157,6 @@ void GlobalParams::parseLine(char *buf, GString *fileName, int line) { parseString("initialZoom", &initialZoom, tokens, fileName, line); } else if (!cmd->cmp("defaultFitZoom")) { parseInteger("defaultFitZoom", &defaultFitZoom, tokens, fileName, line); - } else if (!cmd->cmp("zoomScaleFactor")) { - parseZoomScaleFactor(tokens, fileName, line); - } else if (!cmd->cmp("zoomValues")) { - parseZoomValues(tokens, fileName, line); } else if (!cmd->cmp("initialDisplayMode")) { parseString("initialDisplayMode", &initialDisplayMode, tokens, fileName, line); @@ -1288,9 +1244,6 @@ void GlobalParams::parseLine(char *buf, GString *fileName, int line) { } else if (!cmd->cmp("reverseVideoInvertImages")) { parseYesNo("reverseVideoInvertImages", &reverseVideoInvertImages, tokens, fileName, line); - } else if (!cmd->cmp("allowLinksToChangeZoom")) { - parseYesNo("allowLinksToChangeZoom", &allowLinksToChangeZoom, - tokens, fileName, line); } else if (!cmd->cmp("launchCommand")) { parseString("launchCommand", &launchCommand, tokens, fileName, line); } else if (!cmd->cmp("movieCommand")) { @@ -1308,16 +1261,11 @@ void GlobalParams::parseLine(char *buf, GString *fileName, int line) { &mapExtTrueTypeFontsViaUnicode, tokens, fileName, line); } else if (!cmd->cmp("useTrueTypeUnicodeMapping")) { - parseYesNo("useTrueTypeUnicodeMapping", &useTrueTypeUnicodeMapping, - tokens, fileName, line); - } else if (!cmd->cmp("ignoreWrongSizeToUnicode")) { - parseYesNo("ignoreWrongSizeToUnicode", &ignoreWrongSizeToUnicode, + parseYesNo("useTrueTypeUnicodeMapping", + &useTrueTypeUnicodeMapping, tokens, fileName, line); } else if (!cmd->cmp("dropFont")) { parseDropFont(tokens, fileName, line); - } else if (!cmd->cmp("separateRotatedText")) { - parseYesNo("separateRotatedText", &separateRotatedText, - tokens, fileName, line); } else if (!cmd->cmp("bind")) { parseBind(tokens, fileName, line); } else if (!cmd->cmp("unbind")) { @@ -1326,11 +1274,6 @@ void GlobalParams::parseLine(char *buf, GString *fileName, int line) { parsePopupMenuCmd(tokens, fileName, line); } else if (!cmd->cmp("tabStateFile")) { parseString("tabStateFile", &tabStateFile, tokens, fileName, line); - } else if (!cmd->cmp("sessionFile")) { - parseString("sessionFile", &sessionFile, tokens, fileName, line); - } else if (!cmd->cmp("saveSessionOnQuit")) { - parseYesNo("saveSessionOnQuit", &saveSessionOnQuit, - tokens, fileName, line); } else if (!cmd->cmp("savePageNumbers")) { parseYesNo("savePageNumbers", &savePageNumbers, tokens, fileName, line); } else if (!cmd->cmp("printCommands")) { @@ -2030,59 +1973,6 @@ void GlobalParams::parsePopupMenuCmd(GList *tokens, cmds)); } -void GlobalParams::parseZoomScaleFactor(GList *tokens, - GString *fileName, int line) { - if (tokens->getLength() != 2) { - error(errConfig, -1, "Bad 'zoomScaleFactor' config file command ({0:t}:{1:d})", - fileName, line); - return; - } - GString *tok = (GString *)tokens->get(1); - if (tok->getLength() == 0) { - error(errConfig, -1, "Bad 'zoomScaleFactor' config file command ({0:t}:{1:d})", - fileName, line); - return; - } - if (tok->cmp("actual") == 0) { - zoomScaleFactor = -1; - } else { - for (int i = 0; i < tok->getLength(); ++i) { - if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') || - tok->getChar(i) == '.')) { - error(errConfig, -1, "Bad 'zoomScaleFactor' config file command ({0:t}:{1:d})", - fileName, line); - return; - } - } - zoomScaleFactor = atof(tok->getCString()); - } -} - -void GlobalParams::parseZoomValues(GList *tokens, - GString *fileName, int line) { - if (tokens->getLength() < 2) { - error(errConfig, -1, "Bad 'zoomValues' config file command ({0:t}:{1:d})", - fileName, line); - return; - } - for (int i = 1; i < tokens->getLength(); ++i) { - GString *tok = (GString *)tokens->get(i); - for (int j = 0; j < tok->getLength(); ++j) { - if (tok->getChar(j) < '0' || tok->getChar(j) > '9') { - error(errConfig, -1, "Bad 'zoomValues' config file command ({0:t}:{1:d})", - fileName, line); - return; - } - } - } - deleteGList(zoomValues, GString); - zoomValues = new GList(); - for (int i = 1; i < tokens->getLength(); ++i) { - GString *tok = (GString *)tokens->get(i); - zoomValues->append(tok->copy()); - } -} - void GlobalParams::parseYesNo(const char *cmdName, GBool *flag, GList *tokens, GString *fileName, int line) { GString *tok; @@ -2214,7 +2104,6 @@ GlobalParams::~GlobalParams() { deleteGList(psResidentFontsCC, PSFontParam16); delete textEncoding; delete initialZoom; - deleteGList(zoomValues, GString); delete initialDisplayMode; delete initialSelectMode; if (paperColor) { @@ -2241,9 +2130,7 @@ GlobalParams::~GlobalParams() { delete droppedFonts; deleteGList(keyBindings, KeyBinding); deleteGList(popupMenuCmds, PopupMenuCmd); - delete pagesFile; delete tabStateFile; - delete sessionFile; delete debugLogFile; cMapDirs->startIter(&iter); @@ -3072,19 +2959,6 @@ int GlobalParams::getDefaultFitZoom() { return z; } -double GlobalParams::getZoomScaleFactor() { - double z; - - lockGlobalParams; - z = zoomScaleFactor; - unlockGlobalParams; - return z; -} - -GList *GlobalParams::getZoomValues() { - return zoomValues; -} - GString *GlobalParams::getInitialDisplayMode() { GString *s; @@ -3376,15 +3250,6 @@ GBool GlobalParams::getReverseVideoInvertImages() { return invert; } -GBool GlobalParams::getAllowLinksToChangeZoom() { - GBool allow; - - lockGlobalParams; - allow = allowLinksToChangeZoom; - unlockGlobalParams; - return allow; -} - GString *GlobalParams::getDefaultPrinter() { GString *s; @@ -3430,15 +3295,6 @@ GBool GlobalParams::getUseTrueTypeUnicodeMapping() { return use; } -GBool GlobalParams::getIgnoreWrongSizeToUnicode() { - GBool ignore; - - lockGlobalParams; - ignore = ignoreWrongSizeToUnicode; - unlockGlobalParams; - return ignore; -} - GBool GlobalParams::isDroppedFont(const char *fontName) { GBool isDropped; @@ -3448,15 +3304,6 @@ GBool GlobalParams::isDroppedFont(const char *fontName) { return isDropped; } -GBool GlobalParams::getSeparateRotatedText() { - GBool sep; - - lockGlobalParams; - sep = separateRotatedText; - unlockGlobalParams; - return sep; -} - GList *GlobalParams::getKeyBinding(int code, int mods, int context) { KeyBinding *binding; GList *cmds; @@ -3509,15 +3356,6 @@ PopupMenuCmd *GlobalParams::getPopupMenuCmd(int idx) { return cmd; } -GString *GlobalParams::getPagesFile() { - GString *s; - - lockGlobalParams; - s = pagesFile->copy(); - unlockGlobalParams; - return s; -} - GString *GlobalParams::getTabStateFile() { GString *s; @@ -3527,15 +3365,6 @@ GString *GlobalParams::getTabStateFile() { return s; } -GString *GlobalParams::getSessionFile() { - GString *s; - - lockGlobalParams; - s = sessionFile->copy(); - unlockGlobalParams; - return s; -} - GBool GlobalParams::getSavePageNumbers() { GBool s; @@ -3545,15 +3374,6 @@ GBool GlobalParams::getSavePageNumbers() { return s; } -GBool GlobalParams::getSaveSessionOnQuit() { - GBool s; - - lockGlobalParams; - s = saveSessionOnQuit; - unlockGlobalParams; - return s; -} - GBool GlobalParams::getPrintCommands() { GBool p; @@ -3892,12 +3712,6 @@ void GlobalParams::setInitialZoom(char *s) { unlockGlobalParams; } -void GlobalParams::setDefaultFitZoom(int z) { - lockGlobalParams; - defaultFitZoom = z; - unlockGlobalParams; -} - GBool GlobalParams::setEnableFreeType(char *s) { GBool ok; @@ -4001,13 +3815,6 @@ void GlobalParams::setTabStateFile(char *tabStateFileA) { unlockGlobalParams; } -void GlobalParams::setSessionFile(char *sessionFileA) { - lockGlobalParams; - delete sessionFile; - sessionFile = new GString(sessionFileA); - unlockGlobalParams; -} - void GlobalParams::setPrintCommands(GBool printCommandsA) { lockGlobalParams; printCommands = printCommandsA; |