1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
10 #include <aros/debug.h>
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
35 #include "NameToCharCode.h"
36 #include "CharCodeToUnicode.h"
37 #include "UnicodeMap.h"
39 #include "BuiltinFontTables.h"
40 #include "FontEncodingTables.h"
42 # include "XpdfPluginAPI.h"
44 #include "GlobalParams.h"
47 # define strcasecmp stricmp
51 # define lockGlobalParams gLockMutex(&mutex)
52 # define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex)
53 # define lockCMapCache gLockMutex(&cMapCacheMutex)
54 # define unlockGlobalParams gUnlockMutex(&mutex)
55 # define unlockUnicodeMapCache gUnlockMutex(&unicodeMapCacheMutex)
56 # define unlockCMapCache gUnlockMutex(&cMapCacheMutex)
58 # define lockGlobalParams
59 # define lockUnicodeMapCache
60 # define lockCMapCache
61 # define unlockGlobalParams
62 # define unlockUnicodeMapCache
63 # define unlockCMapCache
66 #include "NameToUnicodeTable.h"
67 #include "UnicodeMapTables.h"
72 extern XpdfPluginVecTable xpdfPluginVecTable
;
76 //------------------------------------------------------------------------
78 #define cidToUnicodeCacheSize 4
79 #define unicodeToUnicodeCacheSize 4
81 //------------------------------------------------------------------------
85 const char *t1FileName
;
86 const char *ttFileName
;
87 } displayFontTab
[] = {
88 {"Courier", "n022003l.pfb", "cour.ttf"},
89 {"Courier-Bold", "n022004l.pfb", "courbd.ttf"},
90 {"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"},
91 {"Courier-Oblique", "n022023l.pfb", "couri.ttf"},
92 {"Helvetica", "n019003l.pfb", "arial.ttf"},
93 {"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"},
94 {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
95 {"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"},
96 {"Symbol", "s050000l.pfb", NULL
},
97 {"Times-Bold", "n021004l.pfb", "timesbd.ttf"},
98 {"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"},
99 {"Times-Italic", "n021023l.pfb", "timesi.ttf"},
100 {"Times-Roman", "n021003l.pfb", "times.ttf"},
101 {"ZapfDingbats", "d050000l.pfb", NULL
},
106 static char *displayFontDirs
[] = {
112 static char *displayFontDirs
[] = {
117 "/usr/local/share/ghostscript/fonts",
118 "/usr/share/fonts/default/Type1",
119 "/usr/share/fonts/default/ghostscript",
120 "/usr/share/fonts/type1/gsfonts",
126 //------------------------------------------------------------------------
128 GlobalParams
*globalParams
= NULL
;
130 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
134 DisplayFontParam::DisplayFontParam(GString
*nameA
,
135 DisplayFontParamKind kindA
) {
148 DisplayFontParam::~DisplayFontParam() {
166 //------------------------------------------------------------------------
168 //------------------------------------------------------------------------
170 class WinFontInfo
: public DisplayFontParam
{
175 static WinFontInfo
*make(GString
*nameA
, GBool boldA
, GBool italicA
,
176 HKEY regKey
, char *winFontDir
);
177 WinFontInfo(GString
*nameA
, GBool boldA
, GBool italicA
,
179 virtual ~WinFontInfo();
180 GBool
equals(WinFontInfo
*fi
);
183 WinFontInfo
*WinFontInfo::make(GString
*nameA
, GBool boldA
, GBool italicA
,
184 HKEY regKey
, char *winFontDir
) {
192 //----- find the font file
194 regName
= nameA
->copy();
196 regName
->append(" Bold");
199 regName
->append(" Italic");
201 regName
->append(" (TrueType)");
203 if (RegQueryValueEx(regKey
, regName
->getCString(), NULL
, NULL
,
204 (LPBYTE
)buf
, &n
) == ERROR_SUCCESS
) {
205 fileNameA
= new GString(winFontDir
);
206 fileNameA
->append('\\')->append(buf
);
214 //----- normalize the font name
216 while (i
< nameA
->getLength()) {
217 c
= nameA
->getChar(i
);
218 if (c
== ' ' || c
== ',' || c
== '-') {
225 return new WinFontInfo(nameA
, boldA
, italicA
, fileNameA
);
228 WinFontInfo::WinFontInfo(GString
*nameA
, GBool boldA
, GBool italicA
,
230 DisplayFontParam(nameA
, displayFontTT
)
234 tt
.fileName
= fileNameA
;
237 WinFontInfo::~WinFontInfo() {
240 GBool
WinFontInfo::equals(WinFontInfo
*fi
) {
241 return !name
->cmp(fi
->name
) && bold
== fi
->bold
&& italic
== fi
->italic
;
244 //------------------------------------------------------------------------
246 //------------------------------------------------------------------------
251 WinFontList(char *winFontDirA
);
253 WinFontInfo
*find(GString
*font
);
257 void add(WinFontInfo
*fi
);
258 static int CALLBACK
enumFunc1(CONST LOGFONT
*font
,
259 CONST TEXTMETRIC
*metrics
,
260 DWORD type
, LPARAM data
);
261 static int CALLBACK
enumFunc2(CONST LOGFONT
*font
,
262 CONST TEXTMETRIC
*metrics
,
263 DWORD type
, LPARAM data
);
265 GList
*fonts
; // [WinFontInfo]
266 HDC dc
; // (only used during enumeration)
267 HKEY regKey
; // (only used during enumeration)
268 char *winFontDir
; // (only used during enumeration)
271 WinFontList::WinFontList(char *winFontDirA
) {
272 OSVERSIONINFO version
;
277 winFontDir
= winFontDirA
;
278 version
.dwOSVersionInfoSize
= sizeof(version
);
279 GetVersionEx(&version
);
280 if (version
.dwPlatformId
== VER_PLATFORM_WIN32_NT
) {
281 path
= "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\";
283 path
= "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts\\";
285 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
, path
, 0,
286 KEY_QUERY_VALUE
| KEY_ENUMERATE_SUB_KEYS
,
287 ®Key
) == ERROR_SUCCESS
) {
288 EnumFonts(dc
, NULL
, &WinFontList::enumFunc1
, (LPARAM
)this);
294 WinFontList::~WinFontList() {
295 deleteGList(fonts
, WinFontInfo
);
298 void WinFontList::add(WinFontInfo
*fi
) {
301 for (i
= 0; i
< fonts
->getLength(); ++i
) {
302 if (((WinFontInfo
*)fonts
->get(i
))->equals(fi
)) {
310 WinFontInfo
*WinFontList::find(GString
*font
) {
319 // remove space, comma, dash chars
321 while (i
< name
->getLength()) {
322 c
= name
->getChar(i
);
323 if (c
== ' ' || c
== ',' || c
== '-') {
329 n
= name
->getLength();
331 // remove trailing "MT" (Foo-MT, Foo-BoldMT, etc.)
332 if (!strcmp(name
->getCString() + n
- 2, "MT")) {
338 if (!strcmp(name
->getCString() + n
- 6, "Italic")) {
347 if (!strcmp(name
->getCString() + n
- 4, "Bold")) {
355 // remove trailing "MT" (FooMT-Bold, etc.)
356 if (!strcmp(name
->getCString() + n
- 2, "MT")) {
361 // remove trailing "PS"
362 if (!strcmp(name
->getCString() + n
- 2, "PS")) {
367 // search for the font
369 for (i
= 0; i
< fonts
->getLength(); ++i
) {
370 fi
= (WinFontInfo
*)fonts
->get(i
);
371 if (!fi
->name
->cmp(name
) && fi
->bold
== bold
&& fi
->italic
== italic
) {
381 int CALLBACK
WinFontList::enumFunc1(CONST LOGFONT
*font
,
382 CONST TEXTMETRIC
*metrics
,
383 DWORD type
, LPARAM data
) {
384 WinFontList
*fl
= (WinFontList
*)data
;
386 EnumFonts(fl
->dc
, font
->lfFaceName
, &WinFontList::enumFunc2
, (LPARAM
)fl
);
390 int CALLBACK
WinFontList::enumFunc2(CONST LOGFONT
*font
,
391 CONST TEXTMETRIC
*metrics
,
392 DWORD type
, LPARAM data
) {
393 WinFontList
*fl
= (WinFontList
*)data
;
396 if (type
& TRUETYPE_FONTTYPE
) {
397 if ((fi
= WinFontInfo::make(new GString(font
->lfFaceName
),
398 font
->lfWeight
>= 600,
399 font
->lfItalic
? gTrue
: gFalse
,
400 fl
->regKey
, fl
->winFontDir
))) {
409 //------------------------------------------------------------------------
411 //------------------------------------------------------------------------
413 PSFontParam::PSFontParam(GString
*pdfFontNameA
, int wModeA
,
414 GString
*psFontNameA
, GString
*encodingA
) {
415 pdfFontName
= pdfFontNameA
;
417 psFontName
= psFontNameA
;
418 encoding
= encodingA
;
421 PSFontParam::~PSFontParam() {
429 //------------------------------------------------------------------------
431 //------------------------------------------------------------------------
433 KeyBinding::KeyBinding(int codeA
, int modsA
, int contextA
, const char *cmd0
) {
438 cmds
->append(new GString(cmd0
));
441 KeyBinding::KeyBinding(int codeA
, int modsA
, int contextA
,
442 const char *cmd0
, const char *cmd1
) {
447 cmds
->append(new GString(cmd0
));
448 cmds
->append(new GString(cmd1
));
451 KeyBinding::KeyBinding(int codeA
, int modsA
, int contextA
, GList
*cmdsA
) {
458 KeyBinding::~KeyBinding() {
459 deleteGList(cmds
, GString
);
462 #ifdef ENABLE_PLUGINS
463 //------------------------------------------------------------------------
465 //------------------------------------------------------------------------
470 static Plugin
*load(char *type
, char *name
);
476 Plugin(HMODULE libA
);
484 Plugin
*Plugin::load(char *type
, char *name
) {
487 XpdfPluginVecTable
*vt
;
488 XpdfBool (*xpdfInitPlugin
)(void);
495 path
= globalParams
->getBaseDir();
496 appendToPath(path
, "plugins");
497 appendToPath(path
, type
);
498 appendToPath(path
, name
);
501 path
->append(".dll");
502 if (!(libA
= LoadLibrary(path
->getCString()))) {
503 error(-1, (char*)"Failed to load plugin '%s'",
507 if (!(vt
= (XpdfPluginVecTable
*)
508 GetProcAddress(libA
, "xpdfPluginVecTable"))) {
509 error(-1, (char*)"Failed to find xpdfPluginVecTable in plugin '%s'",
514 //~ need to deal with other extensions here
516 if (!(dlA
= dlopen(path
->getCString(), RTLD_NOW
))) {
517 error(-1, (char*)"Failed to load plugin '%s': %s",
518 path
->getCString(), dlerror());
521 if (!(vt
= (XpdfPluginVecTable
*)dlsym(dlA
, "xpdfPluginVecTable"))) {
522 error(-1, (char*)"Failed to find xpdfPluginVecTable in plugin '%s'",
528 if (vt
->version
!= xpdfPluginVecTable
.version
) {
529 error(-1, (char*)"Plugin '%s' is wrong version", path
->getCString());
532 memcpy(vt
, &xpdfPluginVecTable
, sizeof(xpdfPluginVecTable
));
535 if (!(xpdfInitPlugin
= (XpdfBool (*)(void))
536 GetProcAddress(libA
, "xpdfInitPlugin"))) {
537 error(-1, (char*)"Failed to find xpdfInitPlugin in plugin '%s'",
542 if (!(xpdfInitPlugin
= (XpdfBool (*)(void))dlsym(dlA
, "xpdfInitPlugin"))) {
543 error(-1, (char*)"Failed to find xpdfInitPlugin in plugin '%s'",
549 if (!(*xpdfInitPlugin
)()) {
550 error(-1, (char*)"Initialization of plugin '%s' failed",
556 plugin
= new Plugin(libA
);
558 plugin
= new Plugin(dlA
);
576 Plugin::Plugin(HMODULE libA
) {
580 Plugin::Plugin(void *dlA
) {
586 void (*xpdfFreePlugin
)(void);
589 if ((xpdfFreePlugin
= (void (*)(void))
590 GetProcAddress(lib
, "xpdfFreePlugin"))) {
595 if ((xpdfFreePlugin
= (void (*)(void))dlsym(dl
, "xpdfFreePlugin"))) {
602 #endif // ENABLE_PLUGINS
604 //------------------------------------------------------------------------
606 //------------------------------------------------------------------------
608 GlobalParams::GlobalParams(char *cfgFileName
) {
616 gInitMutex(&unicodeMapCacheMutex
);
617 gInitMutex(&cMapCacheMutex
);
620 initBuiltinFontTables();
622 // scan the encoding in reverse because we want the lowest-numbered
623 // index for each char name ('space' is encoded twice)
624 macRomanReverseMap
= new NameToCharCode();
625 for (i
= 255; i
>= 0; --i
) {
626 if (macRomanEncoding
[i
]) {
627 macRomanReverseMap
->add((char *)macRomanEncoding
[i
], (CharCode
)i
);
632 // baseDir will be set by a call to setBaseDir
633 baseDir
= new GString();
635 baseDir
= appendToPath(getHomeDir(), ".xpdf");
637 nameToUnicode
= new NameToCharCode();
638 cidToUnicodes
= new GHash(gTrue
);
639 unicodeToUnicodes
= new GHash(gTrue
);
640 residentUnicodeMaps
= new GHash();
641 unicodeMaps
= new GHash(gTrue
);
642 cMapDirs
= new GHash(gTrue
);
643 toUnicodeDirs
= new GList();
644 displayFonts
= new GHash();
645 displayCIDFonts
= new GHash();
646 displayNamedCIDFonts
= new GHash();
649 const struct paper
*paperType
;
651 if ((paperName
= systempapername())) {
652 paperType
= paperinfo(paperName
);
653 psPaperWidth
= (int)paperpswidth(paperType
);
654 psPaperHeight
= (int)paperpsheight(paperType
);
656 error(-1, (char*)"No paper information available - using defaults");
657 psPaperWidth
= defPaperWidth
;
658 psPaperHeight
= defPaperHeight
;
662 psPaperWidth
= defPaperWidth
;
663 psPaperHeight
= defPaperHeight
;
665 psImageableLLX
= psImageableLLY
= 0;
666 psImageableURX
= psPaperWidth
;
667 psImageableURY
= psPaperHeight
;
669 psExpandSmaller
= gFalse
;
670 psShrinkLarger
= gTrue
;
675 psFonts
= new GHash();
676 psNamedFonts16
= new GList();
677 psFonts16
= new GList();
678 psEmbedType1
= gTrue
;
679 psEmbedTrueType
= gTrue
;
680 psEmbedCIDPostScript
= gTrue
;
681 psEmbedCIDTrueType
= gTrue
;
685 textEncoding
= new GString("Latin1");
693 textPageBreaks
= gTrue
;
694 textKeepTinyChars
= gFalse
;
695 fontDirs
= new GList();
696 initialZoom
= new GString("125");
697 continuousView
= gFalse
;
699 enableFreeType
= gTrue
;
701 vectorAntialias
= gTrue
;
702 strokeAdjust
= gTrue
;
703 screenType
= screenUnset
;
705 screenDotRadius
= -1;
707 screenBlackThreshold
= 0.0;
708 screenWhiteThreshold
= 1.0;
711 mapNumericCharNames
= gTrue
;
712 mapUnknownCharNames
= gFalse
;
713 createDefaultKeyBindings();
714 printCommands
= gFalse
;
717 cidToUnicodeCache
= new CharCodeToUnicodeCache(cidToUnicodeCacheSize
);
718 unicodeToUnicodeCache
=
719 new CharCodeToUnicodeCache(unicodeToUnicodeCacheSize
);
720 unicodeMapCache
= new UnicodeMapCache();
721 cMapCache
= new CMapCache();
727 #ifdef ENABLE_PLUGINS
728 plugins
= new GList();
729 securityHandlers
= new GList();
732 // set up the initial nameToUnicode table
733 for (i
= 0; nameToUnicodeTab
[i
].name
; ++i
) {
734 nameToUnicode
->add((char *)nameToUnicodeTab
[i
].name
, nameToUnicodeTab
[i
].u
);
737 // set up the residentUnicodeMaps table
738 map
= new UnicodeMap("Latin1", gFalse
,
739 latin1UnicodeMapRanges
, latin1UnicodeMapLen
);
740 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
741 map
= new UnicodeMap("ASCII7", gFalse
,
742 ascii7UnicodeMapRanges
, ascii7UnicodeMapLen
);
743 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
744 map
= new UnicodeMap("Symbol", gFalse
,
745 symbolUnicodeMapRanges
, symbolUnicodeMapLen
);
746 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
747 map
= new UnicodeMap("ZapfDingbats", gFalse
, zapfDingbatsUnicodeMapRanges
,
748 zapfDingbatsUnicodeMapLen
);
749 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
750 map
= new UnicodeMap("UTF-8", gTrue
, &mapUTF8
);
751 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
752 map
= new UnicodeMap("UCS-2", gTrue
, &mapUCS2
);
753 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
755 #if defined(__AROS__)
759 // look for a user config file, then a system-wide config file
763 if (cfgFileName
&& cfgFileName
[0]) {
764 fileName
= new GString(cfgFileName
);
765 if (!(f
= fopen(fileName
->getCString(), "r"))) {
770 fileName
= appendToPath(getHomeDir(), xpdfUserConfigFile
);
771 if (!(f
= fopen(fileName
->getCString(), "r"))) {
776 #if defined(WIN32) && !defined(__CYGWIN32__)
778 i
= GetModuleFileName(NULL
, buf
, sizeof(buf
));
779 if (i
<= 0 || i
>= sizeof(buf
)) {
780 // error or path too long for buffer - just use the current dir
783 fileName
= grabPath(buf
);
784 appendToPath(fileName
, xpdfSysConfigFile
);
786 fileName
= new GString(xpdfSysConfigFile
);
788 if (!(f
= fopen(fileName
->getCString(), "r"))) {
793 parseFile(fileName
, f
);
799 void GlobalParams::createDefaultKeyBindings() {
800 keyBindings
= new GList();
802 //----- mouse buttons
803 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress1
, xpdfKeyModNone
,
804 xpdfKeyContextAny
, "startSelection"));
805 keyBindings
->append(new KeyBinding(xpdfKeyCodeMouseRelease1
, xpdfKeyModNone
,
806 xpdfKeyContextAny
, "endSelection",
808 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress2
, xpdfKeyModNone
,
809 xpdfKeyContextAny
, "startPan"));
810 keyBindings
->append(new KeyBinding(xpdfKeyCodeMouseRelease2
, xpdfKeyModNone
,
811 xpdfKeyContextAny
, "endPan"));
812 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress3
, xpdfKeyModNone
,
813 xpdfKeyContextAny
, "postPopupMenu"));
814 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress4
, xpdfKeyModNone
,
816 "scrollUpPrevPage(16)"));
817 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress5
, xpdfKeyModNone
,
819 "scrollDownNextPage(16)"));
820 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress6
, xpdfKeyModNone
,
821 xpdfKeyContextAny
, "scrollLeft(16)"));
822 keyBindings
->append(new KeyBinding(xpdfKeyCodeMousePress7
, xpdfKeyModNone
,
823 xpdfKeyContextAny
, "scrollRight(16)"));
826 keyBindings
->append(new KeyBinding(xpdfKeyCodeHome
, xpdfKeyModCtrl
,
827 xpdfKeyContextAny
, "gotoPage(1)"));
828 keyBindings
->append(new KeyBinding(xpdfKeyCodeHome
, xpdfKeyModNone
,
829 xpdfKeyContextAny
, "scrollToTopLeft"));
830 keyBindings
->append(new KeyBinding(xpdfKeyCodeEnd
, xpdfKeyModCtrl
,
831 xpdfKeyContextAny
, "gotoLastPage"));
832 keyBindings
->append(new KeyBinding(xpdfKeyCodeEnd
, xpdfKeyModNone
,
834 "scrollToBottomRight"));
835 keyBindings
->append(new KeyBinding(xpdfKeyCodePgUp
, xpdfKeyModNone
,
836 xpdfKeyContextAny
, "pageUp"));
837 keyBindings
->append(new KeyBinding(xpdfKeyCodeBackspace
, xpdfKeyModNone
,
838 xpdfKeyContextAny
, "pageUp"));
839 keyBindings
->append(new KeyBinding(xpdfKeyCodeDelete
, xpdfKeyModNone
,
840 xpdfKeyContextAny
, "pageUp"));
841 keyBindings
->append(new KeyBinding(xpdfKeyCodePgDn
, xpdfKeyModNone
,
842 xpdfKeyContextAny
, "pageDown"));
843 keyBindings
->append(new KeyBinding(' ', xpdfKeyModNone
,
844 xpdfKeyContextAny
, "pageDown"));
845 keyBindings
->append(new KeyBinding(xpdfKeyCodeLeft
, xpdfKeyModNone
,
846 xpdfKeyContextAny
, "scrollLeft(16)"));
847 keyBindings
->append(new KeyBinding(xpdfKeyCodeRight
, xpdfKeyModNone
,
848 xpdfKeyContextAny
, "scrollRight(16)"));
849 keyBindings
->append(new KeyBinding(xpdfKeyCodeUp
, xpdfKeyModNone
,
850 xpdfKeyContextAny
, "scrollUp(16)"));
851 keyBindings
->append(new KeyBinding(xpdfKeyCodeDown
, xpdfKeyModNone
,
852 xpdfKeyContextAny
, "scrollDown(16)"));
853 keyBindings
->append(new KeyBinding('o', xpdfKeyModNone
,
854 xpdfKeyContextAny
, "open"));
855 keyBindings
->append(new KeyBinding('O', xpdfKeyModNone
,
856 xpdfKeyContextAny
, "open"));
857 keyBindings
->append(new KeyBinding('r', xpdfKeyModNone
,
858 xpdfKeyContextAny
, "reload"));
859 keyBindings
->append(new KeyBinding('R', xpdfKeyModNone
,
860 xpdfKeyContextAny
, "reload"));
861 keyBindings
->append(new KeyBinding('f', xpdfKeyModNone
,
862 xpdfKeyContextAny
, "find"));
863 keyBindings
->append(new KeyBinding('F', xpdfKeyModNone
,
864 xpdfKeyContextAny
, "find"));
865 keyBindings
->append(new KeyBinding('f', xpdfKeyModCtrl
,
866 xpdfKeyContextAny
, "find"));
867 keyBindings
->append(new KeyBinding('g', xpdfKeyModCtrl
,
868 xpdfKeyContextAny
, "findNext"));
869 keyBindings
->append(new KeyBinding('p', xpdfKeyModCtrl
,
870 xpdfKeyContextAny
, "print"));
871 keyBindings
->append(new KeyBinding('n', xpdfKeyModNone
,
872 xpdfKeyContextScrLockOff
, "nextPage"));
873 keyBindings
->append(new KeyBinding('N', xpdfKeyModNone
,
874 xpdfKeyContextScrLockOff
, "nextPage"));
875 keyBindings
->append(new KeyBinding('n', xpdfKeyModNone
,
876 xpdfKeyContextScrLockOn
,
877 "nextPageNoScroll"));
878 keyBindings
->append(new KeyBinding('N', xpdfKeyModNone
,
879 xpdfKeyContextScrLockOn
,
880 "nextPageNoScroll"));
881 keyBindings
->append(new KeyBinding('p', xpdfKeyModNone
,
882 xpdfKeyContextScrLockOff
, "prevPage"));
883 keyBindings
->append(new KeyBinding('P', xpdfKeyModNone
,
884 xpdfKeyContextScrLockOff
, "prevPage"));
885 keyBindings
->append(new KeyBinding('p', xpdfKeyModNone
,
886 xpdfKeyContextScrLockOn
,
887 "prevPageNoScroll"));
888 keyBindings
->append(new KeyBinding('P', xpdfKeyModNone
,
889 xpdfKeyContextScrLockOn
,
890 "prevPageNoScroll"));
891 keyBindings
->append(new KeyBinding('v', xpdfKeyModNone
,
892 xpdfKeyContextAny
, "goForward"));
893 keyBindings
->append(new KeyBinding('b', xpdfKeyModNone
,
894 xpdfKeyContextAny
, "goBackward"));
895 keyBindings
->append(new KeyBinding('g', xpdfKeyModNone
,
896 xpdfKeyContextAny
, "focusToPageNum"));
897 keyBindings
->append(new KeyBinding('0', xpdfKeyModNone
,
898 xpdfKeyContextAny
, "zoomPercent(125)"));
899 keyBindings
->append(new KeyBinding('+', xpdfKeyModNone
,
900 xpdfKeyContextAny
, "zoomIn"));
901 keyBindings
->append(new KeyBinding('-', xpdfKeyModNone
,
902 xpdfKeyContextAny
, "zoomOut"));
903 keyBindings
->append(new KeyBinding('z', xpdfKeyModNone
,
904 xpdfKeyContextAny
, "zoomFitPage"));
905 keyBindings
->append(new KeyBinding('w', xpdfKeyModNone
,
906 xpdfKeyContextAny
, "zoomFitWidth"));
907 keyBindings
->append(new KeyBinding('f', xpdfKeyModAlt
,
909 "toggleFullScreenMode"));
910 keyBindings
->append(new KeyBinding('l', xpdfKeyModCtrl
,
911 xpdfKeyContextAny
, "redraw"));
912 keyBindings
->append(new KeyBinding('w', xpdfKeyModCtrl
,
913 xpdfKeyContextAny
, "closeWindow"));
914 keyBindings
->append(new KeyBinding('?', xpdfKeyModNone
,
915 xpdfKeyContextAny
, "about"));
916 keyBindings
->append(new KeyBinding('q', xpdfKeyModNone
,
917 xpdfKeyContextAny
, "quit"));
918 keyBindings
->append(new KeyBinding('Q', xpdfKeyModNone
,
919 xpdfKeyContextAny
, "quit"));
922 void GlobalParams::parseFile(GString
*fileName
, FILE *f
) {
927 while (getLine(buf
, sizeof(buf
) - 1, f
)) {
928 parseLine(buf
, fileName
, line
);
933 void GlobalParams::parseLine(char *buf
, GString
*fileName
, int line
) {
935 GString
*cmd
, *incFile
;
939 // break the line into tokens
940 tokens
= new GList();
943 for (; *p1
&& isspace(*p1
); ++p1
) ;
947 if (*p1
== '"' || *p1
== '\'') {
948 for (p2
= p1
+ 1; *p2
&& *p2
!= *p1
; ++p2
) ;
951 for (p2
= p1
+ 1; *p2
&& !isspace(*p2
); ++p2
) ;
953 tokens
->append(new GString(p1
, p2
- p1
));
954 p1
= *p2
? p2
+ 1 : p2
;
958 if (tokens
->getLength() > 0 &&
959 ((GString
*)tokens
->get(0))->getChar(0) != '#') {
960 cmd
= (GString
*)tokens
->get(0);
961 if (!cmd
->cmp("include")) {
962 if (tokens
->getLength() == 2) {
963 incFile
= (GString
*)tokens
->get(1);
964 if ((f2
= fopen(incFile
->getCString(), "r"))) {
965 parseFile(incFile
, f2
);
968 error(-1, (char*)"Couldn't find included config file: '%s' (%s:%d)",
969 incFile
->getCString(), fileName
->getCString(), line
);
972 error(-1, (char*)"Bad 'include' config file command (%s:%d)",
973 fileName
->getCString(), line
);
975 } else if (!cmd
->cmp("nameToUnicode")) {
976 parseNameToUnicode(tokens
, fileName
, line
);
977 } else if (!cmd
->cmp("cidToUnicode")) {
978 parseCIDToUnicode(tokens
, fileName
, line
);
979 } else if (!cmd
->cmp("unicodeToUnicode")) {
980 parseUnicodeToUnicode(tokens
, fileName
, line
);
981 } else if (!cmd
->cmp("unicodeMap")) {
982 parseUnicodeMap(tokens
, fileName
, line
);
983 } else if (!cmd
->cmp("cMapDir")) {
984 parseCMapDir(tokens
, fileName
, line
);
985 } else if (!cmd
->cmp("toUnicodeDir")) {
986 parseToUnicodeDir(tokens
, fileName
, line
);
987 } else if (!cmd
->cmp("displayFontT1")) {
988 parseDisplayFont(tokens
, displayFonts
, displayFontT1
, fileName
, line
);
989 } else if (!cmd
->cmp("displayFontTT")) {
990 parseDisplayFont(tokens
, displayFonts
, displayFontTT
, fileName
, line
);
991 } else if (!cmd
->cmp("displayNamedCIDFontT1")) {
992 parseDisplayFont(tokens
, displayNamedCIDFonts
,
993 displayFontT1
, fileName
, line
);
994 } else if (!cmd
->cmp("displayCIDFontT1")) {
995 parseDisplayFont(tokens
, displayCIDFonts
,
996 displayFontT1
, fileName
, line
);
997 } else if (!cmd
->cmp("displayNamedCIDFontTT")) {
998 parseDisplayFont(tokens
, displayNamedCIDFonts
,
999 displayFontTT
, fileName
, line
);
1000 } else if (!cmd
->cmp("displayCIDFontTT")) {
1001 parseDisplayFont(tokens
, displayCIDFonts
,
1002 displayFontTT
, fileName
, line
);
1003 } else if (!cmd
->cmp("psFile")) {
1004 parsePSFile(tokens
, fileName
, line
);
1005 } else if (!cmd
->cmp("psFont")) {
1006 parsePSFont(tokens
, fileName
, line
);
1007 } else if (!cmd
->cmp("psNamedFont16")) {
1008 parsePSFont16("psNamedFont16", psNamedFonts16
,
1009 tokens
, fileName
, line
);
1010 } else if (!cmd
->cmp("psFont16")) {
1011 parsePSFont16("psFont16", psFonts16
, tokens
, fileName
, line
);
1012 } else if (!cmd
->cmp("psPaperSize")) {
1013 parsePSPaperSize(tokens
, fileName
, line
);
1014 } else if (!cmd
->cmp("psImageableArea")) {
1015 parsePSImageableArea(tokens
, fileName
, line
);
1016 } else if (!cmd
->cmp("psCrop")) {
1017 parseYesNo("psCrop", &psCrop
, tokens
, fileName
, line
);
1018 } else if (!cmd
->cmp("psExpandSmaller")) {
1019 parseYesNo("psExpandSmaller", &psExpandSmaller
,
1020 tokens
, fileName
, line
);
1021 } else if (!cmd
->cmp("psShrinkLarger")) {
1022 parseYesNo("psShrinkLarger", &psShrinkLarger
, tokens
, fileName
, line
);
1023 } else if (!cmd
->cmp("psCenter")) {
1024 parseYesNo("psCenter", &psCenter
, tokens
, fileName
, line
);
1025 } else if (!cmd
->cmp("psDuplex")) {
1026 parseYesNo("psDuplex", &psDuplex
, tokens
, fileName
, line
);
1027 } else if (!cmd
->cmp("psLevel")) {
1028 parsePSLevel(tokens
, fileName
, line
);
1029 } else if (!cmd
->cmp("psEmbedType1Fonts")) {
1030 parseYesNo("psEmbedType1", &psEmbedType1
, tokens
, fileName
, line
);
1031 } else if (!cmd
->cmp("psEmbedTrueTypeFonts")) {
1032 parseYesNo("psEmbedTrueType", &psEmbedTrueType
,
1033 tokens
, fileName
, line
);
1034 } else if (!cmd
->cmp("psEmbedCIDPostScriptFonts")) {
1035 parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript
,
1036 tokens
, fileName
, line
);
1037 } else if (!cmd
->cmp("psEmbedCIDTrueTypeFonts")) {
1038 parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType
,
1039 tokens
, fileName
, line
);
1040 } else if (!cmd
->cmp("psPreload")) {
1041 parseYesNo("psPreload", &psPreload
, tokens
, fileName
, line
);
1042 } else if (!cmd
->cmp("psOPI")) {
1043 parseYesNo("psOPI", &psOPI
, tokens
, fileName
, line
);
1044 } else if (!cmd
->cmp("psASCIIHex")) {
1045 parseYesNo("psASCIIHex", &psASCIIHex
, tokens
, fileName
, line
);
1046 } else if (!cmd
->cmp("textEncoding")) {
1047 parseTextEncoding(tokens
, fileName
, line
);
1048 } else if (!cmd
->cmp("textEOL")) {
1049 parseTextEOL(tokens
, fileName
, line
);
1050 } else if (!cmd
->cmp("textPageBreaks")) {
1051 parseYesNo("textPageBreaks", &textPageBreaks
,
1052 tokens
, fileName
, line
);
1053 } else if (!cmd
->cmp("textKeepTinyChars")) {
1054 parseYesNo("textKeepTinyChars", &textKeepTinyChars
,
1055 tokens
, fileName
, line
);
1056 } else if (!cmd
->cmp("fontDir")) {
1057 parseFontDir(tokens
, fileName
, line
);
1058 } else if (!cmd
->cmp("initialZoom")) {
1059 parseInitialZoom(tokens
, fileName
, line
);
1060 } else if (!cmd
->cmp("continuousView")) {
1061 parseYesNo("continuousView", &continuousView
, tokens
, fileName
, line
);
1062 } else if (!cmd
->cmp("enableT1lib")) {
1063 parseYesNo("enableT1lib", &enableT1lib
, tokens
, fileName
, line
);
1064 } else if (!cmd
->cmp("enableFreeType")) {
1065 parseYesNo("enableFreeType", &enableFreeType
, tokens
, fileName
, line
);
1066 } else if (!cmd
->cmp("antialias")) {
1067 parseYesNo("antialias", &antialias
, tokens
, fileName
, line
);
1068 } else if (!cmd
->cmp("vectorAntialias")) {
1069 parseYesNo("vectorAntialias", &vectorAntialias
,
1070 tokens
, fileName
, line
);
1071 } else if (!cmd
->cmp("strokeAdjust")) {
1072 parseYesNo("strokeAdjust", &strokeAdjust
, tokens
, fileName
, line
);
1073 } else if (!cmd
->cmp("screenType")) {
1074 parseScreenType(tokens
, fileName
, line
);
1075 } else if (!cmd
->cmp("screenSize")) {
1076 parseInteger("screenSize", &screenSize
, tokens
, fileName
, line
);
1077 } else if (!cmd
->cmp("screenDotRadius")) {
1078 parseInteger("screenDotRadius", &screenDotRadius
,
1079 tokens
, fileName
, line
);
1080 } else if (!cmd
->cmp("screenGamma")) {
1081 parseFloat("screenGamma", &screenGamma
,
1082 tokens
, fileName
, line
);
1083 } else if (!cmd
->cmp("screenBlackThreshold")) {
1084 parseFloat("screenBlackThreshold", &screenBlackThreshold
,
1085 tokens
, fileName
, line
);
1086 } else if (!cmd
->cmp("screenWhiteThreshold")) {
1087 parseFloat("screenWhiteThreshold", &screenWhiteThreshold
,
1088 tokens
, fileName
, line
);
1089 } else if (!cmd
->cmp("urlCommand")) {
1090 parseCommand("urlCommand", &urlCommand
, tokens
, fileName
, line
);
1091 } else if (!cmd
->cmp("movieCommand")) {
1092 parseCommand("movieCommand", &movieCommand
, tokens
, fileName
, line
);
1093 } else if (!cmd
->cmp("mapNumericCharNames")) {
1094 parseYesNo("mapNumericCharNames", &mapNumericCharNames
,
1095 tokens
, fileName
, line
);
1096 } else if (!cmd
->cmp("mapUnknownCharNames")) {
1097 parseYesNo("mapUnknownCharNames", &mapUnknownCharNames
,
1098 tokens
, fileName
, line
);
1099 } else if (!cmd
->cmp("bind")) {
1100 parseBind(tokens
, fileName
, line
);
1101 } else if (!cmd
->cmp("unbind")) {
1102 parseUnbind(tokens
, fileName
, line
);
1103 } else if (!cmd
->cmp("printCommands")) {
1104 parseYesNo("printCommands", &printCommands
, tokens
, fileName
, line
);
1105 } else if (!cmd
->cmp("errQuiet")) {
1106 parseYesNo("errQuiet", &errQuiet
, tokens
, fileName
, line
);
1108 error(-1, (char*)"Unknown config file command '%s' (%s:%d)",
1109 cmd
->getCString(), fileName
->getCString(), line
);
1110 if (!cmd
->cmp("displayFontX") ||
1111 !cmd
->cmp("displayNamedCIDFontX") ||
1112 !cmd
->cmp("displayCIDFontX")) {
1113 error(-1, (char*)"-- Xpdf no longer supports X fonts");
1114 } else if (!cmd
->cmp("t1libControl") || !cmd
->cmp("freetypeControl")) {
1115 error(-1, (char*)"-- The t1libControl and freetypeControl options have been replaced");
1116 error(-1, (char*)" by the enableT1lib, enableFreeType, and antialias options");
1117 } else if (!cmd
->cmp("fontpath") || !cmd
->cmp("fontmap")) {
1118 error(-1, (char*)"-- the config file format has changed since Xpdf 0.9x");
1123 deleteGList(tokens
, GString
);
1126 void GlobalParams::parseNameToUnicode(GList
*tokens
, GString
*fileName
,
1135 if (tokens
->getLength() != 2) {
1136 error(-1, (char*)"Bad 'nameToUnicode' config file command (%s:%d)",
1137 fileName
->getCString(), line
);
1140 name
= (GString
*)tokens
->get(1);
1141 if (!(f
= fopen(name
->getCString(), "r"))) {
1142 error(-1, (char*)"Couldn't open 'nameToUnicode' file '%s'",
1143 name
->getCString());
1147 while (getLine(buf
, sizeof(buf
), f
)) {
1148 tok1
= strtok(buf
, " \t\r\n");
1149 tok2
= strtok(NULL
, " \t\r\n");
1151 sscanf(tok1
, "%x", &u
);
1152 nameToUnicode
->add(tok2
, u
);
1154 error(-1, (char*)"Bad line in 'nameToUnicode' file (%s:%d)", name
, line2
);
1161 void GlobalParams::parseCIDToUnicode(GList
*tokens
, GString
*fileName
,
1163 GString
*collection
, *name
, *old
;
1165 if (tokens
->getLength() != 3) {
1166 error(-1, (char*)"Bad 'cidToUnicode' config file command (%s:%d)",
1167 fileName
->getCString(), line
);
1170 collection
= (GString
*)tokens
->get(1);
1171 name
= (GString
*)tokens
->get(2);
1172 if ((old
= (GString
*)cidToUnicodes
->remove(collection
))) {
1175 cidToUnicodes
->add(collection
->copy(), name
->copy());
1178 void GlobalParams::parseUnicodeToUnicode(GList
*tokens
, GString
*fileName
,
1180 GString
*font
, *file
, *old
;
1182 if (tokens
->getLength() != 3) {
1183 error(-1, (char*)"Bad 'unicodeToUnicode' config file command (%s:%d)",
1184 fileName
->getCString(), line
);
1187 font
= (GString
*)tokens
->get(1);
1188 file
= (GString
*)tokens
->get(2);
1189 if ((old
= (GString
*)unicodeToUnicodes
->remove(font
))) {
1192 unicodeToUnicodes
->add(font
->copy(), file
->copy());
1195 void GlobalParams::parseUnicodeMap(GList
*tokens
, GString
*fileName
,
1197 GString
*encodingName
, *name
, *old
;
1199 if (tokens
->getLength() != 3) {
1200 error(-1, (char*)"Bad 'unicodeMap' config file command (%s:%d)",
1201 fileName
->getCString(), line
);
1204 encodingName
= (GString
*)tokens
->get(1);
1205 name
= (GString
*)tokens
->get(2);
1206 if ((old
= (GString
*)unicodeMaps
->remove(encodingName
))) {
1209 unicodeMaps
->add(encodingName
->copy(), name
->copy());
1212 void GlobalParams::parseCMapDir(GList
*tokens
, GString
*fileName
, int line
) {
1213 GString
*collection
, *dir
;
1216 if (tokens
->getLength() != 3) {
1217 error(-1, (char*)"Bad 'cMapDir' config file command (%s:%d)",
1218 fileName
->getCString(), line
);
1221 collection
= (GString
*)tokens
->get(1);
1222 dir
= (GString
*)tokens
->get(2);
1223 if (!(list
= (GList
*)cMapDirs
->lookup(collection
))) {
1225 cMapDirs
->add(collection
->copy(), list
);
1227 list
->append(dir
->copy());
1230 void GlobalParams::parseToUnicodeDir(GList
*tokens
, GString
*fileName
,
1232 if (tokens
->getLength() != 2) {
1233 error(-1, (char*)"Bad 'toUnicodeDir' config file command (%s:%d)",
1234 fileName
->getCString(), line
);
1237 toUnicodeDirs
->append(((GString
*)tokens
->get(1))->copy());
1240 void GlobalParams::parseDisplayFont(GList
*tokens
, GHash
*fontHash
,
1241 DisplayFontParamKind kind
,
1242 GString
*fileName
, int line
) {
1243 DisplayFontParam
*param
, *old
;
1245 if (tokens
->getLength() < 2) {
1248 param
= new DisplayFontParam(((GString
*)tokens
->get(1))->copy(), kind
);
1252 if (tokens
->getLength() != 3) {
1255 param
->t1
.fileName
= ((GString
*)tokens
->get(2))->copy();
1258 if (tokens
->getLength() != 3) {
1261 param
->tt
.fileName
= ((GString
*)tokens
->get(2))->copy();
1265 if ((old
= (DisplayFontParam
*)fontHash
->remove(param
->name
))) {
1268 fontHash
->add(param
->name
, param
);
1274 error(-1, (char*)"Bad 'display*Font*' config file command (%s:%d)",
1275 fileName
->getCString(), line
);
1278 void GlobalParams::parsePSPaperSize(GList
*tokens
, GString
*fileName
,
1282 if (tokens
->getLength() == 2) {
1283 tok
= (GString
*)tokens
->get(1);
1284 if (!setPSPaperSize(tok
->getCString())) {
1285 error(-1, (char*)"Bad 'psPaperSize' config file command (%s:%d)",
1286 fileName
->getCString(), line
);
1288 } else if (tokens
->getLength() == 3) {
1289 tok
= (GString
*)tokens
->get(1);
1290 psPaperWidth
= atoi(tok
->getCString());
1291 tok
= (GString
*)tokens
->get(2);
1292 psPaperHeight
= atoi(tok
->getCString());
1293 psImageableLLX
= psImageableLLY
= 0;
1294 psImageableURX
= psPaperWidth
;
1295 psImageableURY
= psPaperHeight
;
1297 error(-1, (char*)"Bad 'psPaperSize' config file command (%s:%d)",
1298 fileName
->getCString(), line
);
1302 void GlobalParams::parsePSImageableArea(GList
*tokens
, GString
*fileName
,
1304 if (tokens
->getLength() != 5) {
1305 error(-1, (char*)"Bad 'psImageableArea' config file command (%s:%d)",
1306 fileName
->getCString(), line
);
1309 psImageableLLX
= atoi(((GString
*)tokens
->get(1))->getCString());
1310 psImageableLLY
= atoi(((GString
*)tokens
->get(2))->getCString());
1311 psImageableURX
= atoi(((GString
*)tokens
->get(3))->getCString());
1312 psImageableURY
= atoi(((GString
*)tokens
->get(4))->getCString());
1315 void GlobalParams::parsePSLevel(GList
*tokens
, GString
*fileName
, int line
) {
1318 if (tokens
->getLength() != 2) {
1319 error(-1, (char*)"Bad 'psLevel' config file command (%s:%d)",
1320 fileName
->getCString(), line
);
1323 tok
= (GString
*)tokens
->get(1);
1324 if (!tok
->cmp("level1")) {
1326 } else if (!tok
->cmp("level1sep")) {
1327 psLevel
= psLevel1Sep
;
1328 } else if (!tok
->cmp("level2")) {
1330 } else if (!tok
->cmp("level2sep")) {
1331 psLevel
= psLevel2Sep
;
1332 } else if (!tok
->cmp("level3")) {
1334 } else if (!tok
->cmp("level3Sep")) {
1335 psLevel
= psLevel3Sep
;
1337 error(-1, (char*)"Bad 'psLevel' config file command (%s:%d)",
1338 fileName
->getCString(), line
);
1342 void GlobalParams::parsePSFile(GList
*tokens
, GString
*fileName
, int line
) {
1343 if (tokens
->getLength() != 2) {
1344 error(-1, (char*)"Bad 'psFile' config file command (%s:%d)",
1345 fileName
->getCString(), line
);
1351 psFile
= ((GString
*)tokens
->get(1))->copy();
1354 void GlobalParams::parsePSFont(GList
*tokens
, GString
*fileName
, int line
) {
1357 if (tokens
->getLength() != 3) {
1358 error(-1, (char*)"Bad 'psFont' config file command (%s:%d)",
1359 fileName
->getCString(), line
);
1362 param
= new PSFontParam(((GString
*)tokens
->get(1))->copy(), 0,
1363 ((GString
*)tokens
->get(2))->copy(), NULL
);
1364 psFonts
->add(param
->pdfFontName
, param
);
1367 void GlobalParams::parsePSFont16(const char *cmdName
, GList
*fontList
,
1368 GList
*tokens
, GString
*fileName
, int line
) {
1373 if (tokens
->getLength() != 5) {
1374 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1375 cmdName
, fileName
->getCString(), line
);
1378 tok
= (GString
*)tokens
->get(2);
1379 if (!tok
->cmp("H")) {
1381 } else if (!tok
->cmp("V")) {
1384 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1385 cmdName
, fileName
->getCString(), line
);
1388 param
= new PSFontParam(((GString
*)tokens
->get(1))->copy(),
1390 ((GString
*)tokens
->get(3))->copy(),
1391 ((GString
*)tokens
->get(4))->copy());
1392 fontList
->append(param
);
1395 void GlobalParams::parseTextEncoding(GList
*tokens
, GString
*fileName
,
1397 if (tokens
->getLength() != 2) {
1398 error(-1, (char*)"Bad 'textEncoding' config file command (%s:%d)",
1399 fileName
->getCString(), line
);
1402 delete textEncoding
;
1403 textEncoding
= ((GString
*)tokens
->get(1))->copy();
1406 void GlobalParams::parseTextEOL(GList
*tokens
, GString
*fileName
, int line
) {
1409 if (tokens
->getLength() != 2) {
1410 error(-1, (char*)"Bad 'textEOL' config file command (%s:%d)",
1411 fileName
->getCString(), line
);
1414 tok
= (GString
*)tokens
->get(1);
1415 if (!tok
->cmp("unix")) {
1417 } else if (!tok
->cmp("dos")) {
1419 } else if (!tok
->cmp("mac")) {
1422 error(-1, (char*)"Bad 'textEOL' config file command (%s:%d)",
1423 fileName
->getCString(), line
);
1427 void GlobalParams::parseFontDir(GList
*tokens
, GString
*fileName
, int line
) {
1428 if (tokens
->getLength() != 2) {
1429 error(-1, (char*)"Bad 'fontDir' config file command (%s:%d)",
1430 fileName
->getCString(), line
);
1433 fontDirs
->append(((GString
*)tokens
->get(1))->copy());
1436 void GlobalParams::parseInitialZoom(GList
*tokens
,
1437 GString
*fileName
, int line
) {
1438 if (tokens
->getLength() != 2) {
1439 error(-1, (char*)"Bad 'initialZoom' config file command (%s:%d)",
1440 fileName
->getCString(), line
);
1444 initialZoom
= ((GString
*)tokens
->get(1))->copy();
1447 void GlobalParams::parseScreenType(GList
*tokens
, GString
*fileName
,
1451 if (tokens
->getLength() != 2) {
1452 error(-1, (char*)"Bad 'screenType' config file command (%s:%d)",
1453 fileName
->getCString(), line
);
1456 tok
= (GString
*)tokens
->get(1);
1457 if (!tok
->cmp("dispersed")) {
1458 screenType
= screenDispersed
;
1459 } else if (!tok
->cmp("clustered")) {
1460 screenType
= screenClustered
;
1461 } else if (!tok
->cmp("stochasticClustered")) {
1462 screenType
= screenStochasticClustered
;
1464 error(-1, (char*)"Bad 'screenType' config file command (%s:%d)",
1465 fileName
->getCString(), line
);
1469 void GlobalParams::parseBind(GList
*tokens
, GString
*fileName
, int line
) {
1470 KeyBinding
*binding
;
1472 int code
, mods
, context
, i
;
1474 if (tokens
->getLength() < 4) {
1475 error(-1, (char*)"Bad 'bind' config file command (%s:%d)",
1476 fileName
->getCString(), line
);
1479 if (!parseKey((GString
*)tokens
->get(1), (GString
*)tokens
->get(2),
1480 &code
, &mods
, &context
,
1481 "bind", tokens
, fileName
, line
)) {
1484 for (i
= 0; i
< keyBindings
->getLength(); ++i
) {
1485 binding
= (KeyBinding
*)keyBindings
->get(i
);
1486 if (binding
->code
== code
&&
1487 binding
->mods
== mods
&&
1488 binding
->context
== context
) {
1489 delete (KeyBinding
*)keyBindings
->del(i
);
1494 for (i
= 3; i
< tokens
->getLength(); ++i
) {
1495 cmds
->append(((GString
*)tokens
->get(i
))->copy());
1497 keyBindings
->append(new KeyBinding(code
, mods
, context
, cmds
));
1500 void GlobalParams::parseUnbind(GList
*tokens
, GString
*fileName
, int line
) {
1501 KeyBinding
*binding
;
1502 int code
, mods
, context
, i
;
1504 if (tokens
->getLength() != 3) {
1505 error(-1, (char*)"Bad 'unbind' config file command (%s:%d)",
1506 fileName
->getCString(), line
);
1509 if (!parseKey((GString
*)tokens
->get(1), (GString
*)tokens
->get(2),
1510 &code
, &mods
, &context
,
1511 "unbind", tokens
, fileName
, line
)) {
1514 for (i
= 0; i
< keyBindings
->getLength(); ++i
) {
1515 binding
= (KeyBinding
*)keyBindings
->get(i
);
1516 if (binding
->code
== code
&&
1517 binding
->mods
== mods
&&
1518 binding
->context
== context
) {
1519 delete (KeyBinding
*)keyBindings
->del(i
);
1525 GBool
GlobalParams::parseKey(GString
*modKeyStr
, GString
*contextStr
,
1526 int *code
, int *mods
, int *context
,
1527 const char *cmdName
,
1528 GList
*tokens
, GString
*fileName
, int line
) {
1531 *mods
= xpdfKeyModNone
;
1532 p0
= modKeyStr
->getCString();
1534 if (!strncmp(p0
, "shift-", 6)) {
1535 *mods
|= xpdfKeyModShift
;
1537 } else if (!strncmp(p0
, "ctrl-", 5)) {
1538 *mods
|= xpdfKeyModCtrl
;
1540 } else if (!strncmp(p0
, "alt-", 4)) {
1541 *mods
|= xpdfKeyModAlt
;
1548 if (!strcmp(p0
, "space")) {
1550 } else if (!strcmp(p0
, "tab")) {
1551 *code
= xpdfKeyCodeTab
;
1552 } else if (!strcmp(p0
, "return")) {
1553 *code
= xpdfKeyCodeReturn
;
1554 } else if (!strcmp(p0
, "enter")) {
1555 *code
= xpdfKeyCodeEnter
;
1556 } else if (!strcmp(p0
, "backspace")) {
1557 *code
= xpdfKeyCodeBackspace
;
1558 } else if (!strcmp(p0
, "insert")) {
1559 *code
= xpdfKeyCodeInsert
;
1560 } else if (!strcmp(p0
, "delete")) {
1561 *code
= xpdfKeyCodeDelete
;
1562 } else if (!strcmp(p0
, "home")) {
1563 *code
= xpdfKeyCodeHome
;
1564 } else if (!strcmp(p0
, "end")) {
1565 *code
= xpdfKeyCodeEnd
;
1566 } else if (!strcmp(p0
, "pgup")) {
1567 *code
= xpdfKeyCodePgUp
;
1568 } else if (!strcmp(p0
, "pgdn")) {
1569 *code
= xpdfKeyCodePgDn
;
1570 } else if (!strcmp(p0
, "left")) {
1571 *code
= xpdfKeyCodeLeft
;
1572 } else if (!strcmp(p0
, "right")) {
1573 *code
= xpdfKeyCodeRight
;
1574 } else if (!strcmp(p0
, "up")) {
1575 *code
= xpdfKeyCodeUp
;
1576 } else if (!strcmp(p0
, "down")) {
1577 *code
= xpdfKeyCodeDown
;
1578 } else if (p0
[0] == 'f' && p0
[1] >= '1' && p0
[1] <= '9' && !p0
[2]) {
1579 *code
= xpdfKeyCodeF1
+ (p0
[1] - '1');
1580 } else if (p0
[0] == 'f' &&
1581 ((p0
[1] >= '1' && p0
[1] <= '2' && p0
[2] >= '0' && p0
[2] <= '9') ||
1582 (p0
[1] == '3' && p0
[2] >= '0' && p0
[2] <= '5')) &&
1584 *code
= xpdfKeyCodeF1
+ 10 * (p0
[1] - '0') + (p0
[2] - '0') - 1;
1585 } else if (!strncmp(p0
, "mousePress", 10) &&
1586 p0
[10] >= '1' && p0
[10] <= '7' && !p0
[11]) {
1587 *code
= xpdfKeyCodeMousePress1
+ (p0
[10] - '1');
1588 } else if (!strncmp(p0
, "mouseRelease", 12) &&
1589 p0
[12] >= '1' && p0
[12] <= '7' && !p0
[13]) {
1590 *code
= xpdfKeyCodeMouseRelease1
+ (p0
[12] - '1');
1591 } else if (*p0
>= 0x20 && *p0
<= 0x7e && !p0
[1]) {
1594 error(-1, (char*)"Bad key/modifier in '%s' config file command (%s:%d)",
1595 cmdName
, fileName
->getCString(), line
);
1599 p0
= contextStr
->getCString();
1600 if (!strcmp(p0
, "any")) {
1601 *context
= xpdfKeyContextAny
;
1603 *context
= xpdfKeyContextAny
;
1605 if (!strncmp(p0
, "fullScreen", 10)) {
1606 *context
|= xpdfKeyContextFullScreen
;
1608 } else if (!strncmp(p0
, "window", 6)) {
1609 *context
|= xpdfKeyContextWindow
;
1611 } else if (!strncmp(p0
, "continuous", 10)) {
1612 *context
|= xpdfKeyContextContinuous
;
1614 } else if (!strncmp(p0
, "singlePage", 10)) {
1615 *context
|= xpdfKeyContextSinglePage
;
1617 } else if (!strncmp(p0
, "overLink", 8)) {
1618 *context
|= xpdfKeyContextOverLink
;
1620 } else if (!strncmp(p0
, "offLink", 7)) {
1621 *context
|= xpdfKeyContextOffLink
;
1623 } else if (!strncmp(p0
, "outline", 7)) {
1624 *context
|= xpdfKeyContextOutline
;
1626 } else if (!strncmp(p0
, "mainWin", 7)) {
1627 *context
|= xpdfKeyContextMainWin
;
1629 } else if (!strncmp(p0
, "scrLockOn", 9)) {
1630 *context
|= xpdfKeyContextScrLockOn
;
1632 } else if (!strncmp(p0
, "scrLockOff", 10)) {
1633 *context
|= xpdfKeyContextScrLockOff
;
1636 error(-1, (char*)"Bad context in '%s' config file command (%s:%d)",
1637 cmdName
, fileName
->getCString(), line
);
1644 error(-1, (char*)"Bad context in '%s' config file command (%s:%d)",
1645 cmdName
, fileName
->getCString(), line
);
1655 void GlobalParams::parseCommand(const char *cmdName
, GString
**val
,
1656 GList
*tokens
, GString
*fileName
, int line
) {
1657 if (tokens
->getLength() != 2) {
1658 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1659 cmdName
, fileName
->getCString(), line
);
1665 *val
= ((GString
*)tokens
->get(1))->copy();
1668 void GlobalParams::parseYesNo(const char *cmdName
, GBool
*flag
,
1669 GList
*tokens
, GString
*fileName
, int line
) {
1672 if (tokens
->getLength() != 2) {
1673 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1674 cmdName
, fileName
->getCString(), line
);
1677 tok
= (GString
*)tokens
->get(1);
1678 if (!parseYesNo2(tok
->getCString(), flag
)) {
1679 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1680 cmdName
, fileName
->getCString(), line
);
1684 GBool
GlobalParams::parseYesNo2(const char *token
, GBool
*flag
) {
1685 if (!strcmp(token
, "yes")) {
1687 } else if (!strcmp(token
, "no")) {
1695 void GlobalParams::parseInteger(const char *cmdName
, int *val
,
1696 GList
*tokens
, GString
*fileName
, int line
) {
1700 if (tokens
->getLength() != 2) {
1701 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1702 cmdName
, fileName
->getCString(), line
);
1705 tok
= (GString
*)tokens
->get(1);
1706 if (tok
->getLength() == 0) {
1707 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1708 cmdName
, fileName
->getCString(), line
);
1711 if (tok
->getChar(0) == '-') {
1716 for (; i
< tok
->getLength(); ++i
) {
1717 if (tok
->getChar(i
) < '0' || tok
->getChar(i
) > '9') {
1718 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1719 cmdName
, fileName
->getCString(), line
);
1723 *val
= atoi(tok
->getCString());
1726 void GlobalParams::parseFloat(const char *cmdName
, double *val
,
1727 GList
*tokens
, GString
*fileName
, int line
) {
1731 if (tokens
->getLength() != 2) {
1732 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1733 cmdName
, fileName
->getCString(), line
);
1736 tok
= (GString
*)tokens
->get(1);
1737 if (tok
->getLength() == 0) {
1738 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1739 cmdName
, fileName
->getCString(), line
);
1742 if (tok
->getChar(0) == '-') {
1747 for (; i
< tok
->getLength(); ++i
) {
1748 if (!((tok
->getChar(i
) >= '0' && tok
->getChar(i
) <= '9') ||
1749 tok
->getChar(i
) == '.')) {
1750 error(-1, (char*)"Bad '%s' config file command (%s:%d)",
1751 cmdName
, fileName
->getCString(), line
);
1755 *val
= atof(tok
->getCString());
1758 GlobalParams::~GlobalParams() {
1763 freeBuiltinFontTables();
1765 delete macRomanReverseMap
;
1768 delete nameToUnicode
;
1769 deleteGHash(cidToUnicodes
, GString
);
1770 deleteGHash(unicodeToUnicodes
, GString
);
1771 deleteGHash(residentUnicodeMaps
, UnicodeMap
);
1772 deleteGHash(unicodeMaps
, GString
);
1773 deleteGList(toUnicodeDirs
, GString
);
1774 deleteGHash(displayFonts
, DisplayFontParam
);
1775 deleteGHash(displayCIDFonts
, DisplayFontParam
);
1776 deleteGHash(displayNamedCIDFonts
, DisplayFontParam
);
1785 deleteGHash(psFonts
, PSFontParam
);
1786 deleteGList(psNamedFonts16
, PSFontParam
);
1787 deleteGList(psFonts16
, PSFontParam
);
1788 delete textEncoding
;
1789 deleteGList(fontDirs
, GString
);
1795 delete movieCommand
;
1797 deleteGList(keyBindings
, KeyBinding
);
1799 cMapDirs
->startIter(&iter
);
1800 while (cMapDirs
->getNext(&iter
, &key
, (void **)&list
)) {
1801 deleteGList(list
, GString
);
1805 delete cidToUnicodeCache
;
1806 delete unicodeToUnicodeCache
;
1807 delete unicodeMapCache
;
1810 #ifdef ENABLE_PLUGINS
1811 delete securityHandlers
;
1812 deleteGList(plugins
, Plugin
);
1816 gDestroyMutex(&mutex
);
1817 gDestroyMutex(&unicodeMapCacheMutex
);
1818 gDestroyMutex(&cMapCacheMutex
);
1822 //------------------------------------------------------------------------
1824 void GlobalParams::setBaseDir(char *dir
) {
1826 baseDir
= new GString(dir
);
1829 void GlobalParams::setupBaseFonts(char *dir
) {
1834 BOOL (__stdcall
*SHGetSpecialFolderPathFunc
)(HWND hwndOwner
,
1838 char winFontDir
[MAX_PATH
];
1841 DisplayFontParamKind kind
;
1842 DisplayFontParam
*dfp
;
1846 // SHGetSpecialFolderPath isn't available in older versions of
1847 // shell32.dll (Win95 and WinNT4), so do a dynamic load
1848 winFontDir
[0] = '\0';
1849 if ((shell32Lib
= LoadLibrary("shell32.dll"))) {
1850 if ((SHGetSpecialFolderPathFunc
=
1851 (BOOL (__stdcall
*)(HWND hwndOwner
, LPTSTR lpszPath
,
1852 int nFolder
, BOOL fCreate
))
1853 GetProcAddress(shell32Lib
, "SHGetSpecialFolderPathA"))) {
1854 if (!(*SHGetSpecialFolderPathFunc
)(NULL
, winFontDir
,
1855 CSIDL_FONTS
, FALSE
)) {
1856 winFontDir
[0] = '\0';
1861 for (i
= 0; displayFontTab
[i
].name
; ++i
) {
1862 fontName
= new GString(displayFontTab
[i
].name
);
1863 if (getDisplayFont(fontName
)) {
1868 kind
= displayFontT1
; // make gcc happy
1870 fileName
= appendToPath(new GString(dir
), (char *)displayFontTab
[i
].t1FileName
);
1871 kind
= displayFontT1
;
1872 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1880 if (!fileName
&& winFontDir
[0] && displayFontTab
[i
].ttFileName
) {
1881 fileName
= appendToPath(new GString(winFontDir
),
1882 displayFontTab
[i
].ttFileName
);
1883 kind
= displayFontTT
;
1884 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1891 // SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server
1892 // or Win2003 Server, or with older versions of shell32.dll, so check
1893 // the "standard" directories
1894 if (displayFontTab
[i
].ttFileName
) {
1895 for (j
= 0; !fileName
&& displayFontDirs
[j
]; ++j
) {
1896 fileName
= appendToPath(new GString(displayFontDirs
[j
]),
1897 displayFontTab
[i
].ttFileName
);
1898 kind
= displayFontTT
;
1899 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1908 for (j
= 0; !fileName
&& displayFontDirs
[j
]; ++j
) {
1909 fileName
= appendToPath(new GString(displayFontDirs
[j
]),
1910 (char *)displayFontTab
[i
].t1FileName
);
1911 kind
= displayFontT1
;
1914 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1923 error(-1, (char*)"No display font for '%s'", displayFontTab
[i
].name
);
1927 dfp
= new DisplayFontParam(fontName
, kind
);
1928 dfp
->t1
.fileName
= fileName
;
1929 globalParams
->addDisplayFont(dfp
);
1933 if (winFontDir
[0]) {
1934 winFontList
= new WinFontList(winFontDir
);
1939 //------------------------------------------------------------------------
1941 //------------------------------------------------------------------------
1943 CharCode
GlobalParams::getMacRomanCharCode(char *charName
) {
1944 // no need to lock - macRomanReverseMap is constant
1945 return macRomanReverseMap
->lookup(charName
);
1948 GString
*GlobalParams::getBaseDir() {
1952 s
= baseDir
->copy();
1957 Unicode
GlobalParams::mapNameToUnicode(char *charName
) {
1958 // no need to lock - nameToUnicode is constant
1959 return nameToUnicode
->lookup(charName
);
1962 UnicodeMap
*GlobalParams::getResidentUnicodeMap(GString
*encodingName
) {
1966 map
= (UnicodeMap
*)residentUnicodeMaps
->lookup(encodingName
);
1974 FILE *GlobalParams::getUnicodeMapFile(GString
*encodingName
) {
1979 if ((fileName
= (GString
*)unicodeMaps
->lookup(encodingName
))) {
1980 f
= fopen(fileName
->getCString(), "r");
1988 FILE *GlobalParams::findCMapFile(GString
*collection
, GString
*cMapName
) {
1996 if (!(list
= (GList
*)cMapDirs
->lookup(collection
))) {
2000 for (i
= 0; i
< list
->getLength(); ++i
) {
2001 dir
= (GString
*)list
->get(i
);
2002 fileName
= appendToPath(dir
->copy(), cMapName
->getCString());
2003 f
= fopen(fileName
->getCString(), "r");
2014 FILE *GlobalParams::findToUnicodeFile(GString
*name
) {
2015 GString
*dir
, *fileName
;
2020 for (i
= 0; i
< toUnicodeDirs
->getLength(); ++i
) {
2021 dir
= (GString
*)toUnicodeDirs
->get(i
);
2022 fileName
= appendToPath(dir
->copy(), name
->getCString());
2023 f
= fopen(fileName
->getCString(), "r");
2034 DisplayFontParam
*GlobalParams::getDisplayFont(GString
*fontName
) {
2035 DisplayFontParam
*dfp
;
2038 dfp
= (DisplayFontParam
*)displayFonts
->lookup(fontName
);
2040 if (!dfp
&& winFontList
) {
2041 dfp
= winFontList
->find(fontName
);
2048 DisplayFontParam
*GlobalParams::getDisplayCIDFont(GString
*fontName
,
2049 GString
*collection
) {
2050 DisplayFontParam
*dfp
;
2054 !(dfp
= (DisplayFontParam
*)displayNamedCIDFonts
->lookup(fontName
))) {
2055 dfp
= (DisplayFontParam
*)displayCIDFonts
->lookup(collection
);
2061 GString
*GlobalParams::getPSFile() {
2065 s
= psFile
? psFile
->copy() : (GString
*)NULL
;
2070 int GlobalParams::getPSPaperWidth() {
2079 int GlobalParams::getPSPaperHeight() {
2088 void GlobalParams::getPSImageableArea(int *llx
, int *lly
, int *urx
, int *ury
) {
2090 *llx
= psImageableLLX
;
2091 *lly
= psImageableLLY
;
2092 *urx
= psImageableURX
;
2093 *ury
= psImageableURY
;
2097 GBool
GlobalParams::getPSCrop() {
2106 GBool
GlobalParams::getPSExpandSmaller() {
2110 f
= psExpandSmaller
;
2115 GBool
GlobalParams::getPSShrinkLarger() {
2124 GBool
GlobalParams::getPSCenter() {
2133 GBool
GlobalParams::getPSDuplex() {
2142 PSLevel
GlobalParams::getPSLevel() {
2151 PSFontParam
*GlobalParams::getPSFont(GString
*fontName
) {
2155 p
= (PSFontParam
*)psFonts
->lookup(fontName
);
2160 PSFontParam
*GlobalParams::getPSFont16(GString
*fontName
,
2161 GString
*collection
, int wMode
) {
2168 for (i
= 0; i
< psNamedFonts16
->getLength(); ++i
) {
2169 p
= (PSFontParam
*)psNamedFonts16
->get(i
);
2170 if (!p
->pdfFontName
->cmp(fontName
) &&
2171 p
->wMode
== wMode
) {
2177 if (!p
&& collection
) {
2178 for (i
= 0; i
< psFonts16
->getLength(); ++i
) {
2179 p
= (PSFontParam
*)psFonts16
->get(i
);
2180 if (!p
->pdfFontName
->cmp(collection
) &&
2181 p
->wMode
== wMode
) {
2191 GBool
GlobalParams::getPSEmbedType1() {
2200 GBool
GlobalParams::getPSEmbedTrueType() {
2204 e
= psEmbedTrueType
;
2209 GBool
GlobalParams::getPSEmbedCIDPostScript() {
2213 e
= psEmbedCIDPostScript
;
2218 GBool
GlobalParams::getPSEmbedCIDTrueType() {
2222 e
= psEmbedCIDTrueType
;
2227 GBool
GlobalParams::getPSPreload() {
2231 preload
= psPreload
;
2236 GBool
GlobalParams::getPSOPI() {
2245 GBool
GlobalParams::getPSASCIIHex() {
2254 GString
*GlobalParams::getTextEncodingName() {
2258 s
= textEncoding
->copy();
2263 EndOfLineKind
GlobalParams::getTextEOL() {
2272 GBool
GlobalParams::getTextPageBreaks() {
2276 pageBreaks
= textPageBreaks
;
2281 GBool
GlobalParams::getTextKeepTinyChars() {
2285 tiny
= textKeepTinyChars
;
2290 GString
*GlobalParams::findFontFile(GString
*fontName
, char **exts
) {
2291 GString
*dir
, *fileName
;
2297 for (i
= 0; i
< fontDirs
->getLength(); ++i
) {
2298 dir
= (GString
*)fontDirs
->get(i
);
2299 for (ext
= exts
; *ext
; ++ext
) {
2300 fileName
= appendToPath(dir
->copy(), fontName
->getCString());
2301 fileName
->append(*ext
);
2302 if ((f
= fopen(fileName
->getCString(), "rb"))) {
2314 GString
*GlobalParams::getInitialZoom() {
2318 s
= initialZoom
->copy();
2323 GBool
GlobalParams::getContinuousView() {
2332 GBool
GlobalParams::getEnableT1lib() {
2341 GBool
GlobalParams::getEnableFreeType() {
2351 GBool
GlobalParams::getAntialias() {
2360 GBool
GlobalParams::getVectorAntialias() {
2364 f
= vectorAntialias
;
2369 GBool
GlobalParams::getStrokeAdjust() {
2378 ScreenType
GlobalParams::getScreenType() {
2387 int GlobalParams::getScreenSize() {
2396 int GlobalParams::getScreenDotRadius() {
2400 r
= screenDotRadius
;
2405 double GlobalParams::getScreenGamma() {
2409 gamma
= screenGamma
;
2414 double GlobalParams::getScreenBlackThreshold() {
2418 thresh
= screenBlackThreshold
;
2423 double GlobalParams::getScreenWhiteThreshold() {
2427 thresh
= screenWhiteThreshold
;
2432 GBool
GlobalParams::getMapNumericCharNames() {
2436 map
= mapNumericCharNames
;
2441 GBool
GlobalParams::getMapUnknownCharNames() {
2445 map
= mapUnknownCharNames
;
2450 GList
*GlobalParams::getKeyBinding(int code
, int mods
, int context
) {
2451 KeyBinding
*binding
;
2458 // for ASCII chars, ignore the shift modifier
2459 modMask
= code
<= 0xff ? ~xpdfKeyModShift
: ~0;
2460 for (i
= 0; i
< keyBindings
->getLength(); ++i
) {
2461 binding
= (KeyBinding
*)keyBindings
->get(i
);
2462 if (binding
->code
== code
&&
2463 (binding
->mods
& modMask
) == (mods
& modMask
) &&
2464 (~binding
->context
| context
) == ~0) {
2466 for (j
= 0; j
< binding
->cmds
->getLength(); ++j
) {
2467 cmds
->append(((GString
*)binding
->cmds
->get(j
))->copy());
2476 GBool
GlobalParams::getPrintCommands() {
2485 GBool
GlobalParams::getErrQuiet() {
2486 // no locking -- this function may get called from inside a locked
2491 CharCodeToUnicode
*GlobalParams::getCIDToUnicode(GString
*collection
) {
2493 CharCodeToUnicode
*ctu
;
2496 if (!(ctu
= cidToUnicodeCache
->getCharCodeToUnicode(collection
))) {
2497 if ((fileName
= (GString
*)cidToUnicodes
->lookup(collection
)) &&
2498 (ctu
= CharCodeToUnicode::parseCIDToUnicode(fileName
, collection
))) {
2499 cidToUnicodeCache
->add(ctu
);
2506 CharCodeToUnicode
*GlobalParams::getUnicodeToUnicode(GString
*fontName
) {
2507 CharCodeToUnicode
*ctu
;
2509 GString
*fontPattern
, *fileName
;
2513 unicodeToUnicodes
->startIter(&iter
);
2514 while (unicodeToUnicodes
->getNext(&iter
, &fontPattern
, (void **)&fileName
)) {
2515 if (strstr(fontName
->getCString(), fontPattern
->getCString())) {
2516 unicodeToUnicodes
->killIter(&iter
);
2522 if (!(ctu
= unicodeToUnicodeCache
->getCharCodeToUnicode(fileName
))) {
2523 if ((ctu
= CharCodeToUnicode::parseUnicodeToUnicode(fileName
))) {
2524 unicodeToUnicodeCache
->add(ctu
);
2534 UnicodeMap
*GlobalParams::getUnicodeMap(GString
*encodingName
) {
2535 return getUnicodeMap2(encodingName
);
2538 UnicodeMap
*GlobalParams::getUnicodeMap2(GString
*encodingName
) {
2541 if (!(map
= getResidentUnicodeMap(encodingName
))) {
2542 lockUnicodeMapCache
;
2543 map
= unicodeMapCache
->getUnicodeMap(encodingName
);
2544 unlockUnicodeMapCache
;
2549 CMap
*GlobalParams::getCMap(GString
*collection
, GString
*cMapName
) {
2553 cMap
= cMapCache
->getCMap(collection
, cMapName
);
2558 UnicodeMap
*GlobalParams::getTextEncoding() {
2559 return getUnicodeMap2(textEncoding
);
2562 //------------------------------------------------------------------------
2563 // functions to set parameters
2564 //------------------------------------------------------------------------
2566 void GlobalParams::addDisplayFont(DisplayFontParam
*param
) {
2567 DisplayFontParam
*old
;
2570 if ((old
= (DisplayFontParam
*)displayFonts
->remove(param
->name
))) {
2573 displayFonts
->add(param
->name
, param
);
2577 void GlobalParams::setPSFile(char *file
) {
2582 psFile
= new GString(file
);
2586 GBool
GlobalParams::setPSPaperSize(char *size
) {
2588 if (!strcmp(size
, "match")) {
2589 psPaperWidth
= psPaperHeight
= -1;
2590 } else if (!strcmp(size
, "letter")) {
2592 psPaperHeight
= 792;
2593 } else if (!strcmp(size
, "legal")) {
2595 psPaperHeight
= 1008;
2596 } else if (!strcmp(size
, "A4")) {
2598 psPaperHeight
= 842;
2599 } else if (!strcmp(size
, "A3")) {
2601 psPaperHeight
= 1190;
2606 psImageableLLX
= psImageableLLY
= 0;
2607 psImageableURX
= psPaperWidth
;
2608 psImageableURY
= psPaperHeight
;
2613 void GlobalParams::setPSPaperWidth(int width
) {
2615 psPaperWidth
= width
;
2617 psImageableURX
= psPaperWidth
;
2621 void GlobalParams::setPSPaperHeight(int height
) {
2623 psPaperHeight
= height
;
2625 psImageableURY
= psPaperHeight
;
2629 void GlobalParams::setPSImageableArea(int llx
, int lly
, int urx
, int ury
) {
2631 psImageableLLX
= llx
;
2632 psImageableLLY
= lly
;
2633 psImageableURX
= urx
;
2634 psImageableURY
= ury
;
2638 void GlobalParams::setPSCrop(GBool crop
) {
2644 void GlobalParams::setPSExpandSmaller(GBool expand
) {
2646 psExpandSmaller
= expand
;
2650 void GlobalParams::setPSShrinkLarger(GBool shrink
) {
2652 psShrinkLarger
= shrink
;
2656 void GlobalParams::setPSCenter(GBool center
) {
2662 void GlobalParams::setPSDuplex(GBool duplex
) {
2668 void GlobalParams::setPSLevel(PSLevel level
) {
2674 void GlobalParams::setPSEmbedType1(GBool embed
) {
2676 psEmbedType1
= embed
;
2680 void GlobalParams::setPSEmbedTrueType(GBool embed
) {
2682 psEmbedTrueType
= embed
;
2686 void GlobalParams::setPSEmbedCIDPostScript(GBool embed
) {
2688 psEmbedCIDPostScript
= embed
;
2692 void GlobalParams::setPSEmbedCIDTrueType(GBool embed
) {
2694 psEmbedCIDTrueType
= embed
;
2698 void GlobalParams::setPSPreload(GBool preload
) {
2700 psPreload
= preload
;
2704 void GlobalParams::setPSOPI(GBool opi
) {
2710 void GlobalParams::setPSASCIIHex(GBool hex
) {
2716 void GlobalParams::setTextEncoding(char *encodingName
) {
2718 delete textEncoding
;
2719 textEncoding
= new GString(encodingName
);
2723 GBool
GlobalParams::setTextEOL(char *s
) {
2725 if (!strcmp(s
, "unix")) {
2727 } else if (!strcmp(s
, "dos")) {
2729 } else if (!strcmp(s
, "mac")) {
2739 void GlobalParams::setTextPageBreaks(GBool pageBreaks
) {
2741 textPageBreaks
= pageBreaks
;
2745 void GlobalParams::setTextKeepTinyChars(GBool keep
) {
2747 textKeepTinyChars
= keep
;
2751 void GlobalParams::setInitialZoom(char *s
) {
2754 initialZoom
= new GString(s
);
2758 void GlobalParams::setContinuousView(GBool cont
) {
2760 continuousView
= cont
;
2764 GBool
GlobalParams::setEnableT1lib(char *s
) {
2768 ok
= parseYesNo2(s
, &enableT1lib
);
2773 GBool
GlobalParams::setEnableFreeType(char *s
) {
2777 ok
= parseYesNo2(s
, &enableFreeType
);
2783 GBool
GlobalParams::setAntialias(char *s
) {
2787 ok
= parseYesNo2(s
, &antialias
);
2792 GBool
GlobalParams::setVectorAntialias(char *s
) {
2796 ok
= parseYesNo2(s
, &vectorAntialias
);
2801 void GlobalParams::setScreenType(ScreenType t
) {
2807 void GlobalParams::setScreenSize(int size
) {
2813 void GlobalParams::setScreenDotRadius(int r
) {
2815 screenDotRadius
= r
;
2819 void GlobalParams::setScreenGamma(double gamma
) {
2821 screenGamma
= gamma
;
2825 void GlobalParams::setScreenBlackThreshold(double thresh
) {
2827 screenBlackThreshold
= thresh
;
2831 void GlobalParams::setScreenWhiteThreshold(double thresh
) {
2833 screenWhiteThreshold
= thresh
;
2837 void GlobalParams::setMapNumericCharNames(GBool map
) {
2839 mapNumericCharNames
= map
;
2843 void GlobalParams::setMapUnknownCharNames(GBool map
) {
2845 mapUnknownCharNames
= map
;
2849 void GlobalParams::setPrintCommands(GBool printCommandsA
) {
2851 printCommands
= printCommandsA
;
2855 void GlobalParams::setErrQuiet(GBool errQuietA
) {
2857 errQuiet
= errQuietA
;
2861 void GlobalParams::addSecurityHandler(XpdfSecurityHandler
*handler
) {
2862 #ifdef ENABLE_PLUGINS
2864 securityHandlers
->append(handler
);
2869 XpdfSecurityHandler
*GlobalParams::getSecurityHandler(char *name
) {
2870 #ifdef ENABLE_PLUGINS
2871 XpdfSecurityHandler
*hdlr
;
2875 for (i
= 0; i
< securityHandlers
->getLength(); ++i
) {
2876 hdlr
= (XpdfSecurityHandler
*)securityHandlers
->get(i
);
2877 if (!strcasecmp(hdlr
->name
, name
)) {
2884 if (!loadPlugin("security", name
)) {
2889 for (i
= 0; i
< securityHandlers
->getLength(); ++i
) {
2890 hdlr
= (XpdfSecurityHandler
*)securityHandlers
->get(i
);
2891 if (!strcmp(hdlr
->name
, name
)) {
2902 #ifdef ENABLE_PLUGINS
2903 //------------------------------------------------------------------------
2905 //------------------------------------------------------------------------
2907 GBool
GlobalParams::loadPlugin(char *type
, char *name
) {
2910 if (!(plugin
= Plugin::load(type
, name
))) {
2914 plugins
->append(plugin
);
2919 #endif // ENABLE_PLUGINS