Lines 23-28
Link Here
|
23 |
#ifdef WIN32 |
23 |
#ifdef WIN32 |
24 |
# include <shlobj.h> |
24 |
# include <shlobj.h> |
25 |
#endif |
25 |
#endif |
|
|
26 |
#if HAVE_PAPER_H |
27 |
#include <paper.h> |
28 |
#endif |
26 |
#include <fontconfig/fontconfig.h> |
29 |
#include <fontconfig/fontconfig.h> |
27 |
#include "goo/gmem.h" |
30 |
#include "goo/gmem.h" |
28 |
#include "goo/GooString.h" |
31 |
#include "goo/GooString.h" |
Lines 83-88
Link Here
|
83 |
|
86 |
|
84 |
//------------------------------------------------------------------------ |
87 |
//------------------------------------------------------------------------ |
85 |
|
88 |
|
|
|
89 |
static struct { |
90 |
char *name; |
91 |
char *t1FileName; |
92 |
char *ttFileName; |
93 |
} displayFontTab[] = { |
94 |
{"Courier", "n022003l.pfb", "cour.ttf"}, |
95 |
{"Courier-Bold", "n022004l.pfb", "courbd.ttf"}, |
96 |
{"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"}, |
97 |
{"Courier-Oblique", "n022023l.pfb", "couri.ttf"}, |
98 |
{"Helvetica", "n019003l.pfb", "arial.ttf"}, |
99 |
{"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"}, |
100 |
{"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"}, |
101 |
{"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"}, |
102 |
{"Symbol", "s050000l.pfb", NULL}, |
103 |
{"Times-Bold", "n021004l.pfb", "timesbd.ttf"}, |
104 |
{"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"}, |
105 |
{"Times-Italic", "n021023l.pfb", "timesi.ttf"}, |
106 |
{"Times-Roman", "n021003l.pfb", "times.ttf"}, |
107 |
{"ZapfDingbats", "d050000l.pfb", NULL}, |
108 |
{NULL} |
109 |
}; |
110 |
|
111 |
#ifdef WIN32 |
112 |
static char *displayFontDirs[] = { |
113 |
"c:/windows/fonts", |
114 |
"c:/winnt/fonts", |
115 |
NULL |
116 |
}; |
117 |
#else |
118 |
static char *displayFontDirs[] = { |
119 |
"/usr/share/ghostscript/fonts", |
120 |
"/usr/local/share/ghostscript/fonts", |
121 |
"/usr/share/fonts/default/Type1", |
122 |
"/usr/share/fonts/default/ghostscript", |
123 |
"/usr/share/fonts/type1/gsfonts", |
124 |
NULL |
125 |
}; |
126 |
#endif |
127 |
|
128 |
//------------------------------------------------------------------------ |
129 |
|
86 |
GlobalParams *globalParams = NULL; |
130 |
GlobalParams *globalParams = NULL; |
87 |
|
131 |
|
88 |
//------------------------------------------------------------------------ |
132 |
//------------------------------------------------------------------------ |
Lines 384-389
Link Here
|
384 |
} |
428 |
} |
385 |
} |
429 |
} |
386 |
|
430 |
|
|
|
431 |
//------------------------------------------------------------------------ |
432 |
// KeyBinding |
433 |
//------------------------------------------------------------------------ |
434 |
|
435 |
KeyBinding::KeyBinding(int codeA, int modsA, int contextA, char *cmd0) { |
436 |
code = codeA; |
437 |
mods = modsA; |
438 |
context = contextA; |
439 |
cmds = new GooList(); |
440 |
cmds->append(new GooString(cmd0)); |
441 |
} |
442 |
|
443 |
KeyBinding::KeyBinding(int codeA, int modsA, int contextA, |
444 |
char *cmd0, char *cmd1) { |
445 |
code = codeA; |
446 |
mods = modsA; |
447 |
context = contextA; |
448 |
cmds = new GooList(); |
449 |
cmds->append(new GooString(cmd0)); |
450 |
cmds->append(new GooString(cmd1)); |
451 |
} |
452 |
|
453 |
KeyBinding::KeyBinding(int codeA, int modsA, int contextA, GooList *cmdsA) { |
454 |
code = codeA; |
455 |
mods = modsA; |
456 |
context = contextA; |
457 |
cmds = cmdsA; |
458 |
} |
459 |
|
460 |
KeyBinding::~KeyBinding() { |
461 |
deleteGooList(cmds, GooString); |
462 |
} |
463 |
|
387 |
#ifdef ENABLE_PLUGINS |
464 |
#ifdef ENABLE_PLUGINS |
388 |
//------------------------------------------------------------------------ |
465 |
//------------------------------------------------------------------------ |
389 |
// Plugin |
466 |
// Plugin |
Lines 530-537
Link Here
|
530 |
// parsing |
607 |
// parsing |
531 |
//------------------------------------------------------------------------ |
608 |
//------------------------------------------------------------------------ |
532 |
|
609 |
|
533 |
GlobalParams::GlobalParams() { |
610 |
GlobalParams::GlobalParams(char *cfgFileName) { |
534 |
UnicodeMap *map; |
611 |
UnicodeMap *map; |
|
|
612 |
GooString *fileName; |
613 |
FILE *f; |
535 |
int i; |
614 |
int i; |
536 |
|
615 |
|
537 |
FcInit(); |
616 |
FcInit(); |
Lines 568-577
Link Here
|
568 |
cMapDirs = new GooHash(gTrue); |
647 |
cMapDirs = new GooHash(gTrue); |
569 |
toUnicodeDirs = new GooList(); |
648 |
toUnicodeDirs = new GooList(); |
570 |
displayFonts = new GooHash(); |
649 |
displayFonts = new GooHash(); |
|
|
650 |
displayCIDFonts = new GooHash(); |
651 |
displayNamedCIDFonts = new GooHash(); |
652 |
#if HAVE_PAPER_H |
653 |
char *paperName; |
654 |
const struct paper *paperType; |
655 |
paperinit(); |
656 |
if ((paperName = systempapername())) { |
657 |
paperType = paperinfo(paperName); |
658 |
psPaperWidth = (int)paperpswidth(paperType); |
659 |
psPaperHeight = (int)paperpsheight(paperType); |
660 |
} else { |
661 |
error(-1, "No paper information available - using defaults"); |
662 |
psPaperWidth = defPaperWidth; |
663 |
psPaperHeight = defPaperHeight; |
664 |
} |
665 |
paperdone(); |
666 |
#else |
667 |
psPaperWidth = defPaperWidth; |
668 |
psPaperHeight = defPaperHeight; |
669 |
#endif |
670 |
psImageableLLX = psImageableLLY = 0; |
671 |
psImageableURX = psPaperWidth; |
672 |
psImageableURY = psPaperHeight; |
673 |
psCrop = gTrue; |
571 |
psExpandSmaller = gFalse; |
674 |
psExpandSmaller = gFalse; |
572 |
psShrinkLarger = gTrue; |
675 |
psShrinkLarger = gTrue; |
573 |
psCenter = gTrue; |
676 |
psCenter = gTrue; |
|
|
677 |
psDuplex = gFalse; |
574 |
psLevel = psLevel2; |
678 |
psLevel = psLevel2; |
|
|
679 |
psFile = NULL; |
575 |
psFonts = new GooHash(); |
680 |
psFonts = new GooHash(); |
576 |
psNamedFonts16 = new GooList(); |
681 |
psNamedFonts16 = new GooList(); |
577 |
psFonts16 = new GooList(); |
682 |
psFonts16 = new GooList(); |
Lines 593-598
Link Here
|
593 |
textPageBreaks = gTrue; |
698 |
textPageBreaks = gTrue; |
594 |
textKeepTinyChars = gFalse; |
699 |
textKeepTinyChars = gFalse; |
595 |
fontDirs = new GooList(); |
700 |
fontDirs = new GooList(); |
|
|
701 |
initialZoom = new GooString("125"); |
702 |
continuousView = gFalse; |
703 |
enableT1lib = gTrue; |
596 |
enableFreeType = gTrue; |
704 |
enableFreeType = gTrue; |
597 |
antialias = gTrue; |
705 |
antialias = gTrue; |
598 |
vectorAntialias = gTrue; |
706 |
vectorAntialias = gTrue; |
Lines 603-610
Link Here
|
603 |
screenGamma = 1.0; |
711 |
screenGamma = 1.0; |
604 |
screenBlackThreshold = 0.0; |
712 |
screenBlackThreshold = 0.0; |
605 |
screenWhiteThreshold = 1.0; |
713 |
screenWhiteThreshold = 1.0; |
|
|
714 |
urlCommand = NULL; |
715 |
movieCommand = NULL; |
606 |
mapNumericCharNames = gTrue; |
716 |
mapNumericCharNames = gTrue; |
607 |
mapUnknownCharNames = gFalse; |
717 |
mapUnknownCharNames = gFalse; |
|
|
718 |
createDefaultKeyBindings(); |
608 |
printCommands = gFalse; |
719 |
printCommands = gFalse; |
609 |
profileCommands = gFalse; |
720 |
profileCommands = gFalse; |
610 |
errQuiet = gFalse; |
721 |
errQuiet = gFalse; |
Lines 619-653
Link Here
|
619 |
winFontList = NULL; |
730 |
winFontList = NULL; |
620 |
#endif |
731 |
#endif |
621 |
|
732 |
|
622 |
#ifdef ENABLE_PLUGINS |
733 |
#ifdef ENABLE_PLUGINS |
623 |
plugins = new GooList(); |
734 |
plugins = new GooList(); |
624 |
securityHandlers = new GooList(); |
735 |
securityHandlers = new GooList(); |
625 |
#endif |
736 |
#endif |
|
|
737 |
|
738 |
// set up the initial nameToUnicode table |
739 |
for (i = 0; nameToUnicodeTab[i].name; ++i) { |
740 |
nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u); |
741 |
} |
742 |
|
743 |
// set up the residentUnicodeMaps table |
744 |
map = new UnicodeMap("Latin1", gFalse, |
745 |
latin1UnicodeMapRanges, latin1UnicodeMapLen); |
746 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
747 |
map = new UnicodeMap("ASCII7", gFalse, |
748 |
ascii7UnicodeMapRanges, ascii7UnicodeMapLen); |
749 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
750 |
map = new UnicodeMap("Symbol", gFalse, |
751 |
symbolUnicodeMapRanges, symbolUnicodeMapLen); |
752 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
753 |
map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges, |
754 |
zapfDingbatsUnicodeMapLen); |
755 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
756 |
map = new UnicodeMap("UTF-8", gTrue, &mapUTF8); |
757 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
758 |
map = new UnicodeMap("UCS-2", gTrue, &mapUCS2); |
759 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
760 |
|
761 |
// look for a user config file, then a system-wide config file |
762 |
f = NULL; |
763 |
fileName = NULL; |
764 |
if (cfgFileName && cfgFileName[0]) { |
765 |
fileName = new GooString(cfgFileName); |
766 |
if (!(f = fopen(fileName->getCString(), "r"))) { |
767 |
delete fileName; |
768 |
} |
769 |
} else { |
770 |
scanEncodingDirs(); |
771 |
} |
772 |
if (!f) { |
773 |
fileName = appendToPath(getHomeDir(), xpdfUserConfigFile); |
774 |
if (!(f = fopen(fileName->getCString(), "r"))) { |
775 |
delete fileName; |
776 |
} |
777 |
} |
778 |
if (!f) { |
779 |
#if defined(WIN32) && !defined(__CYGWIN32__) |
780 |
char buf[512]; |
781 |
i = GetModuleFileName(NULL, buf, sizeof(buf)); |
782 |
if (i <= 0 || i >= sizeof(buf)) { |
783 |
// error or path too long for buffer - just use the current dir |
784 |
buf[0] = '\0'; |
785 |
} |
786 |
fileName = grabPath(buf); |
787 |
appendToPath(fileName, xpdfSysConfigFile); |
788 |
#else |
789 |
fileName = new GooString(xpdfSysConfigFile); |
790 |
#endif |
791 |
if (!(f = fopen(fileName->getCString(), "r"))) { |
792 |
delete fileName; |
793 |
} |
794 |
} |
795 |
if (f) { |
796 |
parseFile(fileName, f); |
797 |
delete fileName; |
798 |
fclose(f); |
799 |
} |
800 |
} |
801 |
|
802 |
void GlobalParams::createDefaultKeyBindings() { |
803 |
keyBindings = new GooList(); |
804 |
|
805 |
//----- mouse buttons |
806 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress1, xpdfKeyModNone, |
807 |
xpdfKeyContextAny, "startSelection")); |
808 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease1, xpdfKeyModNone, |
809 |
xpdfKeyContextAny, "endSelection", |
810 |
"followLinkNoSel")); |
811 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress2, xpdfKeyModNone, |
812 |
xpdfKeyContextAny, "startPan")); |
813 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease2, xpdfKeyModNone, |
814 |
xpdfKeyContextAny, "endPan")); |
815 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress3, xpdfKeyModNone, |
816 |
xpdfKeyContextAny, "postPopupMenu")); |
817 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress4, xpdfKeyModNone, |
818 |
xpdfKeyContextAny, |
819 |
"scrollUpPrevPage(16)")); |
820 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress5, xpdfKeyModNone, |
821 |
xpdfKeyContextAny, |
822 |
"scrollDownNextPage(16)")); |
823 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress6, xpdfKeyModNone, |
824 |
xpdfKeyContextAny, "scrollLeft(16)")); |
825 |
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress7, xpdfKeyModNone, |
826 |
xpdfKeyContextAny, "scrollRight(16)")); |
827 |
|
828 |
//----- keys |
829 |
keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModCtrl, |
830 |
xpdfKeyContextAny, "gotoPage(1)")); |
831 |
keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModNone, |
832 |
xpdfKeyContextAny, "scrollToTopLeft")); |
833 |
keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModCtrl, |
834 |
xpdfKeyContextAny, "gotoLastPage")); |
835 |
keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModNone, |
836 |
xpdfKeyContextAny, |
837 |
"scrollToBottomRight")); |
838 |
keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModNone, |
839 |
xpdfKeyContextAny, "pageUp")); |
840 |
keyBindings->append(new KeyBinding(xpdfKeyCodeBackspace, xpdfKeyModNone, |
841 |
xpdfKeyContextAny, "pageUp")); |
842 |
keyBindings->append(new KeyBinding(xpdfKeyCodeDelete, xpdfKeyModNone, |
843 |
xpdfKeyContextAny, "pageUp")); |
844 |
keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModNone, |
845 |
xpdfKeyContextAny, "pageDown")); |
846 |
keyBindings->append(new KeyBinding(' ', xpdfKeyModNone, |
847 |
xpdfKeyContextAny, "pageDown")); |
848 |
keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModNone, |
849 |
xpdfKeyContextAny, "scrollLeft(16)")); |
850 |
keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModNone, |
851 |
xpdfKeyContextAny, "scrollRight(16)")); |
852 |
keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModNone, |
853 |
xpdfKeyContextAny, "scrollUp(16)")); |
854 |
keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModNone, |
855 |
xpdfKeyContextAny, "scrollDown(16)")); |
856 |
keyBindings->append(new KeyBinding('o', xpdfKeyModNone, |
857 |
xpdfKeyContextAny, "open")); |
858 |
keyBindings->append(new KeyBinding('O', xpdfKeyModNone, |
859 |
xpdfKeyContextAny, "open")); |
860 |
keyBindings->append(new KeyBinding('r', xpdfKeyModNone, |
861 |
xpdfKeyContextAny, "reload")); |
862 |
keyBindings->append(new KeyBinding('R', xpdfKeyModNone, |
863 |
xpdfKeyContextAny, "reload")); |
864 |
keyBindings->append(new KeyBinding('f', xpdfKeyModNone, |
865 |
xpdfKeyContextAny, "find")); |
866 |
keyBindings->append(new KeyBinding('F', xpdfKeyModNone, |
867 |
xpdfKeyContextAny, "find")); |
868 |
keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl, |
869 |
xpdfKeyContextAny, "find")); |
870 |
keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl, |
871 |
xpdfKeyContextAny, "findNext")); |
872 |
keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl, |
873 |
xpdfKeyContextAny, "print")); |
874 |
keyBindings->append(new KeyBinding('n', xpdfKeyModNone, |
875 |
xpdfKeyContextScrLockOff, "nextPage")); |
876 |
keyBindings->append(new KeyBinding('N', xpdfKeyModNone, |
877 |
xpdfKeyContextScrLockOff, "nextPage")); |
878 |
keyBindings->append(new KeyBinding('n', xpdfKeyModNone, |
879 |
xpdfKeyContextScrLockOn, |
880 |
"nextPageNoScroll")); |
881 |
keyBindings->append(new KeyBinding('N', xpdfKeyModNone, |
882 |
xpdfKeyContextScrLockOn, |
883 |
"nextPageNoScroll")); |
884 |
keyBindings->append(new KeyBinding('p', xpdfKeyModNone, |
885 |
xpdfKeyContextScrLockOff, "prevPage")); |
886 |
keyBindings->append(new KeyBinding('P', xpdfKeyModNone, |
887 |
xpdfKeyContextScrLockOff, "prevPage")); |
888 |
keyBindings->append(new KeyBinding('p', xpdfKeyModNone, |
889 |
xpdfKeyContextScrLockOn, |
890 |
"prevPageNoScroll")); |
891 |
keyBindings->append(new KeyBinding('P', xpdfKeyModNone, |
892 |
xpdfKeyContextScrLockOn, |
893 |
"prevPageNoScroll")); |
894 |
keyBindings->append(new KeyBinding('v', xpdfKeyModNone, |
895 |
xpdfKeyContextAny, "goForward")); |
896 |
keyBindings->append(new KeyBinding('b', xpdfKeyModNone, |
897 |
xpdfKeyContextAny, "goBackward")); |
898 |
keyBindings->append(new KeyBinding('g', xpdfKeyModNone, |
899 |
xpdfKeyContextAny, "focusToPageNum")); |
900 |
keyBindings->append(new KeyBinding('0', xpdfKeyModNone, |
901 |
xpdfKeyContextAny, "zoomPercent(125)")); |
902 |
keyBindings->append(new KeyBinding('+', xpdfKeyModNone, |
903 |
xpdfKeyContextAny, "zoomIn")); |
904 |
keyBindings->append(new KeyBinding('-', xpdfKeyModNone, |
905 |
xpdfKeyContextAny, "zoomOut")); |
906 |
keyBindings->append(new KeyBinding('z', xpdfKeyModNone, |
907 |
xpdfKeyContextAny, "zoomFitPage")); |
908 |
keyBindings->append(new KeyBinding('w', xpdfKeyModNone, |
909 |
xpdfKeyContextAny, "zoomFitWidth")); |
910 |
keyBindings->append(new KeyBinding('f', xpdfKeyModAlt, |
911 |
xpdfKeyContextAny, |
912 |
"toggleFullScreenMode")); |
913 |
keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl, |
914 |
xpdfKeyContextAny, "redraw")); |
915 |
keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl, |
916 |
xpdfKeyContextAny, "closeWindow")); |
917 |
keyBindings->append(new KeyBinding('?', xpdfKeyModNone, |
918 |
xpdfKeyContextAny, "about")); |
919 |
keyBindings->append(new KeyBinding('q', xpdfKeyModNone, |
920 |
xpdfKeyContextAny, "quit")); |
921 |
keyBindings->append(new KeyBinding('Q', xpdfKeyModNone, |
922 |
xpdfKeyContextAny, "quit")); |
923 |
} |
924 |
|
925 |
void GlobalParams::parseFile(GooString *fileName, FILE *f) { |
926 |
int line; |
927 |
char buf[512]; |
928 |
|
929 |
line = 1; |
930 |
while (getLine(buf, sizeof(buf) - 1, f)) { |
931 |
parseLine(buf, fileName, line); |
932 |
++line; |
933 |
} |
934 |
} |
935 |
|
936 |
void GlobalParams::parseLine(char *buf, GooString *fileName, int line) { |
937 |
GooList *tokens; |
938 |
GooString *cmd, *incFile; |
939 |
char *p1, *p2; |
940 |
FILE *f2; |
941 |
|
942 |
// break the line into tokens |
943 |
tokens = new GooList(); |
944 |
p1 = buf; |
945 |
while (*p1) { |
946 |
for (; *p1 && isspace(*p1); ++p1) ; |
947 |
if (!*p1) { |
948 |
break; |
949 |
} |
950 |
if (*p1 == '"' || *p1 == '\'') { |
951 |
for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ; |
952 |
++p1; |
953 |
} else { |
954 |
for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ; |
955 |
} |
956 |
tokens->append(new GooString(p1, p2 - p1)); |
957 |
p1 = *p2 ? p2 + 1 : p2; |
958 |
} |
959 |
|
960 |
// parse the line |
961 |
if (tokens->getLength() > 0 && |
962 |
((GooString *)tokens->get(0))->getChar(0) != '#') { |
963 |
cmd = (GooString *)tokens->get(0); |
964 |
if (!cmd->cmp("include")) { |
965 |
if (tokens->getLength() == 2) { |
966 |
incFile = (GooString *)tokens->get(1); |
967 |
if ((f2 = fopen(incFile->getCString(), "r"))) { |
968 |
parseFile(incFile, f2); |
969 |
fclose(f2); |
970 |
} else { |
971 |
error(-1, "Couldn't find included config file: '%s' (%s:%d)", |
972 |
incFile->getCString(), fileName->getCString(), line); |
973 |
} |
974 |
} else { |
975 |
error(-1, "Bad 'include' config file command (%s:%d)", |
976 |
fileName->getCString(), line); |
977 |
} |
978 |
} else if (!cmd->cmp("nameToUnicode")) { |
979 |
parseNameToUnicode(tokens, fileName, line); |
980 |
} else if (!cmd->cmp("cidToUnicode")) { |
981 |
parseCIDToUnicode(tokens, fileName, line); |
982 |
} else if (!cmd->cmp("unicodeToUnicode")) { |
983 |
parseUnicodeToUnicode(tokens, fileName, line); |
984 |
} else if (!cmd->cmp("unicodeMap")) { |
985 |
parseUnicodeMap(tokens, fileName, line); |
986 |
} else if (!cmd->cmp("cMapDir")) { |
987 |
parseCMapDir(tokens, fileName, line); |
988 |
} else if (!cmd->cmp("toUnicodeDir")) { |
989 |
parseToUnicodeDir(tokens, fileName, line); |
990 |
} else if (!cmd->cmp("displayFontT1")) { |
991 |
parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line); |
992 |
} else if (!cmd->cmp("displayFontTT")) { |
993 |
parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line); |
994 |
} else if (!cmd->cmp("displayNamedCIDFontT1")) { |
995 |
parseDisplayFont(tokens, displayNamedCIDFonts, |
996 |
displayFontT1, fileName, line); |
997 |
} else if (!cmd->cmp("displayCIDFontT1")) { |
998 |
parseDisplayFont(tokens, displayCIDFonts, |
999 |
displayFontT1, fileName, line); |
1000 |
} else if (!cmd->cmp("displayNamedCIDFontTT")) { |
1001 |
parseDisplayFont(tokens, displayNamedCIDFonts, |
1002 |
displayFontTT, fileName, line); |
1003 |
} else if (!cmd->cmp("displayCIDFontTT")) { |
1004 |
parseDisplayFont(tokens, displayCIDFonts, |
1005 |
displayFontTT, fileName, line); |
1006 |
} else if (!cmd->cmp("psFile")) { |
1007 |
parsePSFile(tokens, fileName, line); |
1008 |
} else if (!cmd->cmp("psFont")) { |
1009 |
parsePSFont(tokens, fileName, line); |
1010 |
} else if (!cmd->cmp("psNamedFont16")) { |
1011 |
parsePSFont16("psNamedFont16", psNamedFonts16, |
1012 |
tokens, fileName, line); |
1013 |
} else if (!cmd->cmp("psFont16")) { |
1014 |
parsePSFont16("psFont16", psFonts16, tokens, fileName, line); |
1015 |
} else if (!cmd->cmp("psPaperSize")) { |
1016 |
parsePSPaperSize(tokens, fileName, line); |
1017 |
} else if (!cmd->cmp("psImageableArea")) { |
1018 |
parsePSImageableArea(tokens, fileName, line); |
1019 |
} else if (!cmd->cmp("psCrop")) { |
1020 |
parseYesNo("psCrop", &psCrop, tokens, fileName, line); |
1021 |
} else if (!cmd->cmp("psExpandSmaller")) { |
1022 |
parseYesNo("psExpandSmaller", &psExpandSmaller, |
1023 |
tokens, fileName, line); |
1024 |
} else if (!cmd->cmp("psShrinkLarger")) { |
1025 |
parseYesNo("psShrinkLarger", &psShrinkLarger, tokens, fileName, line); |
1026 |
} else if (!cmd->cmp("psCenter")) { |
1027 |
parseYesNo("psCenter", &psCenter, tokens, fileName, line); |
1028 |
} else if (!cmd->cmp("psDuplex")) { |
1029 |
parseYesNo("psDuplex", &psDuplex, tokens, fileName, line); |
1030 |
} else if (!cmd->cmp("psLevel")) { |
1031 |
parsePSLevel(tokens, fileName, line); |
1032 |
} else if (!cmd->cmp("psEmbedType1Fonts")) { |
1033 |
parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line); |
1034 |
} else if (!cmd->cmp("psEmbedTrueTypeFonts")) { |
1035 |
parseYesNo("psEmbedTrueType", &psEmbedTrueType, |
1036 |
tokens, fileName, line); |
1037 |
} else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) { |
1038 |
parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript, |
1039 |
tokens, fileName, line); |
1040 |
} else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) { |
1041 |
parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType, |
1042 |
tokens, fileName, line); |
1043 |
} else if (!cmd->cmp("psPreload")) { |
1044 |
parseYesNo("psPreload", &psPreload, tokens, fileName, line); |
1045 |
} else if (!cmd->cmp("psOPI")) { |
1046 |
parseYesNo("psOPI", &psOPI, tokens, fileName, line); |
1047 |
} else if (!cmd->cmp("psASCIIHex")) { |
1048 |
parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line); |
1049 |
} else if (!cmd->cmp("textEncoding")) { |
1050 |
parseTextEncoding(tokens, fileName, line); |
1051 |
} else if (!cmd->cmp("textEOL")) { |
1052 |
parseTextEOL(tokens, fileName, line); |
1053 |
} else if (!cmd->cmp("textPageBreaks")) { |
1054 |
parseYesNo("textPageBreaks", &textPageBreaks, |
1055 |
tokens, fileName, line); |
1056 |
} else if (!cmd->cmp("textKeepTinyChars")) { |
1057 |
parseYesNo("textKeepTinyChars", &textKeepTinyChars, |
1058 |
tokens, fileName, line); |
1059 |
} else if (!cmd->cmp("fontDir")) { |
1060 |
parseFontDir(tokens, fileName, line); |
1061 |
} else if (!cmd->cmp("initialZoom")) { |
1062 |
parseInitialZoom(tokens, fileName, line); |
1063 |
} else if (!cmd->cmp("continuousView")) { |
1064 |
parseYesNo("continuousView", &continuousView, tokens, fileName, line); |
1065 |
} else if (!cmd->cmp("enableT1lib")) { |
1066 |
parseYesNo("enableT1lib", &enableT1lib, tokens, fileName, line); |
1067 |
} else if (!cmd->cmp("enableFreeType")) { |
1068 |
parseYesNo("enableFreeType", &enableFreeType, tokens, fileName, line); |
1069 |
} else if (!cmd->cmp("antialias")) { |
1070 |
parseYesNo("antialias", &antialias, tokens, fileName, line); |
1071 |
} else if (!cmd->cmp("vectorAntialias")) { |
1072 |
parseYesNo("vectorAntialias", &vectorAntialias, |
1073 |
tokens, fileName, line); |
1074 |
} else if (!cmd->cmp("strokeAdjust")) { |
1075 |
parseYesNo("strokeAdjust", &strokeAdjust, tokens, fileName, line); |
1076 |
} else if (!cmd->cmp("screenType")) { |
1077 |
parseScreenType(tokens, fileName, line); |
1078 |
} else if (!cmd->cmp("screenSize")) { |
1079 |
parseInteger("screenSize", &screenSize, tokens, fileName, line); |
1080 |
} else if (!cmd->cmp("screenDotRadius")) { |
1081 |
parseInteger("screenDotRadius", &screenDotRadius, |
1082 |
tokens, fileName, line); |
1083 |
} else if (!cmd->cmp("screenGamma")) { |
1084 |
parseFloat("screenGamma", &screenGamma, |
1085 |
tokens, fileName, line); |
1086 |
} else if (!cmd->cmp("screenBlackThreshold")) { |
1087 |
parseFloat("screenBlackThreshold", &screenBlackThreshold, |
1088 |
tokens, fileName, line); |
1089 |
} else if (!cmd->cmp("screenWhiteThreshold")) { |
1090 |
parseFloat("screenWhiteThreshold", &screenWhiteThreshold, |
1091 |
tokens, fileName, line); |
1092 |
} else if (!cmd->cmp("urlCommand")) { |
1093 |
parseCommand("urlCommand", &urlCommand, tokens, fileName, line); |
1094 |
} else if (!cmd->cmp("movieCommand")) { |
1095 |
parseCommand("movieCommand", &movieCommand, tokens, fileName, line); |
1096 |
} else if (!cmd->cmp("mapNumericCharNames")) { |
1097 |
parseYesNo("mapNumericCharNames", &mapNumericCharNames, |
1098 |
tokens, fileName, line); |
1099 |
} else if (!cmd->cmp("mapUnknownCharNames")) { |
1100 |
parseYesNo("mapUnknownCharNames", &mapUnknownCharNames, |
1101 |
tokens, fileName, line); |
1102 |
} else if (!cmd->cmp("bind")) { |
1103 |
parseBind(tokens, fileName, line); |
1104 |
} else if (!cmd->cmp("unbind")) { |
1105 |
parseUnbind(tokens, fileName, line); |
1106 |
} else if (!cmd->cmp("printCommands")) { |
1107 |
parseYesNo("printCommands", &printCommands, tokens, fileName, line); |
1108 |
} else if (!cmd->cmp("errQuiet")) { |
1109 |
parseYesNo("errQuiet", &errQuiet, tokens, fileName, line); |
1110 |
} else { |
1111 |
error(-1, "Unknown config file command '%s' (%s:%d)", |
1112 |
cmd->getCString(), fileName->getCString(), line); |
1113 |
if (!cmd->cmp("displayFontX") || |
1114 |
!cmd->cmp("displayNamedCIDFontX") || |
1115 |
!cmd->cmp("displayCIDFontX")) { |
1116 |
error(-1, "-- Xpdf no longer supports X fonts"); |
1117 |
} else if (!cmd->cmp("t1libControl") || !cmd->cmp("freetypeControl")) { |
1118 |
error(-1, "-- The t1libControl and freetypeControl options have been replaced"); |
1119 |
error(-1, " by the enableT1lib, enableFreeType, and antialias options"); |
1120 |
} else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) { |
1121 |
error(-1, "-- the config file format has changed since Xpdf 0.9x"); |
1122 |
} |
1123 |
} |
1124 |
} |
1125 |
|
1126 |
deleteGooList(tokens, GooString); |
1127 |
} |
1128 |
|
1129 |
void GlobalParams::parseNameToUnicode(GooList *tokens, GooString *fileName, |
1130 |
int line) { |
1131 |
GooString *name; |
1132 |
char *tok1, *tok2; |
1133 |
FILE *f; |
1134 |
char buf[256]; |
1135 |
int line2; |
1136 |
Unicode u; |
1137 |
|
1138 |
if (tokens->getLength() != 2) { |
1139 |
error(-1, "Bad 'nameToUnicode' config file command (%s:%d)", |
1140 |
fileName->getCString(), line); |
1141 |
return; |
1142 |
} |
1143 |
name = (GooString *)tokens->get(1); |
1144 |
if (!(f = fopen(name->getCString(), "r"))) { |
1145 |
error(-1, "Couldn't open 'nameToUnicode' file '%s'", |
1146 |
name->getCString()); |
1147 |
return; |
1148 |
} |
1149 |
line2 = 1; |
1150 |
while (getLine(buf, sizeof(buf), f)) { |
1151 |
tok1 = strtok(buf, " \t\r\n"); |
1152 |
tok2 = strtok(NULL, " \t\r\n"); |
1153 |
if (tok1 && tok2) { |
1154 |
sscanf(tok1, "%x", &u); |
1155 |
nameToUnicode->add(tok2, u); |
1156 |
} else { |
1157 |
error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", |
1158 |
name->getCString(), line2); |
1159 |
} |
1160 |
++line2; |
1161 |
} |
1162 |
fclose(f); |
1163 |
} |
1164 |
|
1165 |
void GlobalParams::parseNameToUnicode(GooString *name) { |
1166 |
char *tok1, *tok2; |
1167 |
FILE *f; |
1168 |
char buf[256]; |
1169 |
int line; |
1170 |
Unicode u; |
1171 |
|
1172 |
if (!(f = fopen(name->getCString(), "r"))) { |
1173 |
error(-1, "Couldn't open 'nameToUnicode' file '%s'", |
1174 |
name->getCString()); |
1175 |
return; |
1176 |
} |
1177 |
line = 1; |
1178 |
while (getLine(buf, sizeof(buf), f)) { |
1179 |
tok1 = strtok(buf, " \t\r\n"); |
1180 |
tok2 = strtok(NULL, " \t\r\n"); |
1181 |
if (tok1 && tok2) { |
1182 |
sscanf(tok1, "%x", &u); |
1183 |
nameToUnicode->add(tok2, u); |
1184 |
} else { |
1185 |
error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", |
1186 |
name->getCString(), line); |
1187 |
} |
1188 |
++line; |
1189 |
} |
1190 |
fclose(f); |
1191 |
} |
1192 |
|
1193 |
void GlobalParams::parseCIDToUnicode(GooList *tokens, GooString *fileName, |
1194 |
int line) { |
1195 |
GooString *collection, *name, *old; |
1196 |
|
1197 |
if (tokens->getLength() != 3) { |
1198 |
error(-1, "Bad 'cidToUnicode' config file command (%s:%d)", |
1199 |
fileName->getCString(), line); |
1200 |
return; |
1201 |
} |
1202 |
collection = (GooString *)tokens->get(1); |
1203 |
name = (GooString *)tokens->get(2); |
1204 |
if ((old = (GooString *)cidToUnicodes->remove(collection))) { |
1205 |
delete old; |
1206 |
} |
1207 |
cidToUnicodes->add(collection->copy(), name->copy()); |
1208 |
} |
1209 |
|
1210 |
void GlobalParams::parseUnicodeToUnicode(GooList *tokens, GooString *fileName, |
1211 |
int line) { |
1212 |
GooString *font, *file, *old; |
1213 |
|
1214 |
if (tokens->getLength() != 3) { |
1215 |
error(-1, "Bad 'unicodeToUnicode' config file command (%s:%d)", |
1216 |
fileName->getCString(), line); |
1217 |
return; |
1218 |
} |
1219 |
font = (GooString *)tokens->get(1); |
1220 |
file = (GooString *)tokens->get(2); |
1221 |
if ((old = (GooString *)unicodeToUnicodes->remove(font))) { |
1222 |
delete old; |
1223 |
} |
1224 |
unicodeToUnicodes->add(font->copy(), file->copy()); |
1225 |
} |
1226 |
|
1227 |
void GlobalParams::parseUnicodeMap(GooList *tokens, GooString *fileName, |
1228 |
int line) { |
1229 |
GooString *encodingName, *name, *old; |
1230 |
|
1231 |
if (tokens->getLength() != 3) { |
1232 |
error(-1, "Bad 'unicodeMap' config file command (%s:%d)", |
1233 |
fileName->getCString(), line); |
1234 |
return; |
1235 |
} |
1236 |
encodingName = (GooString *)tokens->get(1); |
1237 |
name = (GooString *)tokens->get(2); |
1238 |
if ((old = (GooString *)unicodeMaps->remove(encodingName))) { |
1239 |
delete old; |
1240 |
} |
1241 |
unicodeMaps->add(encodingName->copy(), name->copy()); |
1242 |
} |
1243 |
|
1244 |
void GlobalParams::parseCMapDir(GooList *tokens, GooString *fileName, int line) { |
1245 |
GooString *collection, *dir; |
1246 |
GooList *list; |
1247 |
|
1248 |
if (tokens->getLength() != 3) { |
1249 |
error(-1, "Bad 'cMapDir' config file command (%s:%d)", |
1250 |
fileName->getCString(), line); |
1251 |
return; |
1252 |
} |
1253 |
collection = (GooString *)tokens->get(1); |
1254 |
dir = (GooString *)tokens->get(2); |
1255 |
if (!(list = (GooList *)cMapDirs->lookup(collection))) { |
1256 |
list = new GooList(); |
1257 |
cMapDirs->add(collection->copy(), list); |
1258 |
} |
1259 |
list->append(dir->copy()); |
1260 |
} |
1261 |
|
1262 |
void GlobalParams::parseToUnicodeDir(GooList *tokens, GooString *fileName, |
1263 |
int line) { |
1264 |
if (tokens->getLength() != 2) { |
1265 |
error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)", |
1266 |
fileName->getCString(), line); |
1267 |
return; |
1268 |
} |
1269 |
toUnicodeDirs->append(((GooString *)tokens->get(1))->copy()); |
1270 |
} |
1271 |
|
1272 |
void GlobalParams::parseDisplayFont(GooList *tokens, GooHash *fontHash, |
1273 |
DisplayFontParamKind kind, |
1274 |
GooString *fileName, int line) { |
1275 |
DisplayFontParam *param, *old; |
1276 |
|
1277 |
if (tokens->getLength() < 2) { |
1278 |
goto err1; |
1279 |
} |
1280 |
param = new DisplayFontParam(((GooString *)tokens->get(1))->copy(), kind); |
1281 |
|
1282 |
switch (kind) { |
1283 |
case displayFontT1: |
1284 |
if (tokens->getLength() != 3) { |
1285 |
goto err2; |
1286 |
} |
1287 |
param->t1.fileName = ((GooString *)tokens->get(2))->copy(); |
1288 |
break; |
1289 |
case displayFontTT: |
1290 |
if (tokens->getLength() != 3) { |
1291 |
goto err2; |
1292 |
} |
1293 |
param->tt.fileName = ((GooString *)tokens->get(2))->copy(); |
1294 |
break; |
1295 |
} |
1296 |
|
1297 |
if ((old = (DisplayFontParam *)fontHash->remove(param->name))) { |
1298 |
delete old; |
1299 |
} |
1300 |
fontHash->add(param->name, param); |
1301 |
return; |
1302 |
|
1303 |
err2: |
1304 |
delete param; |
1305 |
err1: |
1306 |
error(-1, "Bad 'display*Font*' config file command (%s:%d)", |
1307 |
fileName->getCString(), line); |
1308 |
} |
1309 |
|
1310 |
void GlobalParams::parsePSPaperSize(GooList *tokens, GooString *fileName, |
1311 |
int line) { |
1312 |
GooString *tok; |
1313 |
|
1314 |
if (tokens->getLength() == 2) { |
1315 |
tok = (GooString *)tokens->get(1); |
1316 |
if (!setPSPaperSize(tok->getCString())) { |
1317 |
error(-1, "Bad 'psPaperSize' config file command (%s:%d)", |
1318 |
fileName->getCString(), line); |
1319 |
} |
1320 |
} else if (tokens->getLength() == 3) { |
1321 |
tok = (GooString *)tokens->get(1); |
1322 |
psPaperWidth = atoi(tok->getCString()); |
1323 |
tok = (GooString *)tokens->get(2); |
1324 |
psPaperHeight = atoi(tok->getCString()); |
1325 |
psImageableLLX = psImageableLLY = 0; |
1326 |
psImageableURX = psPaperWidth; |
1327 |
psImageableURY = psPaperHeight; |
1328 |
} else { |
1329 |
error(-1, "Bad 'psPaperSize' config file command (%s:%d)", |
1330 |
fileName->getCString(), line); |
1331 |
} |
1332 |
} |
1333 |
|
1334 |
void GlobalParams::parsePSImageableArea(GooList *tokens, GooString *fileName, |
1335 |
int line) { |
1336 |
if (tokens->getLength() != 5) { |
1337 |
error(-1, "Bad 'psImageableArea' config file command (%s:%d)", |
1338 |
fileName->getCString(), line); |
1339 |
return; |
1340 |
} |
1341 |
psImageableLLX = atoi(((GooString *)tokens->get(1))->getCString()); |
1342 |
psImageableLLY = atoi(((GooString *)tokens->get(2))->getCString()); |
1343 |
psImageableURX = atoi(((GooString *)tokens->get(3))->getCString()); |
1344 |
psImageableURY = atoi(((GooString *)tokens->get(4))->getCString()); |
1345 |
} |
1346 |
|
1347 |
void GlobalParams::parsePSLevel(GooList *tokens, GooString *fileName, int line) { |
1348 |
GooString *tok; |
1349 |
|
1350 |
if (tokens->getLength() != 2) { |
1351 |
error(-1, "Bad 'psLevel' config file command (%s:%d)", |
1352 |
fileName->getCString(), line); |
1353 |
return; |
1354 |
} |
1355 |
tok = (GooString *)tokens->get(1); |
1356 |
if (!tok->cmp("level1")) { |
1357 |
psLevel = psLevel1; |
1358 |
} else if (!tok->cmp("level1sep")) { |
1359 |
psLevel = psLevel1Sep; |
1360 |
} else if (!tok->cmp("level2")) { |
1361 |
psLevel = psLevel2; |
1362 |
} else if (!tok->cmp("level2sep")) { |
1363 |
psLevel = psLevel2Sep; |
1364 |
} else if (!tok->cmp("level3")) { |
1365 |
psLevel = psLevel3; |
1366 |
} else if (!tok->cmp("level3Sep")) { |
1367 |
psLevel = psLevel3Sep; |
1368 |
} else { |
1369 |
error(-1, "Bad 'psLevel' config file command (%s:%d)", |
1370 |
fileName->getCString(), line); |
1371 |
} |
1372 |
} |
1373 |
|
1374 |
void GlobalParams::parsePSFile(GooList *tokens, GooString *fileName, int line) { |
1375 |
if (tokens->getLength() != 2) { |
1376 |
error(-1, "Bad 'psFile' config file command (%s:%d)", |
1377 |
fileName->getCString(), line); |
1378 |
return; |
1379 |
} |
1380 |
if (psFile) { |
1381 |
delete psFile; |
1382 |
} |
1383 |
psFile = ((GooString *)tokens->get(1))->copy(); |
1384 |
} |
1385 |
|
1386 |
void GlobalParams::parsePSFont(GooList *tokens, GooString *fileName, int line) { |
1387 |
PSFontParam *param; |
1388 |
|
1389 |
if (tokens->getLength() != 3) { |
1390 |
error(-1, "Bad 'psFont' config file command (%s:%d)", |
1391 |
fileName->getCString(), line); |
1392 |
return; |
1393 |
} |
1394 |
param = new PSFontParam(((GooString *)tokens->get(1))->copy(), 0, |
1395 |
((GooString *)tokens->get(2))->copy(), NULL); |
1396 |
psFonts->add(param->pdfFontName, param); |
1397 |
} |
1398 |
|
1399 |
void GlobalParams::parsePSFont16(char *cmdName, GooList *fontList, |
1400 |
GooList *tokens, GooString *fileName, int line) { |
1401 |
PSFontParam *param; |
1402 |
int wMode; |
1403 |
GooString *tok; |
1404 |
|
1405 |
if (tokens->getLength() != 5) { |
1406 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1407 |
cmdName, fileName->getCString(), line); |
1408 |
return; |
1409 |
} |
1410 |
tok = (GooString *)tokens->get(2); |
1411 |
if (!tok->cmp("H")) { |
1412 |
wMode = 0; |
1413 |
} else if (!tok->cmp("V")) { |
1414 |
wMode = 1; |
1415 |
} else { |
1416 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1417 |
cmdName, fileName->getCString(), line); |
1418 |
return; |
1419 |
} |
1420 |
param = new PSFontParam(((GooString *)tokens->get(1))->copy(), |
1421 |
wMode, |
1422 |
((GooString *)tokens->get(3))->copy(), |
1423 |
((GooString *)tokens->get(4))->copy()); |
1424 |
fontList->append(param); |
1425 |
} |
1426 |
|
1427 |
void GlobalParams::parseTextEncoding(GooList *tokens, GooString *fileName, |
1428 |
int line) { |
1429 |
if (tokens->getLength() != 2) { |
1430 |
error(-1, "Bad 'textEncoding' config file command (%s:%d)", |
1431 |
fileName->getCString(), line); |
1432 |
return; |
1433 |
} |
1434 |
delete textEncoding; |
1435 |
textEncoding = ((GooString *)tokens->get(1))->copy(); |
1436 |
} |
1437 |
|
1438 |
void GlobalParams::parseTextEOL(GooList *tokens, GooString *fileName, int line) { |
1439 |
GooString *tok; |
1440 |
|
1441 |
if (tokens->getLength() != 2) { |
1442 |
error(-1, "Bad 'textEOL' config file command (%s:%d)", |
1443 |
fileName->getCString(), line); |
1444 |
return; |
1445 |
} |
1446 |
tok = (GooString *)tokens->get(1); |
1447 |
if (!tok->cmp("unix")) { |
1448 |
textEOL = eolUnix; |
1449 |
} else if (!tok->cmp("dos")) { |
1450 |
textEOL = eolDOS; |
1451 |
} else if (!tok->cmp("mac")) { |
1452 |
textEOL = eolMac; |
1453 |
} else { |
1454 |
error(-1, "Bad 'textEOL' config file command (%s:%d)", |
1455 |
fileName->getCString(), line); |
1456 |
} |
1457 |
} |
1458 |
|
1459 |
void GlobalParams::parseFontDir(GooList *tokens, GooString *fileName, int line) { |
1460 |
if (tokens->getLength() != 2) { |
1461 |
error(-1, "Bad 'fontDir' config file command (%s:%d)", |
1462 |
fileName->getCString(), line); |
1463 |
return; |
1464 |
} |
1465 |
fontDirs->append(((GooString *)tokens->get(1))->copy()); |
1466 |
} |
1467 |
|
1468 |
void GlobalParams::parseInitialZoom(GooList *tokens, |
1469 |
GooString *fileName, int line) { |
1470 |
if (tokens->getLength() != 2) { |
1471 |
error(-1, "Bad 'initialZoom' config file command (%s:%d)", |
1472 |
fileName->getCString(), line); |
1473 |
return; |
1474 |
} |
1475 |
delete initialZoom; |
1476 |
initialZoom = ((GooString *)tokens->get(1))->copy(); |
1477 |
} |
1478 |
|
1479 |
void GlobalParams::parseScreenType(GooList *tokens, GooString *fileName, |
1480 |
int line) { |
1481 |
GooString *tok; |
1482 |
|
1483 |
if (tokens->getLength() != 2) { |
1484 |
error(-1, "Bad 'screenType' config file command (%s:%d)", |
1485 |
fileName->getCString(), line); |
1486 |
return; |
1487 |
} |
1488 |
tok = (GooString *)tokens->get(1); |
1489 |
if (!tok->cmp("dispersed")) { |
1490 |
screenType = screenDispersed; |
1491 |
} else if (!tok->cmp("clustered")) { |
1492 |
screenType = screenClustered; |
1493 |
} else if (!tok->cmp("stochasticClustered")) { |
1494 |
screenType = screenStochasticClustered; |
1495 |
} else { |
1496 |
error(-1, "Bad 'screenType' config file command (%s:%d)", |
1497 |
fileName->getCString(), line); |
1498 |
} |
1499 |
} |
1500 |
|
1501 |
void GlobalParams::parseBind(GooList *tokens, GooString *fileName, int line) { |
1502 |
KeyBinding *binding; |
1503 |
GooList *cmds; |
1504 |
int code, mods, context, i; |
1505 |
|
1506 |
if (tokens->getLength() < 4) { |
1507 |
error(-1, "Bad 'bind' config file command (%s:%d)", |
1508 |
fileName->getCString(), line); |
1509 |
return; |
1510 |
} |
1511 |
if (!parseKey((GooString *)tokens->get(1), (GooString *)tokens->get(2), |
1512 |
&code, &mods, &context, |
1513 |
"bind", tokens, fileName, line)) { |
1514 |
return; |
1515 |
} |
1516 |
for (i = 0; i < keyBindings->getLength(); ++i) { |
1517 |
binding = (KeyBinding *)keyBindings->get(i); |
1518 |
if (binding->code == code && |
1519 |
binding->mods == mods && |
1520 |
binding->context == context) { |
1521 |
delete (KeyBinding *)keyBindings->del(i); |
1522 |
break; |
1523 |
} |
1524 |
} |
1525 |
cmds = new GooList(); |
1526 |
for (i = 3; i < tokens->getLength(); ++i) { |
1527 |
cmds->append(((GooString *)tokens->get(i))->copy()); |
1528 |
} |
1529 |
keyBindings->append(new KeyBinding(code, mods, context, cmds)); |
1530 |
} |
1531 |
|
1532 |
void GlobalParams::parseUnbind(GooList *tokens, GooString *fileName, int line) { |
1533 |
KeyBinding *binding; |
1534 |
int code, mods, context, i; |
1535 |
|
1536 |
if (tokens->getLength() != 3) { |
1537 |
error(-1, "Bad 'unbind' config file command (%s:%d)", |
1538 |
fileName->getCString(), line); |
1539 |
return; |
1540 |
} |
1541 |
if (!parseKey((GooString *)tokens->get(1), (GooString *)tokens->get(2), |
1542 |
&code, &mods, &context, |
1543 |
"unbind", tokens, fileName, line)) { |
1544 |
return; |
1545 |
} |
1546 |
for (i = 0; i < keyBindings->getLength(); ++i) { |
1547 |
binding = (KeyBinding *)keyBindings->get(i); |
1548 |
if (binding->code == code && |
1549 |
binding->mods == mods && |
1550 |
binding->context == context) { |
1551 |
delete (KeyBinding *)keyBindings->del(i); |
1552 |
break; |
1553 |
} |
1554 |
} |
1555 |
} |
1556 |
|
1557 |
GBool GlobalParams::parseKey(GooString *modKeyStr, GooString *contextStr, |
1558 |
int *code, int *mods, int *context, |
1559 |
char *cmdName, |
1560 |
GooList *tokens, GooString *fileName, int line) { |
1561 |
char *p0; |
1562 |
|
1563 |
*mods = xpdfKeyModNone; |
1564 |
p0 = modKeyStr->getCString(); |
1565 |
while (1) { |
1566 |
if (!strncmp(p0, "shift-", 6)) { |
1567 |
*mods |= xpdfKeyModShift; |
1568 |
p0 += 6; |
1569 |
} else if (!strncmp(p0, "ctrl-", 5)) { |
1570 |
*mods |= xpdfKeyModCtrl; |
1571 |
p0 += 5; |
1572 |
} else if (!strncmp(p0, "alt-", 4)) { |
1573 |
*mods |= xpdfKeyModAlt; |
1574 |
p0 += 4; |
1575 |
} else { |
1576 |
break; |
1577 |
} |
1578 |
} |
1579 |
|
1580 |
if (!strcmp(p0, "space")) { |
1581 |
*code = ' '; |
1582 |
} else if (!strcmp(p0, "tab")) { |
1583 |
*code = xpdfKeyCodeTab; |
1584 |
} else if (!strcmp(p0, "return")) { |
1585 |
*code = xpdfKeyCodeReturn; |
1586 |
} else if (!strcmp(p0, "enter")) { |
1587 |
*code = xpdfKeyCodeEnter; |
1588 |
} else if (!strcmp(p0, "backspace")) { |
1589 |
*code = xpdfKeyCodeBackspace; |
1590 |
} else if (!strcmp(p0, "insert")) { |
1591 |
*code = xpdfKeyCodeInsert; |
1592 |
} else if (!strcmp(p0, "delete")) { |
1593 |
*code = xpdfKeyCodeDelete; |
1594 |
} else if (!strcmp(p0, "home")) { |
1595 |
*code = xpdfKeyCodeHome; |
1596 |
} else if (!strcmp(p0, "end")) { |
1597 |
*code = xpdfKeyCodeEnd; |
1598 |
} else if (!strcmp(p0, "pgup")) { |
1599 |
*code = xpdfKeyCodePgUp; |
1600 |
} else if (!strcmp(p0, "pgdn")) { |
1601 |
*code = xpdfKeyCodePgDn; |
1602 |
} else if (!strcmp(p0, "left")) { |
1603 |
*code = xpdfKeyCodeLeft; |
1604 |
} else if (!strcmp(p0, "right")) { |
1605 |
*code = xpdfKeyCodeRight; |
1606 |
} else if (!strcmp(p0, "up")) { |
1607 |
*code = xpdfKeyCodeUp; |
1608 |
} else if (!strcmp(p0, "down")) { |
1609 |
*code = xpdfKeyCodeDown; |
1610 |
} else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) { |
1611 |
*code = xpdfKeyCodeF1 + (p0[1] - '1'); |
1612 |
} else if (p0[0] == 'f' && |
1613 |
((p0[1] >= '1' && p0[1] <= '2' && p0[2] >= '0' && p0[2] <= '9') || |
1614 |
(p0[1] == '3' && p0[2] >= '0' && p0[2] <= '5')) && |
1615 |
!p0[3]) { |
1616 |
*code = xpdfKeyCodeF1 + 10 * (p0[1] - '0') + (p0[2] - '0') - 1; |
1617 |
} else if (!strncmp(p0, "mousePress", 10) && |
1618 |
p0[10] >= '1' && p0[10] <= '7' && !p0[11]) { |
1619 |
*code = xpdfKeyCodeMousePress1 + (p0[10] - '1'); |
1620 |
} else if (!strncmp(p0, "mouseRelease", 12) && |
1621 |
p0[12] >= '1' && p0[12] <= '7' && !p0[13]) { |
1622 |
*code = xpdfKeyCodeMouseRelease1 + (p0[12] - '1'); |
1623 |
} else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) { |
1624 |
*code = (int)*p0; |
1625 |
} else { |
1626 |
error(-1, "Bad key/modifier in '%s' config file command (%s:%d)", |
1627 |
cmdName, fileName->getCString(), line); |
1628 |
return gFalse; |
1629 |
} |
1630 |
|
1631 |
p0 = contextStr->getCString(); |
1632 |
if (!strcmp(p0, "any")) { |
1633 |
*context = xpdfKeyContextAny; |
1634 |
} else { |
1635 |
*context = xpdfKeyContextAny; |
1636 |
while (1) { |
1637 |
if (!strncmp(p0, "fullScreen", 10)) { |
1638 |
*context |= xpdfKeyContextFullScreen; |
1639 |
p0 += 10; |
1640 |
} else if (!strncmp(p0, "window", 6)) { |
1641 |
*context |= xpdfKeyContextWindow; |
1642 |
p0 += 6; |
1643 |
} else if (!strncmp(p0, "continuous", 10)) { |
1644 |
*context |= xpdfKeyContextContinuous; |
1645 |
p0 += 10; |
1646 |
} else if (!strncmp(p0, "singlePage", 10)) { |
1647 |
*context |= xpdfKeyContextSinglePage; |
1648 |
p0 += 10; |
1649 |
} else if (!strncmp(p0, "overLink", 8)) { |
1650 |
*context |= xpdfKeyContextOverLink; |
1651 |
p0 += 8; |
1652 |
} else if (!strncmp(p0, "offLink", 7)) { |
1653 |
*context |= xpdfKeyContextOffLink; |
1654 |
p0 += 7; |
1655 |
} else if (!strncmp(p0, "outline", 7)) { |
1656 |
*context |= xpdfKeyContextOutline; |
1657 |
p0 += 7; |
1658 |
} else if (!strncmp(p0, "mainWin", 7)) { |
1659 |
*context |= xpdfKeyContextMainWin; |
1660 |
p0 += 7; |
1661 |
} else if (!strncmp(p0, "scrLockOn", 9)) { |
1662 |
*context |= xpdfKeyContextScrLockOn; |
1663 |
p0 += 9; |
1664 |
} else if (!strncmp(p0, "scrLockOff", 10)) { |
1665 |
*context |= xpdfKeyContextScrLockOff; |
1666 |
p0 += 10; |
1667 |
} else { |
1668 |
error(-1, "Bad context in '%s' config file command (%s:%d)", |
1669 |
cmdName, fileName->getCString(), line); |
1670 |
return gFalse; |
1671 |
} |
1672 |
if (!*p0) { |
1673 |
break; |
1674 |
} |
1675 |
if (*p0 != ',') { |
1676 |
error(-1, "Bad context in '%s' config file command (%s:%d)", |
1677 |
cmdName, fileName->getCString(), line); |
1678 |
return gFalse; |
1679 |
} |
1680 |
++p0; |
1681 |
} |
1682 |
} |
1683 |
|
1684 |
return gTrue; |
1685 |
} |
1686 |
|
1687 |
void GlobalParams::parseCommand(char *cmdName, GooString **val, |
1688 |
GooList *tokens, GooString *fileName, int line) { |
1689 |
if (tokens->getLength() != 2) { |
1690 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1691 |
cmdName, fileName->getCString(), line); |
1692 |
return; |
1693 |
} |
1694 |
if (*val) { |
1695 |
delete *val; |
1696 |
} |
1697 |
*val = ((GooString *)tokens->get(1))->copy(); |
1698 |
} |
1699 |
|
1700 |
void GlobalParams::parseYesNo(char *cmdName, GBool *flag, |
1701 |
GooList *tokens, GooString *fileName, int line) { |
1702 |
GooString *tok; |
1703 |
|
1704 |
if (tokens->getLength() != 2) { |
1705 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1706 |
cmdName, fileName->getCString(), line); |
1707 |
return; |
1708 |
} |
1709 |
tok = (GooString *)tokens->get(1); |
1710 |
if (!parseYesNo2(tok->getCString(), flag)) { |
1711 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1712 |
cmdName, fileName->getCString(), line); |
1713 |
} |
1714 |
} |
1715 |
|
1716 |
GBool GlobalParams::parseYesNo2(char *token, GBool *flag) { |
1717 |
if (!strcmp(token, "yes")) { |
1718 |
*flag = gTrue; |
1719 |
} else if (!strcmp(token, "no")) { |
1720 |
*flag = gFalse; |
1721 |
} else { |
1722 |
return gFalse; |
1723 |
} |
1724 |
return gTrue; |
1725 |
} |
1726 |
|
1727 |
void GlobalParams::parseInteger(char *cmdName, int *val, |
1728 |
GooList *tokens, GooString *fileName, int line) { |
1729 |
GooString *tok; |
1730 |
int i; |
626 |
|
1731 |
|
627 |
// set up the initial nameToUnicode table |
1732 |
if (tokens->getLength() != 2) { |
628 |
for (i = 0; nameToUnicodeTab[i].name; ++i) { |
1733 |
error(-1, "Bad '%s' config file command (%s:%d)", |
629 |
nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u); |
1734 |
cmdName, fileName->getCString(), line); |
|
|
1735 |
return; |
1736 |
} |
1737 |
tok = (GooString *)tokens->get(1); |
1738 |
if (tok->getLength() == 0) { |
1739 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1740 |
cmdName, fileName->getCString(), line); |
1741 |
return; |
1742 |
} |
1743 |
if (tok->getChar(0) == '-') { |
1744 |
i = 1; |
1745 |
} else { |
1746 |
i = 0; |
1747 |
} |
1748 |
for (; i < tok->getLength(); ++i) { |
1749 |
if (tok->getChar(i) < '0' || tok->getChar(i) > '9') { |
1750 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1751 |
cmdName, fileName->getCString(), line); |
1752 |
return; |
1753 |
} |
630 |
} |
1754 |
} |
|
|
1755 |
*val = atoi(tok->getCString()); |
1756 |
} |
631 |
|
1757 |
|
632 |
// set up the residentUnicodeMaps table |
1758 |
void GlobalParams::parseFloat(char *cmdName, double *val, |
633 |
map = new UnicodeMap("Latin1", gFalse, |
1759 |
GooList *tokens, GooString *fileName, int line) { |
634 |
latin1UnicodeMapRanges, latin1UnicodeMapLen); |
1760 |
GooString *tok; |
635 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
1761 |
int i; |
636 |
map = new UnicodeMap("ASCII7", gFalse, |
|
|
637 |
ascii7UnicodeMapRanges, ascii7UnicodeMapLen); |
638 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
639 |
map = new UnicodeMap("Symbol", gFalse, |
640 |
symbolUnicodeMapRanges, symbolUnicodeMapLen); |
641 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
642 |
map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges, |
643 |
zapfDingbatsUnicodeMapLen); |
644 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
645 |
map = new UnicodeMap("UTF-8", gTrue, &mapUTF8); |
646 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
647 |
map = new UnicodeMap("UCS-2", gTrue, &mapUCS2); |
648 |
residentUnicodeMaps->add(map->getEncodingName(), map); |
649 |
|
1762 |
|
650 |
scanEncodingDirs(); |
1763 |
if (tokens->getLength() != 2) { |
|
|
1764 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1765 |
cmdName, fileName->getCString(), line); |
1766 |
return; |
1767 |
} |
1768 |
tok = (GooString *)tokens->get(1); |
1769 |
if (tok->getLength() == 0) { |
1770 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1771 |
cmdName, fileName->getCString(), line); |
1772 |
return; |
1773 |
} |
1774 |
if (tok->getChar(0) == '-') { |
1775 |
i = 1; |
1776 |
} else { |
1777 |
i = 0; |
1778 |
} |
1779 |
for (; i < tok->getLength(); ++i) { |
1780 |
if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') || |
1781 |
tok->getChar(i) == '.')) { |
1782 |
error(-1, "Bad '%s' config file command (%s:%d)", |
1783 |
cmdName, fileName->getCString(), line); |
1784 |
return; |
1785 |
} |
1786 |
} |
1787 |
*val = atof(tok->getCString()); |
651 |
} |
1788 |
} |
652 |
|
1789 |
|
653 |
void GlobalParams::scanEncodingDirs() { |
1790 |
void GlobalParams::scanEncodingDirs() { |
Lines 686-719
Link Here
|
686 |
delete dir; |
1823 |
delete dir; |
687 |
} |
1824 |
} |
688 |
|
1825 |
|
689 |
void GlobalParams::parseNameToUnicode(GooString *name) { |
|
|
690 |
char *tok1, *tok2; |
691 |
FILE *f; |
692 |
char buf[256]; |
693 |
int line; |
694 |
Unicode u; |
695 |
|
696 |
if (!(f = fopen(name->getCString(), "r"))) { |
697 |
error(-1, "Couldn't open 'nameToUnicode' file '%s'", |
698 |
name->getCString()); |
699 |
return; |
700 |
} |
701 |
line = 1; |
702 |
while (getLine(buf, sizeof(buf), f)) { |
703 |
tok1 = strtok(buf, " \t\r\n"); |
704 |
tok2 = strtok(NULL, " \t\r\n"); |
705 |
if (tok1 && tok2) { |
706 |
sscanf(tok1, "%x", &u); |
707 |
nameToUnicode->add(tok2, u); |
708 |
} else { |
709 |
error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", |
710 |
name->getCString(), line); |
711 |
} |
712 |
++line; |
713 |
} |
714 |
fclose(f); |
715 |
} |
716 |
|
717 |
void GlobalParams::addCIDToUnicode(GooString *collection, |
1826 |
void GlobalParams::addCIDToUnicode(GooString *collection, |
718 |
GooString *fileName) { |
1827 |
GooString *fileName) { |
719 |
GooString *old; |
1828 |
GooString *old; |
Lines 744-760
Link Here
|
744 |
list->append(dir->copy()); |
1853 |
list->append(dir->copy()); |
745 |
} |
1854 |
} |
746 |
|
1855 |
|
747 |
GBool GlobalParams::parseYesNo2(char *token, GBool *flag) { |
|
|
748 |
if (!strcmp(token, "yes")) { |
749 |
*flag = gTrue; |
750 |
} else if (!strcmp(token, "no")) { |
751 |
*flag = gFalse; |
752 |
} else { |
753 |
return gFalse; |
754 |
} |
755 |
return gTrue; |
756 |
} |
757 |
|
758 |
GlobalParams::~GlobalParams() { |
1856 |
GlobalParams::~GlobalParams() { |
759 |
GooHashIter *iter; |
1857 |
GooHashIter *iter; |
760 |
GooString *key; |
1858 |
GooString *key; |
Lines 772-782
Link Here
|
772 |
deleteGooHash(unicodeMaps, GooString); |
1870 |
deleteGooHash(unicodeMaps, GooString); |
773 |
deleteGooList(toUnicodeDirs, GooString); |
1871 |
deleteGooList(toUnicodeDirs, GooString); |
774 |
deleteGooHash(displayFonts, DisplayFontParam); |
1872 |
deleteGooHash(displayFonts, DisplayFontParam); |
|
|
1873 |
deleteGooHash(displayCIDFonts, DisplayFontParam); |
1874 |
deleteGooHash(displayNamedCIDFonts, DisplayFontParam); |
775 |
#ifdef WIN32 |
1875 |
#ifdef WIN32 |
776 |
if (winFontList) { |
1876 |
if (winFontList) { |
777 |
delete winFontList; |
1877 |
delete winFontList; |
778 |
} |
1878 |
} |
779 |
#endif |
1879 |
#endif |
|
|
1880 |
if (psFile) { |
1881 |
delete psFile; |
1882 |
} |
780 |
deleteGooHash(psFonts, PSFontParam); |
1883 |
deleteGooHash(psFonts, PSFontParam); |
781 |
deleteGooList(psNamedFonts16, PSFontParam); |
1884 |
deleteGooList(psNamedFonts16, PSFontParam); |
782 |
deleteGooList(psFonts16, PSFontParam); |
1885 |
deleteGooList(psFonts16, PSFontParam); |
Lines 813-818
Link Here
|
813 |
baseDir = new GooString(dir); |
1916 |
baseDir = new GooString(dir); |
814 |
} |
1917 |
} |
815 |
|
1918 |
|
|
|
1919 |
void GlobalParams::setupBaseFonts(char *dir) { |
1920 |
GooString *fontName; |
1921 |
GooString *fileName; |
1922 |
#ifdef WIN32 |
1923 |
HMODULE shell32Lib; |
1924 |
BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner, |
1925 |
LPTSTR lpszPath, |
1926 |
int nFolder, |
1927 |
BOOL fCreate); |
1928 |
char winFontDir[MAX_PATH]; |
1929 |
#endif |
1930 |
FILE *f; |
1931 |
DisplayFontParamKind kind; |
1932 |
DisplayFontParam *dfp; |
1933 |
int i, j; |
1934 |
|
1935 |
#ifdef WIN32 |
1936 |
// SHGetSpecialFolderPath isn't available in older versions of |
1937 |
// shell32.dll (Win95 and WinNT4), so do a dynamic load |
1938 |
winFontDir[0] = '\0'; |
1939 |
if ((shell32Lib = LoadLibrary("shell32.dll"))) { |
1940 |
if ((SHGetSpecialFolderPathFunc = |
1941 |
(BOOL (__stdcall *)(HWND hwndOwner, LPTSTR lpszPath, |
1942 |
int nFolder, BOOL fCreate)) |
1943 |
GetProcAddress(shell32Lib, "SHGetSpecialFolderPathA"))) { |
1944 |
if (!(*SHGetSpecialFolderPathFunc)(NULL, winFontDir, |
1945 |
CSIDL_FONTS, FALSE)) { |
1946 |
winFontDir[0] = '\0'; |
1947 |
} |
1948 |
} |
1949 |
} |
1950 |
#endif |
1951 |
for (i = 0; displayFontTab[i].name; ++i) { |
1952 |
fontName = new GooString(displayFontTab[i].name); |
1953 |
if (getDisplayFont(fontName)) { |
1954 |
delete fontName; |
1955 |
continue; |
1956 |
} |
1957 |
fileName = NULL; |
1958 |
kind = displayFontT1; // make gcc happy |
1959 |
if (dir) { |
1960 |
fileName = appendToPath(new GooString(dir), displayFontTab[i].t1FileName); |
1961 |
kind = displayFontT1; |
1962 |
if ((f = fopen(fileName->getCString(), "rb"))) { |
1963 |
fclose(f); |
1964 |
} else { |
1965 |
delete fileName; |
1966 |
fileName = NULL; |
1967 |
} |
1968 |
} |
1969 |
#ifdef WIN32 |
1970 |
if (!fileName && winFontDir[0] && displayFontTab[i].ttFileName) { |
1971 |
fileName = appendToPath(new GooString(winFontDir), |
1972 |
displayFontTab[i].ttFileName); |
1973 |
kind = displayFontTT; |
1974 |
if ((f = fopen(fileName->getCString(), "rb"))) { |
1975 |
fclose(f); |
1976 |
} else { |
1977 |
delete fileName; |
1978 |
fileName = NULL; |
1979 |
} |
1980 |
} |
1981 |
// SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server |
1982 |
// or Win2003 Server, or with older versions of shell32.dll, so check |
1983 |
// the "standard" directories |
1984 |
if (displayFontTab[i].ttFileName) { |
1985 |
for (j = 0; !fileName && displayFontDirs[j]; ++j) { |
1986 |
fileName = appendToPath(new GooString(displayFontDirs[j]), |
1987 |
displayFontTab[i].ttFileName); |
1988 |
kind = displayFontTT; |
1989 |
if ((f = fopen(fileName->getCString(), "rb"))) { |
1990 |
fclose(f); |
1991 |
} else { |
1992 |
delete fileName; |
1993 |
fileName = NULL; |
1994 |
} |
1995 |
} |
1996 |
} |
1997 |
#else |
1998 |
for (j = 0; !fileName && displayFontDirs[j]; ++j) { |
1999 |
fileName = appendToPath(new GooString(displayFontDirs[j]), |
2000 |
displayFontTab[i].t1FileName); |
2001 |
kind = displayFontT1; |
2002 |
if ((f = fopen(fileName->getCString(), "rb"))) { |
2003 |
fclose(f); |
2004 |
} else { |
2005 |
delete fileName; |
2006 |
fileName = NULL; |
2007 |
} |
2008 |
} |
2009 |
#endif |
2010 |
if (!fileName) { |
2011 |
error(-1, "No display font for '%s'", displayFontTab[i].name); |
2012 |
delete fontName; |
2013 |
continue; |
2014 |
} |
2015 |
dfp = new DisplayFontParam(fontName, kind); |
2016 |
dfp->t1.fileName = fileName; |
2017 |
globalParams->addDisplayFont(dfp); |
2018 |
} |
2019 |
|
2020 |
#ifdef WIN32 |
2021 |
if (winFontDir[0]) { |
2022 |
winFontList = new WinFontList(winFontDir); |
2023 |
} |
2024 |
#endif |
2025 |
} |
2026 |
|
816 |
//------------------------------------------------------------------------ |
2027 |
//------------------------------------------------------------------------ |
817 |
// accessors |
2028 |
// accessors |
818 |
//------------------------------------------------------------------------ |
2029 |
//------------------------------------------------------------------------ |
Lines 1127-1132
Link Here
|
1127 |
return dfp; |
2338 |
return dfp; |
1128 |
} |
2339 |
} |
1129 |
|
2340 |
|
|
|
2341 |
DisplayFontParam *GlobalParams::getDisplayFont(GooString *fontName) { |
2342 |
DisplayFontParam *dfp; |
2343 |
|
2344 |
lockGlobalParams; |
2345 |
dfp = (DisplayFontParam *)displayFonts->lookup(fontName); |
2346 |
#ifdef WIN32 |
2347 |
if (!dfp && winFontList) { |
2348 |
dfp = winFontList->find(fontName); |
2349 |
} |
2350 |
#endif |
2351 |
unlockGlobalParams; |
2352 |
return dfp; |
2353 |
} |
2354 |
|
2355 |
DisplayFontParam *GlobalParams::getDisplayCIDFont(GooString *fontName, |
2356 |
GooString *collection) { |
2357 |
DisplayFontParam *dfp; |
2358 |
|
2359 |
lockGlobalParams; |
2360 |
if (!fontName || |
2361 |
!(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) { |
2362 |
dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection); |
2363 |
} |
2364 |
unlockGlobalParams; |
2365 |
return dfp; |
2366 |
} |
2367 |
|
2368 |
GooString *GlobalParams::getPSFile() { |
2369 |
GooString *s; |
2370 |
|
2371 |
lockGlobalParams; |
2372 |
s = psFile ? psFile->copy() : (GooString *)NULL; |
2373 |
unlockGlobalParams; |
2374 |
return s; |
2375 |
} |
2376 |
|
2377 |
int GlobalParams::getPSPaperWidth() { |
2378 |
int w; |
2379 |
|
2380 |
lockGlobalParams; |
2381 |
w = psPaperWidth; |
2382 |
unlockGlobalParams; |
2383 |
return w; |
2384 |
} |
2385 |
|
2386 |
int GlobalParams::getPSPaperHeight() { |
2387 |
int h; |
2388 |
|
2389 |
lockGlobalParams; |
2390 |
h = psPaperHeight; |
2391 |
unlockGlobalParams; |
2392 |
return h; |
2393 |
} |
2394 |
|
2395 |
void GlobalParams::getPSImageableArea(int *llx, int *lly, int *urx, int *ury) { |
2396 |
lockGlobalParams; |
2397 |
*llx = psImageableLLX; |
2398 |
*lly = psImageableLLY; |
2399 |
*urx = psImageableURX; |
2400 |
*ury = psImageableURY; |
2401 |
unlockGlobalParams; |
2402 |
} |
2403 |
|
2404 |
GBool GlobalParams::getPSCrop() { |
2405 |
GBool f; |
2406 |
|
2407 |
lockGlobalParams; |
2408 |
f = psCrop; |
2409 |
unlockGlobalParams; |
2410 |
return f; |
2411 |
} |
2412 |
|
1130 |
GBool GlobalParams::getPSExpandSmaller() { |
2413 |
GBool GlobalParams::getPSExpandSmaller() { |
1131 |
GBool f; |
2414 |
GBool f; |
1132 |
|
2415 |
|
Lines 1154-1159
Link Here
|
1154 |
return f; |
2437 |
return f; |
1155 |
} |
2438 |
} |
1156 |
|
2439 |
|
|
|
2440 |
GBool GlobalParams::getPSDuplex() { |
2441 |
GBool d; |
2442 |
|
2443 |
lockGlobalParams; |
2444 |
d = psDuplex; |
2445 |
unlockGlobalParams; |
2446 |
return d; |
2447 |
} |
2448 |
|
1157 |
PSLevel GlobalParams::getPSLevel() { |
2449 |
PSLevel GlobalParams::getPSLevel() { |
1158 |
PSLevel level; |
2450 |
PSLevel level; |
1159 |
|
2451 |
|
Lines 1326-1331
Link Here
|
1326 |
return NULL; |
2618 |
return NULL; |
1327 |
} |
2619 |
} |
1328 |
|
2620 |
|
|
|
2621 |
GooString *GlobalParams::getInitialZoom() { |
2622 |
GooString *s; |
2623 |
|
2624 |
lockGlobalParams; |
2625 |
s = initialZoom->copy(); |
2626 |
unlockGlobalParams; |
2627 |
return s; |
2628 |
} |
2629 |
|
2630 |
GBool GlobalParams::getContinuousView() { |
2631 |
GBool f; |
2632 |
|
2633 |
lockGlobalParams; |
2634 |
f = continuousView; |
2635 |
unlockGlobalParams; |
2636 |
return f; |
2637 |
} |
2638 |
|
2639 |
GBool GlobalParams::getEnableT1lib() { |
2640 |
GBool f; |
2641 |
|
2642 |
lockGlobalParams; |
2643 |
f = enableT1lib; |
2644 |
unlockGlobalParams; |
2645 |
return f; |
2646 |
} |
2647 |
|
1329 |
GBool GlobalParams::getEnableFreeType() { |
2648 |
GBool GlobalParams::getEnableFreeType() { |
1330 |
GBool f; |
2649 |
GBool f; |
1331 |
|
2650 |
|
Lines 1435-1440
Link Here
|
1435 |
return map; |
2754 |
return map; |
1436 |
} |
2755 |
} |
1437 |
|
2756 |
|
|
|
2757 |
GooList *GlobalParams::getKeyBinding(int code, int mods, int context) { |
2758 |
KeyBinding *binding; |
2759 |
GooList *cmds; |
2760 |
int modMask; |
2761 |
int i, j; |
2762 |
|
2763 |
lockGlobalParams; |
2764 |
cmds = NULL; |
2765 |
// for ASCII chars, ignore the shift modifier |
2766 |
modMask = code <= 0xff ? ~xpdfKeyModShift : ~0; |
2767 |
for (i = 0; i < keyBindings->getLength(); ++i) { |
2768 |
binding = (KeyBinding *)keyBindings->get(i); |
2769 |
if (binding->code == code && |
2770 |
(binding->mods & modMask) == (mods & modMask) && |
2771 |
(~binding->context | context) == ~0) { |
2772 |
cmds = new GooList(); |
2773 |
for (j = 0; j < binding->cmds->getLength(); ++j) { |
2774 |
cmds->append(((GooString *)binding->cmds->get(j))->copy()); |
2775 |
} |
2776 |
break; |
2777 |
} |
2778 |
} |
2779 |
unlockGlobalParams; |
2780 |
return cmds; |
2781 |
} |
2782 |
|
1438 |
GBool GlobalParams::getPrintCommands() { |
2783 |
GBool GlobalParams::getPrintCommands() { |
1439 |
GBool p; |
2784 |
GBool p; |
1440 |
|
2785 |
|
Lines 1534-1539
Link Here
|
1534 |
// functions to set parameters |
2879 |
// functions to set parameters |
1535 |
//------------------------------------------------------------------------ |
2880 |
//------------------------------------------------------------------------ |
1536 |
|
2881 |
|
|
|
2882 |
void GlobalParams::addDisplayFont(DisplayFontParam *param) { |
2883 |
DisplayFontParam *old; |
2884 |
|
2885 |
lockGlobalParams; |
2886 |
if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) { |
2887 |
delete old; |
2888 |
} |
2889 |
displayFonts->add(param->name, param); |
2890 |
unlockGlobalParams; |
2891 |
} |
2892 |
|
2893 |
void GlobalParams::setPSFile(char *file) { |
2894 |
lockGlobalParams; |
2895 |
if (psFile) { |
2896 |
delete psFile; |
2897 |
} |
2898 |
psFile = new GooString(file); |
2899 |
unlockGlobalParams; |
2900 |
} |
2901 |
|
2902 |
GBool GlobalParams::setPSPaperSize(char *size) { |
2903 |
lockGlobalParams; |
2904 |
if (!strcmp(size, "match")) { |
2905 |
psPaperWidth = psPaperHeight = -1; |
2906 |
} else if (!strcmp(size, "letter")) { |
2907 |
psPaperWidth = 612; |
2908 |
psPaperHeight = 792; |
2909 |
} else if (!strcmp(size, "legal")) { |
2910 |
psPaperWidth = 612; |
2911 |
psPaperHeight = 1008; |
2912 |
} else if (!strcmp(size, "A4")) { |
2913 |
psPaperWidth = 595; |
2914 |
psPaperHeight = 842; |
2915 |
} else if (!strcmp(size, "A3")) { |
2916 |
psPaperWidth = 842; |
2917 |
psPaperHeight = 1190; |
2918 |
} else { |
2919 |
unlockGlobalParams; |
2920 |
return gFalse; |
2921 |
} |
2922 |
psImageableLLX = psImageableLLY = 0; |
2923 |
psImageableURX = psPaperWidth; |
2924 |
psImageableURY = psPaperHeight; |
2925 |
unlockGlobalParams; |
2926 |
return gTrue; |
2927 |
} |
2928 |
|
2929 |
void GlobalParams::setPSPaperWidth(int width) { |
2930 |
lockGlobalParams; |
2931 |
psPaperWidth = width; |
2932 |
psImageableLLX = 0; |
2933 |
psImageableURX = psPaperWidth; |
2934 |
unlockGlobalParams; |
2935 |
} |
2936 |
|
2937 |
void GlobalParams::setPSPaperHeight(int height) { |
2938 |
lockGlobalParams; |
2939 |
psPaperHeight = height; |
2940 |
psImageableLLY = 0; |
2941 |
psImageableURY = psPaperHeight; |
2942 |
unlockGlobalParams; |
2943 |
} |
2944 |
|
2945 |
void GlobalParams::setPSImageableArea(int llx, int lly, int urx, int ury) { |
2946 |
lockGlobalParams; |
2947 |
psImageableLLX = llx; |
2948 |
psImageableLLY = lly; |
2949 |
psImageableURX = urx; |
2950 |
psImageableURY = ury; |
2951 |
unlockGlobalParams; |
2952 |
} |
2953 |
|
2954 |
void GlobalParams::setPSCrop(GBool crop) { |
2955 |
lockGlobalParams; |
2956 |
psCrop = crop; |
2957 |
unlockGlobalParams; |
2958 |
} |
2959 |
|
1537 |
void GlobalParams::setPSExpandSmaller(GBool expand) { |
2960 |
void GlobalParams::setPSExpandSmaller(GBool expand) { |
1538 |
lockGlobalParams; |
2961 |
lockGlobalParams; |
1539 |
psExpandSmaller = expand; |
2962 |
psExpandSmaller = expand; |
Lines 1552-1557
Link Here
|
1552 |
unlockGlobalParams; |
2975 |
unlockGlobalParams; |
1553 |
} |
2976 |
} |
1554 |
|
2977 |
|
|
|
2978 |
void GlobalParams::setPSDuplex(GBool duplex) { |
2979 |
lockGlobalParams; |
2980 |
psDuplex = duplex; |
2981 |
unlockGlobalParams; |
2982 |
} |
2983 |
|
1555 |
void GlobalParams::setPSLevel(PSLevel level) { |
2984 |
void GlobalParams::setPSLevel(PSLevel level) { |
1556 |
lockGlobalParams; |
2985 |
lockGlobalParams; |
1557 |
psLevel = level; |
2986 |
psLevel = level; |
Lines 1635-1640
Link Here
|
1635 |
unlockGlobalParams; |
3064 |
unlockGlobalParams; |
1636 |
} |
3065 |
} |
1637 |
|
3066 |
|
|
|
3067 |
void GlobalParams::setInitialZoom(char *s) { |
3068 |
lockGlobalParams; |
3069 |
delete initialZoom; |
3070 |
initialZoom = new GooString(s); |
3071 |
unlockGlobalParams; |
3072 |
} |
3073 |
|
3074 |
void GlobalParams::setContinuousView(GBool cont) { |
3075 |
lockGlobalParams; |
3076 |
continuousView = cont; |
3077 |
unlockGlobalParams; |
3078 |
} |
3079 |
|
3080 |
GBool GlobalParams::setEnableT1lib(char *s) { |
3081 |
GBool ok; |
3082 |
|
3083 |
lockGlobalParams; |
3084 |
ok = parseYesNo2(s, &enableT1lib); |
3085 |
unlockGlobalParams; |
3086 |
return ok; |
3087 |
} |
3088 |
|
1638 |
GBool GlobalParams::setEnableFreeType(char *s) { |
3089 |
GBool GlobalParams::setEnableFreeType(char *s) { |
1639 |
GBool ok; |
3090 |
GBool ok; |
1640 |
|
3091 |
|