pdf2json 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. data/README.markdown +9 -0
  2. data/bin/.gitkeep +0 -0
  3. data/ext/extconf.rb +30 -0
  4. data/lib/pdf2json.rb +8 -0
  5. data/pdf2json-0.52-source/AUTHORS +24 -0
  6. data/pdf2json-0.52-source/CHANGES +11 -0
  7. data/pdf2json-0.52-source/Makefile +84 -0
  8. data/pdf2json-0.52-source/Makefile.in +84 -0
  9. data/pdf2json-0.52-source/aclocal.m4 +274 -0
  10. data/pdf2json-0.52-source/aconf-win32.h +86 -0
  11. data/pdf2json-0.52-source/aconf.h +42 -0
  12. data/pdf2json-0.52-source/aconf.h.in +41 -0
  13. data/pdf2json-0.52-source/autom4te.cache/output.0 +6908 -0
  14. data/pdf2json-0.52-source/autom4te.cache/requests +76 -0
  15. data/pdf2json-0.52-source/autom4te.cache/traces.0 +466 -0
  16. data/pdf2json-0.52-source/config.log +1259 -0
  17. data/pdf2json-0.52-source/config.status +1050 -0
  18. data/pdf2json-0.52-source/configure +6908 -0
  19. data/pdf2json-0.52-source/configure.ac +93 -0
  20. data/pdf2json-0.52-source/doc/pdffonts.1 +130 -0
  21. data/pdf2json-0.52-source/doc/pdffonts.cat +107 -0
  22. data/pdf2json-0.52-source/doc/pdffonts.hlp +117 -0
  23. data/pdf2json-0.52-source/doc/pdfimages.1 +102 -0
  24. data/pdf2json-0.52-source/doc/pdfimages.cat +92 -0
  25. data/pdf2json-0.52-source/doc/pdfimages.hlp +101 -0
  26. data/pdf2json-0.52-source/doc/pdfinfo.1 +158 -0
  27. data/pdf2json-0.52-source/doc/pdfinfo.cat +119 -0
  28. data/pdf2json-0.52-source/doc/pdfinfo.hlp +129 -0
  29. data/pdf2json-0.52-source/doc/pdftoppm.1 +115 -0
  30. data/pdf2json-0.52-source/doc/pdftoppm.cat +105 -0
  31. data/pdf2json-0.52-source/doc/pdftoppm.hlp +114 -0
  32. data/pdf2json-0.52-source/doc/pdftops.1 +229 -0
  33. data/pdf2json-0.52-source/doc/pdftops.cat +221 -0
  34. data/pdf2json-0.52-source/doc/pdftops.hlp +231 -0
  35. data/pdf2json-0.52-source/doc/pdftotext.1 +137 -0
  36. data/pdf2json-0.52-source/doc/pdftotext.cat +120 -0
  37. data/pdf2json-0.52-source/doc/pdftotext.hlp +133 -0
  38. data/pdf2json-0.52-source/doc/sample-xpdfrc +91 -0
  39. data/pdf2json-0.52-source/doc/xpdf.1 +513 -0
  40. data/pdf2json-0.52-source/doc/xpdf.cat +476 -0
  41. data/pdf2json-0.52-source/doc/xpdf.hlp +489 -0
  42. data/pdf2json-0.52-source/doc/xpdfrc.5 +480 -0
  43. data/pdf2json-0.52-source/doc/xpdfrc.cat +474 -0
  44. data/pdf2json-0.52-source/doc/xpdfrc.hlp +479 -0
  45. data/pdf2json-0.52-source/fofi/.DS_Store +0 -0
  46. data/pdf2json-0.52-source/fofi/FoFiBase.cc +156 -0
  47. data/pdf2json-0.52-source/fofi/FoFiBase.h +57 -0
  48. data/pdf2json-0.52-source/fofi/FoFiBase.o +0 -0
  49. data/pdf2json-0.52-source/fofi/FoFiEncodings.cc +994 -0
  50. data/pdf2json-0.52-source/fofi/FoFiEncodings.h +36 -0
  51. data/pdf2json-0.52-source/fofi/FoFiEncodings.o +0 -0
  52. data/pdf2json-0.52-source/fofi/FoFiTrueType.cc +2027 -0
  53. data/pdf2json-0.52-source/fofi/FoFiTrueType.h +174 -0
  54. data/pdf2json-0.52-source/fofi/FoFiTrueType.o +0 -0
  55. data/pdf2json-0.52-source/fofi/FoFiType1.cc +252 -0
  56. data/pdf2json-0.52-source/fofi/FoFiType1.h +59 -0
  57. data/pdf2json-0.52-source/fofi/FoFiType1.o +0 -0
  58. data/pdf2json-0.52-source/fofi/FoFiType1C.cc +2603 -0
  59. data/pdf2json-0.52-source/fofi/FoFiType1C.h +233 -0
  60. data/pdf2json-0.52-source/fofi/FoFiType1C.o +0 -0
  61. data/pdf2json-0.52-source/fofi/Makefile +70 -0
  62. data/pdf2json-0.52-source/fofi/Makefile.dep +0 -0
  63. data/pdf2json-0.52-source/fofi/Makefile.in +70 -0
  64. data/pdf2json-0.52-source/fofi/libfofi.a +0 -0
  65. data/pdf2json-0.52-source/fofi/vms_make.com +0 -0
  66. data/pdf2json-0.52-source/freetype.win32/.DS_Store +0 -0
  67. data/pdf2json-0.52-source/freetype.win32/include/.DS_Store +0 -0
  68. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftconfig.h +528 -0
  69. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftheader.h +780 -0
  70. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftmodule.h +32 -0
  71. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftoption.h +733 -0
  72. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftstdlib.h +173 -0
  73. data/pdf2json-0.52-source/freetype.win32/include/freetype/freetype.h +3919 -0
  74. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftadvanc.h +179 -0
  75. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbbox.h +94 -0
  76. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbdf.h +209 -0
  77. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbitmap.h +227 -0
  78. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcache.h +1128 -0
  79. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftchapters.h +103 -0
  80. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcid.h +166 -0
  81. data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrdef.h +244 -0
  82. data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrors.h +206 -0
  83. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgasp.h +120 -0
  84. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftglyph.h +613 -0
  85. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgxval.h +358 -0
  86. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgzip.h +102 -0
  87. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftimage.h +1313 -0
  88. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftincrem.h +353 -0
  89. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlcdfil.h +213 -0
  90. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlist.h +277 -0
  91. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlzw.h +99 -0
  92. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmac.h +274 -0
  93. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmm.h +378 -0
  94. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmodapi.h +483 -0
  95. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmoderr.h +155 -0
  96. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftotval.h +203 -0
  97. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftoutln.h +537 -0
  98. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftpfr.h +172 -0
  99. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftrender.h +230 -0
  100. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsizes.h +159 -0
  101. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsnames.h +200 -0
  102. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftstroke.h +716 -0
  103. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsynth.h +80 -0
  104. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsystem.h +347 -0
  105. data/pdf2json-0.52-source/freetype.win32/include/freetype/fttrigon.h +350 -0
  106. data/pdf2json-0.52-source/freetype.win32/include/freetype/fttypes.h +588 -0
  107. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftwinfnt.h +274 -0
  108. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftxf86.h +83 -0
  109. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/autohint.h +231 -0
  110. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftcalc.h +179 -0
  111. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdebug.h +250 -0
  112. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdriver.h +422 -0
  113. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftgloadr.h +168 -0
  114. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftmemory.h +380 -0
  115. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftobjs.h +1428 -0
  116. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftpic.h +67 -0
  117. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftrfork.h +196 -0
  118. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftserv.h +620 -0
  119. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftstream.h +539 -0
  120. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/fttrace.h +139 -0
  121. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftvalid.h +150 -0
  122. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/internal.h +51 -0
  123. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pcftypes.h +56 -0
  124. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/psaux.h +873 -0
  125. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pshints.h +712 -0
  126. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svbdf.h +77 -0
  127. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svcid.h +83 -0
  128. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgldict.h +82 -0
  129. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgxval.h +72 -0
  130. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svkern.h +51 -0
  131. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svmm.h +104 -0
  132. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svotval.h +55 -0
  133. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpfr.h +66 -0
  134. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpostnm.h +79 -0
  135. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpscmap.h +164 -0
  136. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpsinfo.h +92 -0
  137. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svsfnt.h +102 -0
  138. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttcmap.h +106 -0
  139. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svtteng.h +53 -0
  140. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttglyf.h +67 -0
  141. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svwinfnt.h +50 -0
  142. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svxf86nm.h +55 -0
  143. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/sfnt.h +897 -0
  144. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/t1types.h +270 -0
  145. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/tttypes.h +1543 -0
  146. data/pdf2json-0.52-source/freetype.win32/include/freetype/t1tables.h +504 -0
  147. data/pdf2json-0.52-source/freetype.win32/include/freetype/ttnameid.h +1247 -0
  148. data/pdf2json-0.52-source/freetype.win32/include/freetype/tttables.h +759 -0
  149. data/pdf2json-0.52-source/freetype.win32/include/freetype/tttags.h +107 -0
  150. data/pdf2json-0.52-source/freetype.win32/include/freetype/ttunpat.h +59 -0
  151. data/pdf2json-0.52-source/freetype.win32/include/ft2build.h +39 -0
  152. data/pdf2json-0.52-source/freetype.win32/lib/freetype_a.lib +0 -0
  153. data/pdf2json-0.52-source/goo/.DS_Store +0 -0
  154. data/pdf2json-0.52-source/goo/FixedPoint.cc +118 -0
  155. data/pdf2json-0.52-source/goo/FixedPoint.h +155 -0
  156. data/pdf2json-0.52-source/goo/FixedPoint.o +0 -0
  157. data/pdf2json-0.52-source/goo/GHash.cc +380 -0
  158. data/pdf2json-0.52-source/goo/GHash.h +78 -0
  159. data/pdf2json-0.52-source/goo/GHash.o +0 -0
  160. data/pdf2json-0.52-source/goo/GList.cc +97 -0
  161. data/pdf2json-0.52-source/goo/GList.h +96 -0
  162. data/pdf2json-0.52-source/goo/GList.o +0 -0
  163. data/pdf2json-0.52-source/goo/GMutex.h +49 -0
  164. data/pdf2json-0.52-source/goo/GString.cc +724 -0
  165. data/pdf2json-0.52-source/goo/GString.cc.fixed +718 -0
  166. data/pdf2json-0.52-source/goo/GString.h +136 -0
  167. data/pdf2json-0.52-source/goo/GString.o +0 -0
  168. data/pdf2json-0.52-source/goo/ImgWriter.o +0 -0
  169. data/pdf2json-0.52-source/goo/JpegWriter.o +0 -0
  170. data/pdf2json-0.52-source/goo/Makefile +72 -0
  171. data/pdf2json-0.52-source/goo/Makefile.dep +0 -0
  172. data/pdf2json-0.52-source/goo/Makefile.in +72 -0
  173. data/pdf2json-0.52-source/goo/PNGWriter.o +0 -0
  174. data/pdf2json-0.52-source/goo/gfile.cc +731 -0
  175. data/pdf2json-0.52-source/goo/gfile.h +138 -0
  176. data/pdf2json-0.52-source/goo/gfile.o +0 -0
  177. data/pdf2json-0.52-source/goo/gmem.cc +264 -0
  178. data/pdf2json-0.52-source/goo/gmem.h +79 -0
  179. data/pdf2json-0.52-source/goo/gmem.o +0 -0
  180. data/pdf2json-0.52-source/goo/gmempp.cc +32 -0
  181. data/pdf2json-0.52-source/goo/gmempp.o +0 -0
  182. data/pdf2json-0.52-source/goo/gtypes.h +29 -0
  183. data/pdf2json-0.52-source/goo/libGoo.a +0 -0
  184. data/pdf2json-0.52-source/goo/parseargs.c +190 -0
  185. data/pdf2json-0.52-source/goo/parseargs.h +71 -0
  186. data/pdf2json-0.52-source/goo/parseargs.o +0 -0
  187. data/pdf2json-0.52-source/goo/vms_directory.c +214 -0
  188. data/pdf2json-0.52-source/goo/vms_dirent.h +67 -0
  189. data/pdf2json-0.52-source/goo/vms_make.com +82 -0
  190. data/pdf2json-0.52-source/goo/vms_sys_dirent.h +54 -0
  191. data/pdf2json-0.52-source/goo/vms_unix_time.h +102 -0
  192. data/pdf2json-0.52-source/goo/vms_unix_times.c +42 -0
  193. data/pdf2json-0.52-source/goo/vms_unlink.c +22 -0
  194. data/pdf2json-0.52-source/ms_make.bat +199 -0
  195. data/pdf2json-0.52-source/splash/.DS_Store +0 -0
  196. data/pdf2json-0.52-source/splash/Makefile +103 -0
  197. data/pdf2json-0.52-source/splash/Makefile.dep +0 -0
  198. data/pdf2json-0.52-source/splash/Makefile.in +103 -0
  199. data/pdf2json-0.52-source/splash/Splash.cc +3310 -0
  200. data/pdf2json-0.52-source/splash/Splash.h +293 -0
  201. data/pdf2json-0.52-source/splash/Splash.o +0 -0
  202. data/pdf2json-0.52-source/splash/SplashBitmap.cc +188 -0
  203. data/pdf2json-0.52-source/splash/SplashBitmap.h +64 -0
  204. data/pdf2json-0.52-source/splash/SplashBitmap.o +0 -0
  205. data/pdf2json-0.52-source/splash/SplashClip.cc +382 -0
  206. data/pdf2json-0.52-source/splash/SplashClip.h +107 -0
  207. data/pdf2json-0.52-source/splash/SplashClip.o +0 -0
  208. data/pdf2json-0.52-source/splash/SplashErrorCodes.h +32 -0
  209. data/pdf2json-0.52-source/splash/SplashFTFont.cc +357 -0
  210. data/pdf2json-0.52-source/splash/SplashFTFont.h +58 -0
  211. data/pdf2json-0.52-source/splash/SplashFTFont.o +0 -0
  212. data/pdf2json-0.52-source/splash/SplashFTFontEngine.cc +179 -0
  213. data/pdf2json-0.52-source/splash/SplashFTFontEngine.h +65 -0
  214. data/pdf2json-0.52-source/splash/SplashFTFontEngine.o +0 -0
  215. data/pdf2json-0.52-source/splash/SplashFTFontFile.cc +114 -0
  216. data/pdf2json-0.52-source/splash/SplashFTFontFile.h +73 -0
  217. data/pdf2json-0.52-source/splash/SplashFTFontFile.o +0 -0
  218. data/pdf2json-0.52-source/splash/SplashFont.cc +176 -0
  219. data/pdf2json-0.52-source/splash/SplashFont.h +104 -0
  220. data/pdf2json-0.52-source/splash/SplashFont.o +0 -0
  221. data/pdf2json-0.52-source/splash/SplashFontEngine.cc +317 -0
  222. data/pdf2json-0.52-source/splash/SplashFontEngine.h +91 -0
  223. data/pdf2json-0.52-source/splash/SplashFontEngine.o +0 -0
  224. data/pdf2json-0.52-source/splash/SplashFontFile.cc +55 -0
  225. data/pdf2json-0.52-source/splash/SplashFontFile.h +60 -0
  226. data/pdf2json-0.52-source/splash/SplashFontFile.o +0 -0
  227. data/pdf2json-0.52-source/splash/SplashFontFileID.cc +23 -0
  228. data/pdf2json-0.52-source/splash/SplashFontFileID.h +30 -0
  229. data/pdf2json-0.52-source/splash/SplashFontFileID.o +0 -0
  230. data/pdf2json-0.52-source/splash/SplashGlyphBitmap.h +26 -0
  231. data/pdf2json-0.52-source/splash/SplashMath.h +89 -0
  232. data/pdf2json-0.52-source/splash/SplashPath.cc +184 -0
  233. data/pdf2json-0.52-source/splash/SplashPath.h +121 -0
  234. data/pdf2json-0.52-source/splash/SplashPath.o +0 -0
  235. data/pdf2json-0.52-source/splash/SplashPattern.cc +40 -0
  236. data/pdf2json-0.52-source/splash/SplashPattern.h +65 -0
  237. data/pdf2json-0.52-source/splash/SplashPattern.o +0 -0
  238. data/pdf2json-0.52-source/splash/SplashScreen.cc +383 -0
  239. data/pdf2json-0.52-source/splash/SplashScreen.h +56 -0
  240. data/pdf2json-0.52-source/splash/SplashScreen.o +0 -0
  241. data/pdf2json-0.52-source/splash/SplashState.cc +165 -0
  242. data/pdf2json-0.52-source/splash/SplashState.h +103 -0
  243. data/pdf2json-0.52-source/splash/SplashState.o +0 -0
  244. data/pdf2json-0.52-source/splash/SplashT1Font.cc +287 -0
  245. data/pdf2json-0.52-source/splash/SplashT1Font.h +57 -0
  246. data/pdf2json-0.52-source/splash/SplashT1Font.o +0 -0
  247. data/pdf2json-0.52-source/splash/SplashT1FontEngine.cc +124 -0
  248. data/pdf2json-0.52-source/splash/SplashT1FontEngine.h +53 -0
  249. data/pdf2json-0.52-source/splash/SplashT1FontEngine.o +0 -0
  250. data/pdf2json-0.52-source/splash/SplashT1FontFile.cc +97 -0
  251. data/pdf2json-0.52-source/splash/SplashT1FontFile.h +58 -0
  252. data/pdf2json-0.52-source/splash/SplashT1FontFile.o +0 -0
  253. data/pdf2json-0.52-source/splash/SplashTypes.h +132 -0
  254. data/pdf2json-0.52-source/splash/SplashXPath.cc +438 -0
  255. data/pdf2json-0.52-source/splash/SplashXPath.h +100 -0
  256. data/pdf2json-0.52-source/splash/SplashXPath.o +0 -0
  257. data/pdf2json-0.52-source/splash/SplashXPathScanner.cc +428 -0
  258. data/pdf2json-0.52-source/splash/SplashXPathScanner.h +87 -0
  259. data/pdf2json-0.52-source/splash/SplashXPathScanner.o +0 -0
  260. data/pdf2json-0.52-source/splash/libsplash.a +0 -0
  261. data/pdf2json-0.52-source/splash/vms_make.com +0 -0
  262. data/pdf2json-0.52-source/src/.DS_Store +0 -0
  263. data/pdf2json-0.52-source/src/GVector.h +101 -0
  264. data/pdf2json-0.52-source/src/ImgOutputDev.cc +1243 -0
  265. data/pdf2json-0.52-source/src/ImgOutputDev.h +307 -0
  266. data/pdf2json-0.52-source/src/ImgOutputDev.o +0 -0
  267. data/pdf2json-0.52-source/src/Makefile +68 -0
  268. data/pdf2json-0.52-source/src/Makefile.in +68 -0
  269. data/pdf2json-0.52-source/src/XmlFonts.cc +367 -0
  270. data/pdf2json-0.52-source/src/XmlFonts.h +91 -0
  271. data/pdf2json-0.52-source/src/XmlFonts.o +0 -0
  272. data/pdf2json-0.52-source/src/XmlLinks.cc +101 -0
  273. data/pdf2json-0.52-source/src/XmlLinks.h +54 -0
  274. data/pdf2json-0.52-source/src/XmlLinks.o +0 -0
  275. data/pdf2json-0.52-source/src/pdf2json +0 -0
  276. data/pdf2json-0.52-source/src/pdf2json.cc +343 -0
  277. data/pdf2json-0.52-source/src/pdf2json.o +0 -0
  278. data/pdf2json-0.52-source/src/pdf2xml.dtd +22 -0
  279. data/pdf2json-0.52-source/src/pdf2xmljson.dtd +9 -0
  280. data/pdf2json-0.52-source/xpdf/.DS_Store +0 -0
  281. data/pdf2json-0.52-source/xpdf/Annot.cc +1556 -0
  282. data/pdf2json-0.52-source/xpdf/Annot.h +142 -0
  283. data/pdf2json-0.52-source/xpdf/Annot.o +0 -0
  284. data/pdf2json-0.52-source/xpdf/Array.cc +73 -0
  285. data/pdf2json-0.52-source/xpdf/Array.h +58 -0
  286. data/pdf2json-0.52-source/xpdf/Array.o +0 -0
  287. data/pdf2json-0.52-source/xpdf/BuiltinFont.cc +65 -0
  288. data/pdf2json-0.52-source/xpdf/BuiltinFont.h +57 -0
  289. data/pdf2json-0.52-source/xpdf/BuiltinFont.o +0 -0
  290. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.cc +4284 -0
  291. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.h +23 -0
  292. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.o +0 -0
  293. data/pdf2json-0.52-source/xpdf/CMap.cc +408 -0
  294. data/pdf2json-0.52-source/xpdf/CMap.h +102 -0
  295. data/pdf2json-0.52-source/xpdf/CMap.o +0 -0
  296. data/pdf2json-0.52-source/xpdf/Catalog.cc +374 -0
  297. data/pdf2json-0.52-source/xpdf/Catalog.h +97 -0
  298. data/pdf2json-0.52-source/xpdf/Catalog.o +0 -0
  299. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.cc +540 -0
  300. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.h +117 -0
  301. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.o +0 -0
  302. data/pdf2json-0.52-source/xpdf/CharTypes.h +24 -0
  303. data/pdf2json-0.52-source/xpdf/CompactFontTables.h +464 -0
  304. data/pdf2json-0.52-source/xpdf/CoreOutputDev.cc +61 -0
  305. data/pdf2json-0.52-source/xpdf/CoreOutputDev.h +61 -0
  306. data/pdf2json-0.52-source/xpdf/Decrypt.cc +776 -0
  307. data/pdf2json-0.52-source/xpdf/Decrypt.h +95 -0
  308. data/pdf2json-0.52-source/xpdf/Decrypt.o +0 -0
  309. data/pdf2json-0.52-source/xpdf/Dict.cc +95 -0
  310. data/pdf2json-0.52-source/xpdf/Dict.h +77 -0
  311. data/pdf2json-0.52-source/xpdf/Dict.o +0 -0
  312. data/pdf2json-0.52-source/xpdf/Error.cc +38 -0
  313. data/pdf2json-0.52-source/xpdf/Error.h +23 -0
  314. data/pdf2json-0.52-source/xpdf/Error.o +0 -0
  315. data/pdf2json-0.52-source/xpdf/ErrorCodes.h +36 -0
  316. data/pdf2json-0.52-source/xpdf/FontEncodingTables.cc +1824 -0
  317. data/pdf2json-0.52-source/xpdf/FontEncodingTables.h +20 -0
  318. data/pdf2json-0.52-source/xpdf/FontEncodingTables.o +0 -0
  319. data/pdf2json-0.52-source/xpdf/Function.cc +1573 -0
  320. data/pdf2json-0.52-source/xpdf/Function.h +229 -0
  321. data/pdf2json-0.52-source/xpdf/Function.o +0 -0
  322. data/pdf2json-0.52-source/xpdf/Gfx.cc +4187 -0
  323. data/pdf2json-0.52-source/xpdf/Gfx.h +312 -0
  324. data/pdf2json-0.52-source/xpdf/Gfx.o +0 -0
  325. data/pdf2json-0.52-source/xpdf/GfxFont.cc +1568 -0
  326. data/pdf2json-0.52-source/xpdf/GfxFont.h +320 -0
  327. data/pdf2json-0.52-source/xpdf/GfxFont.o +0 -0
  328. data/pdf2json-0.52-source/xpdf/GfxState.cc +4137 -0
  329. data/pdf2json-0.52-source/xpdf/GfxState.h +1244 -0
  330. data/pdf2json-0.52-source/xpdf/GfxState.o +0 -0
  331. data/pdf2json-0.52-source/xpdf/GlobalParams.cc +2924 -0
  332. data/pdf2json-0.52-source/xpdf/GlobalParams.cc.old +2908 -0
  333. data/pdf2json-0.52-source/xpdf/GlobalParams.h +466 -0
  334. data/pdf2json-0.52-source/xpdf/GlobalParams.h.old +463 -0
  335. data/pdf2json-0.52-source/xpdf/GlobalParams.o +0 -0
  336. data/pdf2json-0.52-source/xpdf/ImageOutputDev.cc +195 -0
  337. data/pdf2json-0.52-source/xpdf/ImageOutputDev.h +76 -0
  338. data/pdf2json-0.52-source/xpdf/ImageOutputDev.o +0 -0
  339. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.cc +322 -0
  340. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.h +109 -0
  341. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.o +0 -0
  342. data/pdf2json-0.52-source/xpdf/JBIG2Stream.cc +3413 -0
  343. data/pdf2json-0.52-source/xpdf/JBIG2Stream.h +145 -0
  344. data/pdf2json-0.52-source/xpdf/JBIG2Stream.o +0 -0
  345. data/pdf2json-0.52-source/xpdf/JPXStream.cc +3144 -0
  346. data/pdf2json-0.52-source/xpdf/JPXStream.h +351 -0
  347. data/pdf2json-0.52-source/xpdf/JPXStream.o +0 -0
  348. data/pdf2json-0.52-source/xpdf/Lexer.cc +485 -0
  349. data/pdf2json-0.52-source/xpdf/Lexer.h +80 -0
  350. data/pdf2json-0.52-source/xpdf/Lexer.o +0 -0
  351. data/pdf2json-0.52-source/xpdf/Link.cc +806 -0
  352. data/pdf2json-0.52-source/xpdf/Link.cc.old +784 -0
  353. data/pdf2json-0.52-source/xpdf/Link.h +415 -0
  354. data/pdf2json-0.52-source/xpdf/Link.h.old +369 -0
  355. data/pdf2json-0.52-source/xpdf/Link.o +0 -0
  356. data/pdf2json-0.52-source/xpdf/Makefile +232 -0
  357. data/pdf2json-0.52-source/xpdf/Makefile.dep +0 -0
  358. data/pdf2json-0.52-source/xpdf/Makefile.in +232 -0
  359. data/pdf2json-0.52-source/xpdf/NameToCharCode.cc +116 -0
  360. data/pdf2json-0.52-source/xpdf/NameToCharCode.h +42 -0
  361. data/pdf2json-0.52-source/xpdf/NameToCharCode.o +0 -0
  362. data/pdf2json-0.52-source/xpdf/NameToUnicodeTable.h +1097 -0
  363. data/pdf2json-0.52-source/xpdf/Object.cc +231 -0
  364. data/pdf2json-0.52-source/xpdf/Object.h +303 -0
  365. data/pdf2json-0.52-source/xpdf/Object.o +0 -0
  366. data/pdf2json-0.52-source/xpdf/Outline.cc +151 -0
  367. data/pdf2json-0.52-source/xpdf/Outline.h +76 -0
  368. data/pdf2json-0.52-source/xpdf/Outline.o +0 -0
  369. data/pdf2json-0.52-source/xpdf/OutputDev.cc +131 -0
  370. data/pdf2json-0.52-source/xpdf/OutputDev.h +253 -0
  371. data/pdf2json-0.52-source/xpdf/OutputDev.o +0 -0
  372. data/pdf2json-0.52-source/xpdf/PDFCore.cc +2044 -0
  373. data/pdf2json-0.52-source/xpdf/PDFCore.h +321 -0
  374. data/pdf2json-0.52-source/xpdf/PDFDoc.cc +404 -0
  375. data/pdf2json-0.52-source/xpdf/PDFDoc.h +183 -0
  376. data/pdf2json-0.52-source/xpdf/PDFDoc.o +0 -0
  377. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.cc +44 -0
  378. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.h +16 -0
  379. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.o +0 -0
  380. data/pdf2json-0.52-source/xpdf/PSOutputDev.cc +6224 -0
  381. data/pdf2json-0.52-source/xpdf/PSOutputDev.h +395 -0
  382. data/pdf2json-0.52-source/xpdf/PSOutputDev.o +0 -0
  383. data/pdf2json-0.52-source/xpdf/PSTokenizer.cc +135 -0
  384. data/pdf2json-0.52-source/xpdf/PSTokenizer.h +41 -0
  385. data/pdf2json-0.52-source/xpdf/PSTokenizer.o +0 -0
  386. data/pdf2json-0.52-source/xpdf/Page.cc +454 -0
  387. data/pdf2json-0.52-source/xpdf/Page.h +187 -0
  388. data/pdf2json-0.52-source/xpdf/Page.o +0 -0
  389. data/pdf2json-0.52-source/xpdf/Parser.cc +227 -0
  390. data/pdf2json-0.52-source/xpdf/Parser.h +59 -0
  391. data/pdf2json-0.52-source/xpdf/Parser.o +0 -0
  392. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.cc +257 -0
  393. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.h +130 -0
  394. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.o +0 -0
  395. data/pdf2json-0.52-source/xpdf/SecurityHandler.cc +390 -0
  396. data/pdf2json-0.52-source/xpdf/SecurityHandler.h +160 -0
  397. data/pdf2json-0.52-source/xpdf/SecurityHandler.o +0 -0
  398. data/pdf2json-0.52-source/xpdf/SplashOutputDev.cc +2845 -0
  399. data/pdf2json-0.52-source/xpdf/SplashOutputDev.h +247 -0
  400. data/pdf2json-0.52-source/xpdf/SplashOutputDev.o +0 -0
  401. data/pdf2json-0.52-source/xpdf/Stream-CCITT.h +459 -0
  402. data/pdf2json-0.52-source/xpdf/Stream.cc +4627 -0
  403. data/pdf2json-0.52-source/xpdf/Stream.h +858 -0
  404. data/pdf2json-0.52-source/xpdf/Stream.o +0 -0
  405. data/pdf2json-0.52-source/xpdf/TextOutputDev.cc +4090 -0
  406. data/pdf2json-0.52-source/xpdf/TextOutputDev.h +661 -0
  407. data/pdf2json-0.52-source/xpdf/TextOutputDev.o +0 -0
  408. data/pdf2json-0.52-source/xpdf/UTF8.h +56 -0
  409. data/pdf2json-0.52-source/xpdf/UnicodeMap.cc +302 -0
  410. data/pdf2json-0.52-source/xpdf/UnicodeMap.cc.old +293 -0
  411. data/pdf2json-0.52-source/xpdf/UnicodeMap.h +135 -0
  412. data/pdf2json-0.52-source/xpdf/UnicodeMap.h.old +123 -0
  413. data/pdf2json-0.52-source/xpdf/UnicodeMap.o +0 -0
  414. data/pdf2json-0.52-source/xpdf/UnicodeMapTables.h +361 -0
  415. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.cc +949 -0
  416. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.h +20 -0
  417. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.o +0 -0
  418. data/pdf2json-0.52-source/xpdf/XPDFApp.cc +447 -0
  419. data/pdf2json-0.52-source/xpdf/XPDFApp.h +114 -0
  420. data/pdf2json-0.52-source/xpdf/XPDFCore.cc +1655 -0
  421. data/pdf2json-0.52-source/xpdf/XPDFCore.h +251 -0
  422. data/pdf2json-0.52-source/xpdf/XPDFTree.cc +931 -0
  423. data/pdf2json-0.52-source/xpdf/XPDFTree.h +45 -0
  424. data/pdf2json-0.52-source/xpdf/XPDFTreeP.h +87 -0
  425. data/pdf2json-0.52-source/xpdf/XPDFViewer.cc +3488 -0
  426. data/pdf2json-0.52-source/xpdf/XPDFViewer.h +352 -0
  427. data/pdf2json-0.52-source/xpdf/XRef.cc +896 -0
  428. data/pdf2json-0.52-source/xpdf/XRef.h +133 -0
  429. data/pdf2json-0.52-source/xpdf/XRef.o +0 -0
  430. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.cc +262 -0
  431. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.h +341 -0
  432. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.o +0 -0
  433. data/pdf2json-0.52-source/xpdf/about-text.h +48 -0
  434. data/pdf2json-0.52-source/xpdf/about.xbm +6 -0
  435. data/pdf2json-0.52-source/xpdf/backArrow.xbm +6 -0
  436. data/pdf2json-0.52-source/xpdf/backArrowDis.xbm +6 -0
  437. data/pdf2json-0.52-source/xpdf/config.h +112 -0
  438. data/pdf2json-0.52-source/xpdf/dblLeftArrow.xbm +6 -0
  439. data/pdf2json-0.52-source/xpdf/dblLeftArrowDis.xbm +6 -0
  440. data/pdf2json-0.52-source/xpdf/dblRightArrow.xbm +6 -0
  441. data/pdf2json-0.52-source/xpdf/dblRightArrowDis.xbm +6 -0
  442. data/pdf2json-0.52-source/xpdf/find.xbm +6 -0
  443. data/pdf2json-0.52-source/xpdf/findDis.xbm +6 -0
  444. data/pdf2json-0.52-source/xpdf/forwardArrow.xbm +6 -0
  445. data/pdf2json-0.52-source/xpdf/forwardArrowDis.xbm +6 -0
  446. data/pdf2json-0.52-source/xpdf/leftArrow.xbm +5 -0
  447. data/pdf2json-0.52-source/xpdf/leftArrowDis.xbm +5 -0
  448. data/pdf2json-0.52-source/xpdf/libXpdf.a +0 -0
  449. data/pdf2json-0.52-source/xpdf/pdffonts +0 -0
  450. data/pdf2json-0.52-source/xpdf/pdffonts.cc +298 -0
  451. data/pdf2json-0.52-source/xpdf/pdffonts.o +0 -0
  452. data/pdf2json-0.52-source/xpdf/pdfimages +0 -0
  453. data/pdf2json-0.52-source/xpdf/pdfimages.cc +155 -0
  454. data/pdf2json-0.52-source/xpdf/pdfimages.o +0 -0
  455. data/pdf2json-0.52-source/xpdf/pdfinfo +0 -0
  456. data/pdf2json-0.52-source/xpdf/pdfinfo.cc +387 -0
  457. data/pdf2json-0.52-source/xpdf/pdfinfo.o +0 -0
  458. data/pdf2json-0.52-source/xpdf/pdftoppm.cc +203 -0
  459. data/pdf2json-0.52-source/xpdf/pdftops +0 -0
  460. data/pdf2json-0.52-source/xpdf/pdftops.cc +344 -0
  461. data/pdf2json-0.52-source/xpdf/pdftops.o +0 -0
  462. data/pdf2json-0.52-source/xpdf/pdftotext +0 -0
  463. data/pdf2json-0.52-source/xpdf/pdftotext.cc +333 -0
  464. data/pdf2json-0.52-source/xpdf/pdftotext.o +0 -0
  465. data/pdf2json-0.52-source/xpdf/print.xbm +6 -0
  466. data/pdf2json-0.52-source/xpdf/printDis.xbm +6 -0
  467. data/pdf2json-0.52-source/xpdf/rightArrow.xbm +5 -0
  468. data/pdf2json-0.52-source/xpdf/rightArrowDis.xbm +5 -0
  469. data/pdf2json-0.52-source/xpdf/vms_make.com +129 -0
  470. data/pdf2json-0.52-source/xpdf/xpdf.cc +344 -0
  471. data/pdf2json-0.52-source/xpdf/xpdfIcon.xpm +62 -0
  472. data/pdf2json.gemspec +29 -0
  473. metadata +518 -0
@@ -0,0 +1,2924 @@
1
+ //========================================================================
2
+ //
3
+ // GlobalParams.cc
4
+ //
5
+ // Copyright 2001-2003 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ #include <aconf.h>
10
+
11
+ #ifdef USE_GCC_PRAGMAS
12
+ #pragma implementation
13
+ #endif
14
+
15
+ #include <string.h>
16
+ #include <stdio.h>
17
+ #include <ctype.h>
18
+ #ifdef ENABLE_PLUGINS
19
+ # ifndef WIN32
20
+ # include <dlfcn.h>
21
+ # endif
22
+ #endif
23
+ #ifdef WIN32
24
+ # include <shlobj.h>
25
+ #endif
26
+ #if HAVE_PAPER_H
27
+ #include <paper.h>
28
+ #endif
29
+ #include "gmem.h"
30
+ #include "GString.h"
31
+ #include "GList.h"
32
+ #include "GHash.h"
33
+ #include "gfile.h"
34
+ #include "Error.h"
35
+ #include "NameToCharCode.h"
36
+ #include "CharCodeToUnicode.h"
37
+ #include "UnicodeMap.h"
38
+ #include "CMap.h"
39
+ #include "BuiltinFontTables.h"
40
+ #include "FontEncodingTables.h"
41
+ #ifdef ENABLE_PLUGINS
42
+ # include "XpdfPluginAPI.h"
43
+ #endif
44
+ #include "GlobalParams.h"
45
+
46
+ #ifdef WIN32
47
+ # define strcasecmp stricmp
48
+ #endif
49
+
50
+ #if MULTITHREADED
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)
57
+ #else
58
+ # define lockGlobalParams
59
+ # define lockUnicodeMapCache
60
+ # define lockCMapCache
61
+ # define unlockGlobalParams
62
+ # define unlockUnicodeMapCache
63
+ # define unlockCMapCache
64
+ #endif
65
+
66
+ #include "NameToUnicodeTable.h"
67
+ #include "UnicodeMapTables.h"
68
+ #include "UTF8.h"
69
+
70
+ #ifdef ENABLE_PLUGINS
71
+ # ifdef WIN32
72
+ extern XpdfPluginVecTable xpdfPluginVecTable;
73
+ # endif
74
+ #endif
75
+
76
+ //------------------------------------------------------------------------
77
+
78
+ #define cidToUnicodeCacheSize 4
79
+ #define unicodeToUnicodeCacheSize 4
80
+
81
+ //------------------------------------------------------------------------
82
+
83
+ static struct {
84
+ char *name;
85
+ char *t1FileName;
86
+ 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},
102
+ {NULL}
103
+ };
104
+
105
+ #ifdef WIN32
106
+ static char *displayFontDirs[] = {
107
+ "c:/windows/fonts",
108
+ "c:/winnt/fonts",
109
+ NULL
110
+ };
111
+ #else
112
+ static char *displayFontDirs[] = {
113
+ "/usr/share/ghostscript/fonts",
114
+ "/usr/local/share/ghostscript/fonts",
115
+ "/usr/share/fonts/default/Type1",
116
+ "/usr/share/fonts/default/ghostscript",
117
+ "/usr/share/fonts/type1/gsfonts",
118
+ NULL
119
+ };
120
+ #endif
121
+
122
+ //------------------------------------------------------------------------
123
+
124
+ GlobalParams *globalParams = NULL;
125
+
126
+ //------------------------------------------------------------------------
127
+ // DisplayFontParam
128
+ //------------------------------------------------------------------------
129
+
130
+ DisplayFontParam::DisplayFontParam(GString *nameA,
131
+ DisplayFontParamKind kindA) {
132
+ name = nameA;
133
+ kind = kindA;
134
+ switch (kind) {
135
+ case displayFontT1:
136
+ t1.fileName = NULL;
137
+ break;
138
+ case displayFontTT:
139
+ tt.fileName = NULL;
140
+ break;
141
+ }
142
+ }
143
+
144
+ DisplayFontParam::~DisplayFontParam() {
145
+ delete name;
146
+ switch (kind) {
147
+ case displayFontT1:
148
+ if (t1.fileName) {
149
+ delete t1.fileName;
150
+ }
151
+ break;
152
+ case displayFontTT:
153
+ if (tt.fileName) {
154
+ delete tt.fileName;
155
+ }
156
+ break;
157
+ }
158
+ }
159
+
160
+ #ifdef WIN32
161
+
162
+ //------------------------------------------------------------------------
163
+ // WinFontInfo
164
+ //------------------------------------------------------------------------
165
+
166
+ class WinFontInfo: public DisplayFontParam {
167
+ public:
168
+
169
+ GBool bold, italic;
170
+
171
+ static WinFontInfo *make(GString *nameA, GBool boldA, GBool italicA,
172
+ HKEY regKey, char *winFontDir);
173
+ WinFontInfo(GString *nameA, GBool boldA, GBool italicA,
174
+ GString *fileNameA);
175
+ virtual ~WinFontInfo();
176
+ GBool equals(WinFontInfo *fi);
177
+ };
178
+
179
+ WinFontInfo *WinFontInfo::make(GString *nameA, GBool boldA, GBool italicA,
180
+ HKEY regKey, char *winFontDir) {
181
+ GString *regName;
182
+ GString *fileNameA;
183
+ char buf[MAX_PATH];
184
+ DWORD n;
185
+ char c;
186
+ int i;
187
+
188
+ //----- find the font file
189
+ fileNameA = NULL;
190
+ regName = nameA->copy();
191
+ if (boldA) {
192
+ regName->append(" Bold");
193
+ }
194
+ if (italicA) {
195
+ regName->append(" Italic");
196
+ }
197
+ regName->append(" (TrueType)");
198
+ n = sizeof(buf);
199
+ if (RegQueryValueEx(regKey, regName->getCString(), NULL, NULL,
200
+ (LPBYTE)buf, &n) == ERROR_SUCCESS) {
201
+ fileNameA = new GString(winFontDir);
202
+ fileNameA->append('\\')->append(buf);
203
+ }
204
+ delete regName;
205
+ if (!fileNameA) {
206
+ delete nameA;
207
+ return NULL;
208
+ }
209
+
210
+ //----- normalize the font name
211
+ i = 0;
212
+ while (i < nameA->getLength()) {
213
+ c = nameA->getChar(i);
214
+ if (c == ' ' || c == ',' || c == '-') {
215
+ nameA->del(i);
216
+ } else {
217
+ ++i;
218
+ }
219
+ }
220
+
221
+ return new WinFontInfo(nameA, boldA, italicA, fileNameA);
222
+ }
223
+
224
+ WinFontInfo::WinFontInfo(GString *nameA, GBool boldA, GBool italicA,
225
+ GString *fileNameA):
226
+ DisplayFontParam(nameA, displayFontTT)
227
+ {
228
+ bold = boldA;
229
+ italic = italicA;
230
+ tt.fileName = fileNameA;
231
+ }
232
+
233
+ WinFontInfo::~WinFontInfo() {
234
+ }
235
+
236
+ GBool WinFontInfo::equals(WinFontInfo *fi) {
237
+ return !name->cmp(fi->name) && bold == fi->bold && italic == fi->italic;
238
+ }
239
+
240
+ //------------------------------------------------------------------------
241
+ // WinFontList
242
+ //------------------------------------------------------------------------
243
+
244
+ class WinFontList {
245
+ public:
246
+
247
+ WinFontList(char *winFontDirA);
248
+ ~WinFontList();
249
+ WinFontInfo *find(GString *font);
250
+
251
+ private:
252
+
253
+ void add(WinFontInfo *fi);
254
+ static int CALLBACK enumFunc1(CONST LOGFONT *font,
255
+ CONST TEXTMETRIC *metrics,
256
+ DWORD type, LPARAM data);
257
+ static int CALLBACK enumFunc2(CONST LOGFONT *font,
258
+ CONST TEXTMETRIC *metrics,
259
+ DWORD type, LPARAM data);
260
+
261
+ GList *fonts; // [WinFontInfo]
262
+ HDC dc; // (only used during enumeration)
263
+ HKEY regKey; // (only used during enumeration)
264
+ char *winFontDir; // (only used during enumeration)
265
+ };
266
+
267
+ WinFontList::WinFontList(char *winFontDirA) {
268
+ OSVERSIONINFO version;
269
+ char *path;
270
+
271
+ fonts = new GList();
272
+ dc = GetDC(NULL);
273
+ winFontDir = winFontDirA;
274
+ version.dwOSVersionInfoSize = sizeof(version);
275
+ GetVersionEx(&version);
276
+ if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
277
+ path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\";
278
+ } else {
279
+ path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts\\";
280
+ }
281
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0,
282
+ KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
283
+ &regKey) == ERROR_SUCCESS) {
284
+ EnumFonts(dc, NULL, &WinFontList::enumFunc1, (LPARAM)this);
285
+ RegCloseKey(regKey);
286
+ }
287
+ ReleaseDC(NULL, dc);
288
+ }
289
+
290
+ WinFontList::~WinFontList() {
291
+ deleteGList(fonts, WinFontInfo);
292
+ }
293
+
294
+ void WinFontList::add(WinFontInfo *fi) {
295
+ int i;
296
+
297
+ for (i = 0; i < fonts->getLength(); ++i) {
298
+ if (((WinFontInfo *)fonts->get(i))->equals(fi)) {
299
+ delete fi;
300
+ return;
301
+ }
302
+ }
303
+ fonts->append(fi);
304
+ }
305
+
306
+ WinFontInfo *WinFontList::find(GString *font) {
307
+ GString *name;
308
+ GBool bold, italic;
309
+ WinFontInfo *fi;
310
+ char c;
311
+ int n, i;
312
+
313
+ name = font->copy();
314
+
315
+ // remove space, comma, dash chars
316
+ i = 0;
317
+ while (i < name->getLength()) {
318
+ c = name->getChar(i);
319
+ if (c == ' ' || c == ',' || c == '-') {
320
+ name->del(i);
321
+ } else {
322
+ ++i;
323
+ }
324
+ }
325
+ n = name->getLength();
326
+
327
+ // remove trailing "MT" (Foo-MT, Foo-BoldMT, etc.)
328
+ if (!strcmp(name->getCString() + n - 2, "MT")) {
329
+ name->del(n - 2, 2);
330
+ n -= 2;
331
+ }
332
+
333
+ // look for "Italic"
334
+ if (!strcmp(name->getCString() + n - 6, "Italic")) {
335
+ name->del(n - 6, 6);
336
+ italic = gTrue;
337
+ n -= 6;
338
+ } else {
339
+ italic = gFalse;
340
+ }
341
+
342
+ // look for "Bold"
343
+ if (!strcmp(name->getCString() + n - 4, "Bold")) {
344
+ name->del(n - 4, 4);
345
+ bold = gTrue;
346
+ n -= 4;
347
+ } else {
348
+ bold = gFalse;
349
+ }
350
+
351
+ // remove trailing "MT" (FooMT-Bold, etc.)
352
+ if (!strcmp(name->getCString() + n - 2, "MT")) {
353
+ name->del(n - 2, 2);
354
+ n -= 2;
355
+ }
356
+
357
+ // remove trailing "PS"
358
+ if (!strcmp(name->getCString() + n - 2, "PS")) {
359
+ name->del(n - 2, 2);
360
+ n -= 2;
361
+ }
362
+
363
+ // search for the font
364
+ fi = NULL;
365
+ for (i = 0; i < fonts->getLength(); ++i) {
366
+ fi = (WinFontInfo *)fonts->get(i);
367
+ if (!fi->name->cmp(name) && fi->bold == bold && fi->italic == italic) {
368
+ break;
369
+ }
370
+ fi = NULL;
371
+ }
372
+
373
+ delete name;
374
+ return fi;
375
+ }
376
+
377
+ int CALLBACK WinFontList::enumFunc1(CONST LOGFONT *font,
378
+ CONST TEXTMETRIC *metrics,
379
+ DWORD type, LPARAM data) {
380
+ WinFontList *fl = (WinFontList *)data;
381
+
382
+ EnumFonts(fl->dc, font->lfFaceName, &WinFontList::enumFunc2, (LPARAM)fl);
383
+ return 1;
384
+ }
385
+
386
+ int CALLBACK WinFontList::enumFunc2(CONST LOGFONT *font,
387
+ CONST TEXTMETRIC *metrics,
388
+ DWORD type, LPARAM data) {
389
+ WinFontList *fl = (WinFontList *)data;
390
+ WinFontInfo *fi;
391
+
392
+ if (type & TRUETYPE_FONTTYPE) {
393
+ if ((fi = WinFontInfo::make(new GString(font->lfFaceName),
394
+ font->lfWeight >= 600,
395
+ font->lfItalic ? gTrue : gFalse,
396
+ fl->regKey, fl->winFontDir))) {
397
+ fl->add(fi);
398
+ }
399
+ }
400
+ return 1;
401
+ }
402
+
403
+ #endif // WIN32
404
+
405
+ //------------------------------------------------------------------------
406
+ // PSFontParam
407
+ //------------------------------------------------------------------------
408
+
409
+ PSFontParam::PSFontParam(GString *pdfFontNameA, int wModeA,
410
+ GString *psFontNameA, GString *encodingA) {
411
+ pdfFontName = pdfFontNameA;
412
+ wMode = wModeA;
413
+ psFontName = psFontNameA;
414
+ encoding = encodingA;
415
+ }
416
+
417
+ PSFontParam::~PSFontParam() {
418
+ delete pdfFontName;
419
+ delete psFontName;
420
+ if (encoding) {
421
+ delete encoding;
422
+ }
423
+ }
424
+
425
+ //------------------------------------------------------------------------
426
+ // KeyBinding
427
+ //------------------------------------------------------------------------
428
+
429
+ KeyBinding::KeyBinding(int codeA, int modsA, int contextA, char *cmd0) {
430
+ code = codeA;
431
+ mods = modsA;
432
+ context = contextA;
433
+ cmds = new GList();
434
+ cmds->append(new GString(cmd0));
435
+ }
436
+
437
+ KeyBinding::KeyBinding(int codeA, int modsA, int contextA,
438
+ char *cmd0, char *cmd1) {
439
+ code = codeA;
440
+ mods = modsA;
441
+ context = contextA;
442
+ cmds = new GList();
443
+ cmds->append(new GString(cmd0));
444
+ cmds->append(new GString(cmd1));
445
+ }
446
+
447
+ KeyBinding::KeyBinding(int codeA, int modsA, int contextA, GList *cmdsA) {
448
+ code = codeA;
449
+ mods = modsA;
450
+ context = contextA;
451
+ cmds = cmdsA;
452
+ }
453
+
454
+ KeyBinding::~KeyBinding() {
455
+ deleteGList(cmds, GString);
456
+ }
457
+
458
+ #ifdef ENABLE_PLUGINS
459
+ //------------------------------------------------------------------------
460
+ // Plugin
461
+ //------------------------------------------------------------------------
462
+
463
+ class Plugin {
464
+ public:
465
+
466
+ static Plugin *load(char *type, char *name);
467
+ ~Plugin();
468
+
469
+ private:
470
+
471
+ #ifdef WIN32
472
+ Plugin(HMODULE libA);
473
+ HMODULE lib;
474
+ #else
475
+ Plugin(void *dlA);
476
+ void *dl;
477
+ #endif
478
+ };
479
+
480
+ Plugin *Plugin::load(char *type, char *name) {
481
+ GString *path;
482
+ Plugin *plugin;
483
+ XpdfPluginVecTable *vt;
484
+ XpdfBool (*xpdfInitPlugin)(void);
485
+ #ifdef WIN32
486
+ HMODULE libA;
487
+ #else
488
+ void *dlA;
489
+ #endif
490
+
491
+ path = globalParams->getBaseDir();
492
+ appendToPath(path, "plugins");
493
+ appendToPath(path, type);
494
+ appendToPath(path, name);
495
+
496
+ #ifdef WIN32
497
+ path->append(".dll");
498
+ if (!(libA = LoadLibrary(path->getCString()))) {
499
+ error(-1, "Failed to load plugin '%s'",
500
+ path->getCString());
501
+ goto err1;
502
+ }
503
+ if (!(vt = (XpdfPluginVecTable *)
504
+ GetProcAddress(libA, "xpdfPluginVecTable"))) {
505
+ error(-1, "Failed to find xpdfPluginVecTable in plugin '%s'",
506
+ path->getCString());
507
+ goto err2;
508
+ }
509
+ #else
510
+ //~ need to deal with other extensions here
511
+ path->append(".so");
512
+ if (!(dlA = dlopen(path->getCString(), RTLD_NOW))) {
513
+ error(-1, "Failed to load plugin '%s': %s",
514
+ path->getCString(), dlerror());
515
+ goto err1;
516
+ }
517
+ if (!(vt = (XpdfPluginVecTable *)dlsym(dlA, "xpdfPluginVecTable"))) {
518
+ error(-1, "Failed to find xpdfPluginVecTable in plugin '%s'",
519
+ path->getCString());
520
+ goto err2;
521
+ }
522
+ #endif
523
+
524
+ if (vt->version != xpdfPluginVecTable.version) {
525
+ error(-1, "Plugin '%s' is wrong version", path->getCString());
526
+ goto err2;
527
+ }
528
+ memcpy(vt, &xpdfPluginVecTable, sizeof(xpdfPluginVecTable));
529
+
530
+ #ifdef WIN32
531
+ if (!(xpdfInitPlugin = (XpdfBool (*)(void))
532
+ GetProcAddress(libA, "xpdfInitPlugin"))) {
533
+ error(-1, "Failed to find xpdfInitPlugin in plugin '%s'",
534
+ path->getCString());
535
+ goto err2;
536
+ }
537
+ #else
538
+ if (!(xpdfInitPlugin = (XpdfBool (*)(void))dlsym(dlA, "xpdfInitPlugin"))) {
539
+ error(-1, "Failed to find xpdfInitPlugin in plugin '%s'",
540
+ path->getCString());
541
+ goto err2;
542
+ }
543
+ #endif
544
+
545
+ if (!(*xpdfInitPlugin)()) {
546
+ error(-1, "Initialization of plugin '%s' failed",
547
+ path->getCString());
548
+ goto err2;
549
+ }
550
+
551
+ #ifdef WIN32
552
+ plugin = new Plugin(libA);
553
+ #else
554
+ plugin = new Plugin(dlA);
555
+ #endif
556
+
557
+ delete path;
558
+ return plugin;
559
+
560
+ err2:
561
+ #ifdef WIN32
562
+ FreeLibrary(libA);
563
+ #else
564
+ dlclose(dlA);
565
+ #endif
566
+ err1:
567
+ delete path;
568
+ return NULL;
569
+ }
570
+
571
+ #ifdef WIN32
572
+ Plugin::Plugin(HMODULE libA) {
573
+ lib = libA;
574
+ }
575
+ #else
576
+ Plugin::Plugin(void *dlA) {
577
+ dl = dlA;
578
+ }
579
+ #endif
580
+
581
+ Plugin::~Plugin() {
582
+ void (*xpdfFreePlugin)(void);
583
+
584
+ #ifdef WIN32
585
+ if ((xpdfFreePlugin = (void (*)(void))
586
+ GetProcAddress(lib, "xpdfFreePlugin"))) {
587
+ (*xpdfFreePlugin)();
588
+ }
589
+ FreeLibrary(lib);
590
+ #else
591
+ if ((xpdfFreePlugin = (void (*)(void))dlsym(dl, "xpdfFreePlugin"))) {
592
+ (*xpdfFreePlugin)();
593
+ }
594
+ dlclose(dl);
595
+ #endif
596
+ }
597
+
598
+ #endif // ENABLE_PLUGINS
599
+
600
+ //------------------------------------------------------------------------
601
+ // parsing
602
+ //------------------------------------------------------------------------
603
+
604
+ GlobalParams::GlobalParams(char *cfgFileName) {
605
+ UnicodeMap *map;
606
+ GString *fileName;
607
+ FILE *f;
608
+ int i;
609
+
610
+ #if MULTITHREADED
611
+ gInitMutex(&mutex);
612
+ gInitMutex(&unicodeMapCacheMutex);
613
+ gInitMutex(&cMapCacheMutex);
614
+ #endif
615
+
616
+ initBuiltinFontTables();
617
+
618
+ // scan the encoding in reverse because we want the lowest-numbered
619
+ // index for each char name ('space' is encoded twice)
620
+ macRomanReverseMap = new NameToCharCode();
621
+ for (i = 255; i >= 0; --i) {
622
+ if (macRomanEncoding[i]) {
623
+ macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
624
+ }
625
+ }
626
+
627
+ #ifdef WIN32
628
+ // baseDir will be set by a call to setBaseDir
629
+ baseDir = new GString();
630
+ #else
631
+ baseDir = appendToPath(getHomeDir(), ".xpdf");
632
+ #endif
633
+ nameToUnicode = new NameToCharCode();
634
+ cidToUnicodes = new GHash(gTrue);
635
+ unicodeToUnicodes = new GHash(gTrue);
636
+ residentUnicodeMaps = new GHash();
637
+ unicodeMaps = new GHash(gTrue);
638
+ cMapDirs = new GHash(gTrue);
639
+ toUnicodeDirs = new GList();
640
+ displayFonts = new GHash();
641
+ displayCIDFonts = new GHash();
642
+ displayNamedCIDFonts = new GHash();
643
+ #if HAVE_PAPER_H
644
+ char *paperName;
645
+ const struct paper *paperType;
646
+ paperinit();
647
+ if ((paperName = systempapername())) {
648
+ paperType = paperinfo(paperName);
649
+ psPaperWidth = (int)paperpswidth(paperType);
650
+ psPaperHeight = (int)paperpsheight(paperType);
651
+ } else {
652
+ error(-1, "No paper information available - using defaults");
653
+ psPaperWidth = defPaperWidth;
654
+ psPaperHeight = defPaperHeight;
655
+ }
656
+ paperdone();
657
+ #else
658
+ psPaperWidth = defPaperWidth;
659
+ psPaperHeight = defPaperHeight;
660
+ #endif
661
+ psImageableLLX = psImageableLLY = 0;
662
+ psImageableURX = psPaperWidth;
663
+ psImageableURY = psPaperHeight;
664
+ psCrop = gTrue;
665
+ psExpandSmaller = gFalse;
666
+ psShrinkLarger = gTrue;
667
+ psCenter = gTrue;
668
+ psDuplex = gFalse;
669
+ psLevel = psLevel2;
670
+ psFile = NULL;
671
+ psFonts = new GHash();
672
+ psNamedFonts16 = new GList();
673
+ psFonts16 = new GList();
674
+ psEmbedType1 = gTrue;
675
+ psEmbedTrueType = gTrue;
676
+ psEmbedCIDPostScript = gTrue;
677
+ psEmbedCIDTrueType = gTrue;
678
+ psPreload = gFalse;
679
+ psOPI = gFalse;
680
+ psASCIIHex = gFalse;
681
+ textEncoding = new GString("Latin1");
682
+ #if defined(WIN32)
683
+ textEOL = eolDOS;
684
+ #elif defined(MACOS)
685
+ textEOL = eolMac;
686
+ #else
687
+ textEOL = eolUnix;
688
+ #endif
689
+ textPageBreaks = gTrue;
690
+ textKeepTinyChars = gFalse;
691
+ fontDirs = new GList();
692
+ initialZoom = new GString("125");
693
+ continuousView = gFalse;
694
+ enableT1lib = gTrue;
695
+ enableFreeType = gTrue;
696
+ antialias = gTrue;
697
+ vectorAntialias = gTrue;
698
+ strokeAdjust = gTrue;
699
+ screenType = screenUnset;
700
+ screenSize = -1;
701
+ screenDotRadius = -1;
702
+ screenGamma = 1.0;
703
+ screenBlackThreshold = 0.0;
704
+ screenWhiteThreshold = 1.0;
705
+ urlCommand = NULL;
706
+ movieCommand = NULL;
707
+ mapNumericCharNames = gTrue;
708
+ mapUnknownCharNames = gFalse;
709
+ createDefaultKeyBindings();
710
+ printCommands = gFalse;
711
+ errQuiet = gFalse;
712
+
713
+ cidToUnicodeCache = new CharCodeToUnicodeCache(cidToUnicodeCacheSize);
714
+ unicodeToUnicodeCache =
715
+ new CharCodeToUnicodeCache(unicodeToUnicodeCacheSize);
716
+ unicodeMapCache = new UnicodeMapCache();
717
+ cMapCache = new CMapCache();
718
+
719
+ #ifdef WIN32
720
+ winFontList = NULL;
721
+ #endif
722
+
723
+ #ifdef ENABLE_PLUGINS
724
+ plugins = new GList();
725
+ securityHandlers = new GList();
726
+ #endif
727
+
728
+ // set up the initial nameToUnicode table
729
+ for (i = 0; nameToUnicodeTab[i].name; ++i) {
730
+ nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
731
+ }
732
+
733
+ // set up the residentUnicodeMaps table
734
+ map = new UnicodeMap("Latin1", gFalse,
735
+ latin1UnicodeMapRanges, latin1UnicodeMapLen);
736
+ residentUnicodeMaps->add(map->getEncodingName(), map);
737
+ map = new UnicodeMap("ASCII7", gFalse,
738
+ ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
739
+ residentUnicodeMaps->add(map->getEncodingName(), map);
740
+ map = new UnicodeMap("Symbol", gFalse,
741
+ symbolUnicodeMapRanges, symbolUnicodeMapLen);
742
+ residentUnicodeMaps->add(map->getEncodingName(), map);
743
+ map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
744
+ zapfDingbatsUnicodeMapLen);
745
+ residentUnicodeMaps->add(map->getEncodingName(), map);
746
+ map = new UnicodeMap("UTF-8", gTrue, &mapUTF8);
747
+ residentUnicodeMaps->add(map->getEncodingName(), map);
748
+ map = new UnicodeMap("UCS-2", gTrue, &mapUCS2);
749
+ residentUnicodeMaps->add(map->getEncodingName(), map);
750
+
751
+ // look for a user config file, then a system-wide config file
752
+ f = NULL;
753
+ fileName = NULL;
754
+ if (cfgFileName && cfgFileName[0]) {
755
+ fileName = new GString(cfgFileName);
756
+ if (!(f = fopen(fileName->getCString(), "r"))) {
757
+ delete fileName;
758
+ }
759
+ }
760
+ if (!f) {
761
+ fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
762
+ if (!(f = fopen(fileName->getCString(), "r"))) {
763
+ delete fileName;
764
+ }
765
+ }
766
+ if (!f) {
767
+ #if defined(WIN32) && !defined(__CYGWIN32__)
768
+ char buf[512];
769
+ i = GetModuleFileName(NULL, buf, sizeof(buf));
770
+ if (i <= 0 || i >= sizeof(buf)) {
771
+ // error or path too long for buffer - just use the current dir
772
+ buf[0] = '\0';
773
+ }
774
+ fileName = grabPath(buf);
775
+ appendToPath(fileName, xpdfSysConfigFile);
776
+ #else
777
+ fileName = new GString(xpdfSysConfigFile);
778
+ #endif
779
+ if (!(f = fopen(fileName->getCString(), "r"))) {
780
+ delete fileName;
781
+ }
782
+ }
783
+ if (f) {
784
+ parseFile(fileName, f);
785
+ delete fileName;
786
+ fclose(f);
787
+ }
788
+ }
789
+
790
+ void GlobalParams::createDefaultKeyBindings() {
791
+ keyBindings = new GList();
792
+
793
+ //----- mouse buttons
794
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress1, xpdfKeyModNone,
795
+ xpdfKeyContextAny, "startSelection"));
796
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease1, xpdfKeyModNone,
797
+ xpdfKeyContextAny, "endSelection",
798
+ "followLinkNoSel"));
799
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress2, xpdfKeyModNone,
800
+ xpdfKeyContextAny, "startPan"));
801
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease2, xpdfKeyModNone,
802
+ xpdfKeyContextAny, "endPan"));
803
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress3, xpdfKeyModNone,
804
+ xpdfKeyContextAny, "postPopupMenu"));
805
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress4, xpdfKeyModNone,
806
+ xpdfKeyContextAny,
807
+ "scrollUpPrevPage(16)"));
808
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress5, xpdfKeyModNone,
809
+ xpdfKeyContextAny,
810
+ "scrollDownNextPage(16)"));
811
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress6, xpdfKeyModNone,
812
+ xpdfKeyContextAny, "scrollLeft(16)"));
813
+ keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress7, xpdfKeyModNone,
814
+ xpdfKeyContextAny, "scrollRight(16)"));
815
+
816
+ //----- keys
817
+ keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModCtrl,
818
+ xpdfKeyContextAny, "gotoPage(1)"));
819
+ keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModNone,
820
+ xpdfKeyContextAny, "scrollToTopLeft"));
821
+ keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModCtrl,
822
+ xpdfKeyContextAny, "gotoLastPage"));
823
+ keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModNone,
824
+ xpdfKeyContextAny,
825
+ "scrollToBottomRight"));
826
+ keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModNone,
827
+ xpdfKeyContextAny, "pageUp"));
828
+ keyBindings->append(new KeyBinding(xpdfKeyCodeBackspace, xpdfKeyModNone,
829
+ xpdfKeyContextAny, "pageUp"));
830
+ keyBindings->append(new KeyBinding(xpdfKeyCodeDelete, xpdfKeyModNone,
831
+ xpdfKeyContextAny, "pageUp"));
832
+ keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModNone,
833
+ xpdfKeyContextAny, "pageDown"));
834
+ keyBindings->append(new KeyBinding(' ', xpdfKeyModNone,
835
+ xpdfKeyContextAny, "pageDown"));
836
+ keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModNone,
837
+ xpdfKeyContextAny, "scrollLeft(16)"));
838
+ keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModNone,
839
+ xpdfKeyContextAny, "scrollRight(16)"));
840
+ keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModNone,
841
+ xpdfKeyContextAny, "scrollUp(16)"));
842
+ keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModNone,
843
+ xpdfKeyContextAny, "scrollDown(16)"));
844
+ keyBindings->append(new KeyBinding('o', xpdfKeyModNone,
845
+ xpdfKeyContextAny, "open"));
846
+ keyBindings->append(new KeyBinding('O', xpdfKeyModNone,
847
+ xpdfKeyContextAny, "open"));
848
+ keyBindings->append(new KeyBinding('r', xpdfKeyModNone,
849
+ xpdfKeyContextAny, "reload"));
850
+ keyBindings->append(new KeyBinding('R', xpdfKeyModNone,
851
+ xpdfKeyContextAny, "reload"));
852
+ keyBindings->append(new KeyBinding('f', xpdfKeyModNone,
853
+ xpdfKeyContextAny, "find"));
854
+ keyBindings->append(new KeyBinding('F', xpdfKeyModNone,
855
+ xpdfKeyContextAny, "find"));
856
+ keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl,
857
+ xpdfKeyContextAny, "find"));
858
+ keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl,
859
+ xpdfKeyContextAny, "findNext"));
860
+ keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl,
861
+ xpdfKeyContextAny, "print"));
862
+ keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
863
+ xpdfKeyContextScrLockOff, "nextPage"));
864
+ keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
865
+ xpdfKeyContextScrLockOff, "nextPage"));
866
+ keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
867
+ xpdfKeyContextScrLockOn,
868
+ "nextPageNoScroll"));
869
+ keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
870
+ xpdfKeyContextScrLockOn,
871
+ "nextPageNoScroll"));
872
+ keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
873
+ xpdfKeyContextScrLockOff, "prevPage"));
874
+ keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
875
+ xpdfKeyContextScrLockOff, "prevPage"));
876
+ keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
877
+ xpdfKeyContextScrLockOn,
878
+ "prevPageNoScroll"));
879
+ keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
880
+ xpdfKeyContextScrLockOn,
881
+ "prevPageNoScroll"));
882
+ keyBindings->append(new KeyBinding('v', xpdfKeyModNone,
883
+ xpdfKeyContextAny, "goForward"));
884
+ keyBindings->append(new KeyBinding('b', xpdfKeyModNone,
885
+ xpdfKeyContextAny, "goBackward"));
886
+ keyBindings->append(new KeyBinding('g', xpdfKeyModNone,
887
+ xpdfKeyContextAny, "focusToPageNum"));
888
+ keyBindings->append(new KeyBinding('0', xpdfKeyModNone,
889
+ xpdfKeyContextAny, "zoomPercent(125)"));
890
+ keyBindings->append(new KeyBinding('+', xpdfKeyModNone,
891
+ xpdfKeyContextAny, "zoomIn"));
892
+ keyBindings->append(new KeyBinding('-', xpdfKeyModNone,
893
+ xpdfKeyContextAny, "zoomOut"));
894
+ keyBindings->append(new KeyBinding('z', xpdfKeyModNone,
895
+ xpdfKeyContextAny, "zoomFitPage"));
896
+ keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
897
+ xpdfKeyContextAny, "zoomFitWidth"));
898
+ keyBindings->append(new KeyBinding('f', xpdfKeyModAlt,
899
+ xpdfKeyContextAny,
900
+ "toggleFullScreenMode"));
901
+ keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl,
902
+ xpdfKeyContextAny, "redraw"));
903
+ keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
904
+ xpdfKeyContextAny, "closeWindow"));
905
+ keyBindings->append(new KeyBinding('?', xpdfKeyModNone,
906
+ xpdfKeyContextAny, "about"));
907
+ keyBindings->append(new KeyBinding('q', xpdfKeyModNone,
908
+ xpdfKeyContextAny, "quit"));
909
+ keyBindings->append(new KeyBinding('Q', xpdfKeyModNone,
910
+ xpdfKeyContextAny, "quit"));
911
+ }
912
+
913
+ void GlobalParams::parseFile(GString *fileName, FILE *f) {
914
+ int line;
915
+ char buf[512];
916
+
917
+ line = 1;
918
+ while (getLine(buf, sizeof(buf) - 1, f)) {
919
+ parseLine(buf, fileName, line);
920
+ ++line;
921
+ }
922
+ }
923
+
924
+ void GlobalParams::parseLine(char *buf, GString *fileName, int line) {
925
+ GList *tokens;
926
+ GString *cmd, *incFile;
927
+ char *p1, *p2;
928
+ FILE *f2;
929
+
930
+ // break the line into tokens
931
+ tokens = new GList();
932
+ p1 = buf;
933
+ while (*p1) {
934
+ for (; *p1 && isspace(*p1); ++p1) ;
935
+ if (!*p1) {
936
+ break;
937
+ }
938
+ if (*p1 == '"' || *p1 == '\'') {
939
+ for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
940
+ ++p1;
941
+ } else {
942
+ for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
943
+ }
944
+ tokens->append(new GString(p1, p2 - p1));
945
+ p1 = *p2 ? p2 + 1 : p2;
946
+ }
947
+
948
+ // parse the line
949
+ if (tokens->getLength() > 0 &&
950
+ ((GString *)tokens->get(0))->getChar(0) != '#') {
951
+ cmd = (GString *)tokens->get(0);
952
+ if (!cmd->cmp("include")) {
953
+ if (tokens->getLength() == 2) {
954
+ incFile = (GString *)tokens->get(1);
955
+ if ((f2 = fopen(incFile->getCString(), "r"))) {
956
+ parseFile(incFile, f2);
957
+ fclose(f2);
958
+ } else {
959
+ error(-1, "Couldn't find included config file: '%s' (%s:%d)",
960
+ incFile->getCString(), fileName->getCString(), line);
961
+ }
962
+ } else {
963
+ error(-1, "Bad 'include' config file command (%s:%d)",
964
+ fileName->getCString(), line);
965
+ }
966
+ } else if (!cmd->cmp("nameToUnicode")) {
967
+ parseNameToUnicode(tokens, fileName, line);
968
+ } else if (!cmd->cmp("cidToUnicode")) {
969
+ parseCIDToUnicode(tokens, fileName, line);
970
+ } else if (!cmd->cmp("unicodeToUnicode")) {
971
+ parseUnicodeToUnicode(tokens, fileName, line);
972
+ } else if (!cmd->cmp("unicodeMap")) {
973
+ parseUnicodeMap(tokens, fileName, line);
974
+ } else if (!cmd->cmp("cMapDir")) {
975
+ parseCMapDir(tokens, fileName, line);
976
+ } else if (!cmd->cmp("toUnicodeDir")) {
977
+ parseToUnicodeDir(tokens, fileName, line);
978
+ } else if (!cmd->cmp("displayFontT1")) {
979
+ parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
980
+ } else if (!cmd->cmp("displayFontTT")) {
981
+ parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
982
+ } else if (!cmd->cmp("displayNamedCIDFontT1")) {
983
+ parseDisplayFont(tokens, displayNamedCIDFonts,
984
+ displayFontT1, fileName, line);
985
+ } else if (!cmd->cmp("displayCIDFontT1")) {
986
+ parseDisplayFont(tokens, displayCIDFonts,
987
+ displayFontT1, fileName, line);
988
+ } else if (!cmd->cmp("displayNamedCIDFontTT")) {
989
+ parseDisplayFont(tokens, displayNamedCIDFonts,
990
+ displayFontTT, fileName, line);
991
+ } else if (!cmd->cmp("displayCIDFontTT")) {
992
+ parseDisplayFont(tokens, displayCIDFonts,
993
+ displayFontTT, fileName, line);
994
+ } else if (!cmd->cmp("psFile")) {
995
+ parsePSFile(tokens, fileName, line);
996
+ } else if (!cmd->cmp("psFont")) {
997
+ parsePSFont(tokens, fileName, line);
998
+ } else if (!cmd->cmp("psNamedFont16")) {
999
+ parsePSFont16("psNamedFont16", psNamedFonts16,
1000
+ tokens, fileName, line);
1001
+ } else if (!cmd->cmp("psFont16")) {
1002
+ parsePSFont16("psFont16", psFonts16, tokens, fileName, line);
1003
+ } else if (!cmd->cmp("psPaperSize")) {
1004
+ parsePSPaperSize(tokens, fileName, line);
1005
+ } else if (!cmd->cmp("psImageableArea")) {
1006
+ parsePSImageableArea(tokens, fileName, line);
1007
+ } else if (!cmd->cmp("psCrop")) {
1008
+ parseYesNo("psCrop", &psCrop, tokens, fileName, line);
1009
+ } else if (!cmd->cmp("psExpandSmaller")) {
1010
+ parseYesNo("psExpandSmaller", &psExpandSmaller,
1011
+ tokens, fileName, line);
1012
+ } else if (!cmd->cmp("psShrinkLarger")) {
1013
+ parseYesNo("psShrinkLarger", &psShrinkLarger, tokens, fileName, line);
1014
+ } else if (!cmd->cmp("psCenter")) {
1015
+ parseYesNo("psCenter", &psCenter, tokens, fileName, line);
1016
+ } else if (!cmd->cmp("psDuplex")) {
1017
+ parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
1018
+ } else if (!cmd->cmp("psLevel")) {
1019
+ parsePSLevel(tokens, fileName, line);
1020
+ } else if (!cmd->cmp("psEmbedType1Fonts")) {
1021
+ parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
1022
+ } else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
1023
+ parseYesNo("psEmbedTrueType", &psEmbedTrueType,
1024
+ tokens, fileName, line);
1025
+ } else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
1026
+ parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
1027
+ tokens, fileName, line);
1028
+ } else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
1029
+ parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
1030
+ tokens, fileName, line);
1031
+ } else if (!cmd->cmp("psPreload")) {
1032
+ parseYesNo("psPreload", &psPreload, tokens, fileName, line);
1033
+ } else if (!cmd->cmp("psOPI")) {
1034
+ parseYesNo("psOPI", &psOPI, tokens, fileName, line);
1035
+ } else if (!cmd->cmp("psASCIIHex")) {
1036
+ parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
1037
+ } else if (!cmd->cmp("textEncoding")) {
1038
+ parseTextEncoding(tokens, fileName, line);
1039
+ } else if (!cmd->cmp("textEOL")) {
1040
+ parseTextEOL(tokens, fileName, line);
1041
+ } else if (!cmd->cmp("textPageBreaks")) {
1042
+ parseYesNo("textPageBreaks", &textPageBreaks,
1043
+ tokens, fileName, line);
1044
+ } else if (!cmd->cmp("textKeepTinyChars")) {
1045
+ parseYesNo("textKeepTinyChars", &textKeepTinyChars,
1046
+ tokens, fileName, line);
1047
+ } else if (!cmd->cmp("fontDir")) {
1048
+ parseFontDir(tokens, fileName, line);
1049
+ } else if (!cmd->cmp("initialZoom")) {
1050
+ parseInitialZoom(tokens, fileName, line);
1051
+ } else if (!cmd->cmp("continuousView")) {
1052
+ parseYesNo("continuousView", &continuousView, tokens, fileName, line);
1053
+ } else if (!cmd->cmp("enableT1lib")) {
1054
+ parseYesNo("enableT1lib", &enableT1lib, tokens, fileName, line);
1055
+ } else if (!cmd->cmp("enableFreeType")) {
1056
+ parseYesNo("enableFreeType", &enableFreeType, tokens, fileName, line);
1057
+ } else if (!cmd->cmp("antialias")) {
1058
+ parseYesNo("antialias", &antialias, tokens, fileName, line);
1059
+ } else if (!cmd->cmp("vectorAntialias")) {
1060
+ parseYesNo("vectorAntialias", &vectorAntialias,
1061
+ tokens, fileName, line);
1062
+ } else if (!cmd->cmp("strokeAdjust")) {
1063
+ parseYesNo("strokeAdjust", &strokeAdjust, tokens, fileName, line);
1064
+ } else if (!cmd->cmp("screenType")) {
1065
+ parseScreenType(tokens, fileName, line);
1066
+ } else if (!cmd->cmp("screenSize")) {
1067
+ parseInteger("screenSize", &screenSize, tokens, fileName, line);
1068
+ } else if (!cmd->cmp("screenDotRadius")) {
1069
+ parseInteger("screenDotRadius", &screenDotRadius,
1070
+ tokens, fileName, line);
1071
+ } else if (!cmd->cmp("screenGamma")) {
1072
+ parseFloat("screenGamma", &screenGamma,
1073
+ tokens, fileName, line);
1074
+ } else if (!cmd->cmp("screenBlackThreshold")) {
1075
+ parseFloat("screenBlackThreshold", &screenBlackThreshold,
1076
+ tokens, fileName, line);
1077
+ } else if (!cmd->cmp("screenWhiteThreshold")) {
1078
+ parseFloat("screenWhiteThreshold", &screenWhiteThreshold,
1079
+ tokens, fileName, line);
1080
+ } else if (!cmd->cmp("urlCommand")) {
1081
+ parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
1082
+ } else if (!cmd->cmp("movieCommand")) {
1083
+ parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
1084
+ } else if (!cmd->cmp("mapNumericCharNames")) {
1085
+ parseYesNo("mapNumericCharNames", &mapNumericCharNames,
1086
+ tokens, fileName, line);
1087
+ } else if (!cmd->cmp("mapUnknownCharNames")) {
1088
+ parseYesNo("mapUnknownCharNames", &mapUnknownCharNames,
1089
+ tokens, fileName, line);
1090
+ } else if (!cmd->cmp("bind")) {
1091
+ parseBind(tokens, fileName, line);
1092
+ } else if (!cmd->cmp("unbind")) {
1093
+ parseUnbind(tokens, fileName, line);
1094
+ } else if (!cmd->cmp("printCommands")) {
1095
+ parseYesNo("printCommands", &printCommands, tokens, fileName, line);
1096
+ } else if (!cmd->cmp("errQuiet")) {
1097
+ parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
1098
+ } else {
1099
+ error(-1, "Unknown config file command '%s' (%s:%d)",
1100
+ cmd->getCString(), fileName->getCString(), line);
1101
+ if (!cmd->cmp("displayFontX") ||
1102
+ !cmd->cmp("displayNamedCIDFontX") ||
1103
+ !cmd->cmp("displayCIDFontX")) {
1104
+ error(-1, "-- Xpdf no longer supports X fonts");
1105
+ } else if (!cmd->cmp("t1libControl") || !cmd->cmp("freetypeControl")) {
1106
+ error(-1, "-- The t1libControl and freetypeControl options have been replaced");
1107
+ error(-1, " by the enableT1lib, enableFreeType, and antialias options");
1108
+ } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
1109
+ error(-1, "-- the config file format has changed since Xpdf 0.9x");
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ deleteGList(tokens, GString);
1115
+ }
1116
+
1117
+ void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
1118
+ int line) {
1119
+ GString *name;
1120
+ char *tok1, *tok2;
1121
+ FILE *f;
1122
+ char buf[256];
1123
+ int line2;
1124
+ Unicode u;
1125
+
1126
+ if (tokens->getLength() != 2) {
1127
+ error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
1128
+ fileName->getCString(), line);
1129
+ return;
1130
+ }
1131
+ name = (GString *)tokens->get(1);
1132
+ if (!(f = fopen(name->getCString(), "r"))) {
1133
+ error(-1, "Couldn't open 'nameToUnicode' file '%s'",
1134
+ name->getCString());
1135
+ return;
1136
+ }
1137
+ line2 = 1;
1138
+ while (getLine(buf, sizeof(buf), f)) {
1139
+ tok1 = strtok(buf, " \t\r\n");
1140
+ tok2 = strtok(NULL, " \t\r\n");
1141
+ if (tok1 && tok2) {
1142
+ sscanf(tok1, "%x", &u);
1143
+ nameToUnicode->add(tok2, u);
1144
+ } else {
1145
+ error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", name, line2);
1146
+ }
1147
+ ++line2;
1148
+ }
1149
+ fclose(f);
1150
+ }
1151
+
1152
+ void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
1153
+ int line) {
1154
+ GString *collection, *name, *old;
1155
+
1156
+ if (tokens->getLength() != 3) {
1157
+ error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
1158
+ fileName->getCString(), line);
1159
+ return;
1160
+ }
1161
+ collection = (GString *)tokens->get(1);
1162
+ name = (GString *)tokens->get(2);
1163
+ if ((old = (GString *)cidToUnicodes->remove(collection))) {
1164
+ delete old;
1165
+ }
1166
+ cidToUnicodes->add(collection->copy(), name->copy());
1167
+ }
1168
+
1169
+ void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
1170
+ int line) {
1171
+ GString *font, *file, *old;
1172
+
1173
+ if (tokens->getLength() != 3) {
1174
+ error(-1, "Bad 'unicodeToUnicode' config file command (%s:%d)",
1175
+ fileName->getCString(), line);
1176
+ return;
1177
+ }
1178
+ font = (GString *)tokens->get(1);
1179
+ file = (GString *)tokens->get(2);
1180
+ if ((old = (GString *)unicodeToUnicodes->remove(font))) {
1181
+ delete old;
1182
+ }
1183
+ unicodeToUnicodes->add(font->copy(), file->copy());
1184
+ }
1185
+
1186
+ void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
1187
+ int line) {
1188
+ GString *encodingName, *name, *old;
1189
+
1190
+ if (tokens->getLength() != 3) {
1191
+ error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
1192
+ fileName->getCString(), line);
1193
+ return;
1194
+ }
1195
+ encodingName = (GString *)tokens->get(1);
1196
+ name = (GString *)tokens->get(2);
1197
+ if ((old = (GString *)unicodeMaps->remove(encodingName))) {
1198
+ delete old;
1199
+ }
1200
+ unicodeMaps->add(encodingName->copy(), name->copy());
1201
+ }
1202
+
1203
+ void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
1204
+ GString *collection, *dir;
1205
+ GList *list;
1206
+
1207
+ if (tokens->getLength() != 3) {
1208
+ error(-1, "Bad 'cMapDir' config file command (%s:%d)",
1209
+ fileName->getCString(), line);
1210
+ return;
1211
+ }
1212
+ collection = (GString *)tokens->get(1);
1213
+ dir = (GString *)tokens->get(2);
1214
+ if (!(list = (GList *)cMapDirs->lookup(collection))) {
1215
+ list = new GList();
1216
+ cMapDirs->add(collection->copy(), list);
1217
+ }
1218
+ list->append(dir->copy());
1219
+ }
1220
+
1221
+ void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
1222
+ int line) {
1223
+ if (tokens->getLength() != 2) {
1224
+ error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
1225
+ fileName->getCString(), line);
1226
+ return;
1227
+ }
1228
+ toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
1229
+ }
1230
+
1231
+ void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
1232
+ DisplayFontParamKind kind,
1233
+ GString *fileName, int line) {
1234
+ DisplayFontParam *param, *old;
1235
+
1236
+ if (tokens->getLength() < 2) {
1237
+ goto err1;
1238
+ }
1239
+ param = new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);
1240
+
1241
+ switch (kind) {
1242
+ case displayFontT1:
1243
+ if (tokens->getLength() != 3) {
1244
+ goto err2;
1245
+ }
1246
+ param->t1.fileName = ((GString *)tokens->get(2))->copy();
1247
+ break;
1248
+ case displayFontTT:
1249
+ if (tokens->getLength() != 3) {
1250
+ goto err2;
1251
+ }
1252
+ param->tt.fileName = ((GString *)tokens->get(2))->copy();
1253
+ break;
1254
+ }
1255
+
1256
+ if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
1257
+ delete old;
1258
+ }
1259
+ fontHash->add(param->name, param);
1260
+ return;
1261
+
1262
+ err2:
1263
+ delete param;
1264
+ err1:
1265
+ error(-1, "Bad 'display*Font*' config file command (%s:%d)",
1266
+ fileName->getCString(), line);
1267
+ }
1268
+
1269
+ void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
1270
+ int line) {
1271
+ GString *tok;
1272
+
1273
+ if (tokens->getLength() == 2) {
1274
+ tok = (GString *)tokens->get(1);
1275
+ if (!setPSPaperSize(tok->getCString())) {
1276
+ error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
1277
+ fileName->getCString(), line);
1278
+ }
1279
+ } else if (tokens->getLength() == 3) {
1280
+ tok = (GString *)tokens->get(1);
1281
+ psPaperWidth = atoi(tok->getCString());
1282
+ tok = (GString *)tokens->get(2);
1283
+ psPaperHeight = atoi(tok->getCString());
1284
+ psImageableLLX = psImageableLLY = 0;
1285
+ psImageableURX = psPaperWidth;
1286
+ psImageableURY = psPaperHeight;
1287
+ } else {
1288
+ error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
1289
+ fileName->getCString(), line);
1290
+ }
1291
+ }
1292
+
1293
+ void GlobalParams::parsePSImageableArea(GList *tokens, GString *fileName,
1294
+ int line) {
1295
+ if (tokens->getLength() != 5) {
1296
+ error(-1, "Bad 'psImageableArea' config file command (%s:%d)",
1297
+ fileName->getCString(), line);
1298
+ return;
1299
+ }
1300
+ psImageableLLX = atoi(((GString *)tokens->get(1))->getCString());
1301
+ psImageableLLY = atoi(((GString *)tokens->get(2))->getCString());
1302
+ psImageableURX = atoi(((GString *)tokens->get(3))->getCString());
1303
+ psImageableURY = atoi(((GString *)tokens->get(4))->getCString());
1304
+ }
1305
+
1306
+ void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {
1307
+ GString *tok;
1308
+
1309
+ if (tokens->getLength() != 2) {
1310
+ error(-1, "Bad 'psLevel' config file command (%s:%d)",
1311
+ fileName->getCString(), line);
1312
+ return;
1313
+ }
1314
+ tok = (GString *)tokens->get(1);
1315
+ if (!tok->cmp("level1")) {
1316
+ psLevel = psLevel1;
1317
+ } else if (!tok->cmp("level1sep")) {
1318
+ psLevel = psLevel1Sep;
1319
+ } else if (!tok->cmp("level2")) {
1320
+ psLevel = psLevel2;
1321
+ } else if (!tok->cmp("level2sep")) {
1322
+ psLevel = psLevel2Sep;
1323
+ } else if (!tok->cmp("level3")) {
1324
+ psLevel = psLevel3;
1325
+ } else if (!tok->cmp("level3Sep")) {
1326
+ psLevel = psLevel3Sep;
1327
+ } else {
1328
+ error(-1, "Bad 'psLevel' config file command (%s:%d)",
1329
+ fileName->getCString(), line);
1330
+ }
1331
+ }
1332
+
1333
+ void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {
1334
+ if (tokens->getLength() != 2) {
1335
+ error(-1, "Bad 'psFile' config file command (%s:%d)",
1336
+ fileName->getCString(), line);
1337
+ return;
1338
+ }
1339
+ if (psFile) {
1340
+ delete psFile;
1341
+ }
1342
+ psFile = ((GString *)tokens->get(1))->copy();
1343
+ }
1344
+
1345
+ void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {
1346
+ PSFontParam *param;
1347
+
1348
+ if (tokens->getLength() != 3) {
1349
+ error(-1, "Bad 'psFont' config file command (%s:%d)",
1350
+ fileName->getCString(), line);
1351
+ return;
1352
+ }
1353
+ param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
1354
+ ((GString *)tokens->get(2))->copy(), NULL);
1355
+ psFonts->add(param->pdfFontName, param);
1356
+ }
1357
+
1358
+ void GlobalParams::parsePSFont16(char *cmdName, GList *fontList,
1359
+ GList *tokens, GString *fileName, int line) {
1360
+ PSFontParam *param;
1361
+ int wMode;
1362
+ GString *tok;
1363
+
1364
+ if (tokens->getLength() != 5) {
1365
+ error(-1, "Bad '%s' config file command (%s:%d)",
1366
+ cmdName, fileName->getCString(), line);
1367
+ return;
1368
+ }
1369
+ tok = (GString *)tokens->get(2);
1370
+ if (!tok->cmp("H")) {
1371
+ wMode = 0;
1372
+ } else if (!tok->cmp("V")) {
1373
+ wMode = 1;
1374
+ } else {
1375
+ error(-1, "Bad '%s' config file command (%s:%d)",
1376
+ cmdName, fileName->getCString(), line);
1377
+ return;
1378
+ }
1379
+ param = new PSFontParam(((GString *)tokens->get(1))->copy(),
1380
+ wMode,
1381
+ ((GString *)tokens->get(3))->copy(),
1382
+ ((GString *)tokens->get(4))->copy());
1383
+ fontList->append(param);
1384
+ }
1385
+
1386
+ void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
1387
+ int line) {
1388
+ if (tokens->getLength() != 2) {
1389
+ error(-1, "Bad 'textEncoding' config file command (%s:%d)",
1390
+ fileName->getCString(), line);
1391
+ return;
1392
+ }
1393
+ delete textEncoding;
1394
+ textEncoding = ((GString *)tokens->get(1))->copy();
1395
+ }
1396
+
1397
+ void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {
1398
+ GString *tok;
1399
+
1400
+ if (tokens->getLength() != 2) {
1401
+ error(-1, "Bad 'textEOL' config file command (%s:%d)",
1402
+ fileName->getCString(), line);
1403
+ return;
1404
+ }
1405
+ tok = (GString *)tokens->get(1);
1406
+ if (!tok->cmp("unix")) {
1407
+ textEOL = eolUnix;
1408
+ } else if (!tok->cmp("dos")) {
1409
+ textEOL = eolDOS;
1410
+ } else if (!tok->cmp("mac")) {
1411
+ textEOL = eolMac;
1412
+ } else {
1413
+ error(-1, "Bad 'textEOL' config file command (%s:%d)",
1414
+ fileName->getCString(), line);
1415
+ }
1416
+ }
1417
+
1418
+ void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {
1419
+ if (tokens->getLength() != 2) {
1420
+ error(-1, "Bad 'fontDir' config file command (%s:%d)",
1421
+ fileName->getCString(), line);
1422
+ return;
1423
+ }
1424
+ fontDirs->append(((GString *)tokens->get(1))->copy());
1425
+ }
1426
+
1427
+ void GlobalParams::parseInitialZoom(GList *tokens,
1428
+ GString *fileName, int line) {
1429
+ if (tokens->getLength() != 2) {
1430
+ error(-1, "Bad 'initialZoom' config file command (%s:%d)",
1431
+ fileName->getCString(), line);
1432
+ return;
1433
+ }
1434
+ delete initialZoom;
1435
+ initialZoom = ((GString *)tokens->get(1))->copy();
1436
+ }
1437
+
1438
+ void GlobalParams::parseScreenType(GList *tokens, GString *fileName,
1439
+ int line) {
1440
+ GString *tok;
1441
+
1442
+ if (tokens->getLength() != 2) {
1443
+ error(-1, "Bad 'screenType' config file command (%s:%d)",
1444
+ fileName->getCString(), line);
1445
+ return;
1446
+ }
1447
+ tok = (GString *)tokens->get(1);
1448
+ if (!tok->cmp("dispersed")) {
1449
+ screenType = screenDispersed;
1450
+ } else if (!tok->cmp("clustered")) {
1451
+ screenType = screenClustered;
1452
+ } else if (!tok->cmp("stochasticClustered")) {
1453
+ screenType = screenStochasticClustered;
1454
+ } else {
1455
+ error(-1, "Bad 'screenType' config file command (%s:%d)",
1456
+ fileName->getCString(), line);
1457
+ }
1458
+ }
1459
+
1460
+ void GlobalParams::parseBind(GList *tokens, GString *fileName, int line) {
1461
+ KeyBinding *binding;
1462
+ GList *cmds;
1463
+ int code, mods, context, i;
1464
+
1465
+ if (tokens->getLength() < 4) {
1466
+ error(-1, "Bad 'bind' config file command (%s:%d)",
1467
+ fileName->getCString(), line);
1468
+ return;
1469
+ }
1470
+ if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2),
1471
+ &code, &mods, &context,
1472
+ "bind", tokens, fileName, line)) {
1473
+ return;
1474
+ }
1475
+ for (i = 0; i < keyBindings->getLength(); ++i) {
1476
+ binding = (KeyBinding *)keyBindings->get(i);
1477
+ if (binding->code == code &&
1478
+ binding->mods == mods &&
1479
+ binding->context == context) {
1480
+ delete (KeyBinding *)keyBindings->del(i);
1481
+ break;
1482
+ }
1483
+ }
1484
+ cmds = new GList();
1485
+ for (i = 3; i < tokens->getLength(); ++i) {
1486
+ cmds->append(((GString *)tokens->get(i))->copy());
1487
+ }
1488
+ keyBindings->append(new KeyBinding(code, mods, context, cmds));
1489
+ }
1490
+
1491
+ void GlobalParams::parseUnbind(GList *tokens, GString *fileName, int line) {
1492
+ KeyBinding *binding;
1493
+ int code, mods, context, i;
1494
+
1495
+ if (tokens->getLength() != 3) {
1496
+ error(-1, "Bad 'unbind' config file command (%s:%d)",
1497
+ fileName->getCString(), line);
1498
+ return;
1499
+ }
1500
+ if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2),
1501
+ &code, &mods, &context,
1502
+ "unbind", tokens, fileName, line)) {
1503
+ return;
1504
+ }
1505
+ for (i = 0; i < keyBindings->getLength(); ++i) {
1506
+ binding = (KeyBinding *)keyBindings->get(i);
1507
+ if (binding->code == code &&
1508
+ binding->mods == mods &&
1509
+ binding->context == context) {
1510
+ delete (KeyBinding *)keyBindings->del(i);
1511
+ break;
1512
+ }
1513
+ }
1514
+ }
1515
+
1516
+ GBool GlobalParams::parseKey(GString *modKeyStr, GString *contextStr,
1517
+ int *code, int *mods, int *context,
1518
+ char *cmdName,
1519
+ GList *tokens, GString *fileName, int line) {
1520
+ char *p0;
1521
+
1522
+ *mods = xpdfKeyModNone;
1523
+ p0 = modKeyStr->getCString();
1524
+ while (1) {
1525
+ if (!strncmp(p0, "shift-", 6)) {
1526
+ *mods |= xpdfKeyModShift;
1527
+ p0 += 6;
1528
+ } else if (!strncmp(p0, "ctrl-", 5)) {
1529
+ *mods |= xpdfKeyModCtrl;
1530
+ p0 += 5;
1531
+ } else if (!strncmp(p0, "alt-", 4)) {
1532
+ *mods |= xpdfKeyModAlt;
1533
+ p0 += 4;
1534
+ } else {
1535
+ break;
1536
+ }
1537
+ }
1538
+
1539
+ if (!strcmp(p0, "space")) {
1540
+ *code = ' ';
1541
+ } else if (!strcmp(p0, "tab")) {
1542
+ *code = xpdfKeyCodeTab;
1543
+ } else if (!strcmp(p0, "return")) {
1544
+ *code = xpdfKeyCodeReturn;
1545
+ } else if (!strcmp(p0, "enter")) {
1546
+ *code = xpdfKeyCodeEnter;
1547
+ } else if (!strcmp(p0, "backspace")) {
1548
+ *code = xpdfKeyCodeBackspace;
1549
+ } else if (!strcmp(p0, "insert")) {
1550
+ *code = xpdfKeyCodeInsert;
1551
+ } else if (!strcmp(p0, "delete")) {
1552
+ *code = xpdfKeyCodeDelete;
1553
+ } else if (!strcmp(p0, "home")) {
1554
+ *code = xpdfKeyCodeHome;
1555
+ } else if (!strcmp(p0, "end")) {
1556
+ *code = xpdfKeyCodeEnd;
1557
+ } else if (!strcmp(p0, "pgup")) {
1558
+ *code = xpdfKeyCodePgUp;
1559
+ } else if (!strcmp(p0, "pgdn")) {
1560
+ *code = xpdfKeyCodePgDn;
1561
+ } else if (!strcmp(p0, "left")) {
1562
+ *code = xpdfKeyCodeLeft;
1563
+ } else if (!strcmp(p0, "right")) {
1564
+ *code = xpdfKeyCodeRight;
1565
+ } else if (!strcmp(p0, "up")) {
1566
+ *code = xpdfKeyCodeUp;
1567
+ } else if (!strcmp(p0, "down")) {
1568
+ *code = xpdfKeyCodeDown;
1569
+ } else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) {
1570
+ *code = xpdfKeyCodeF1 + (p0[1] - '1');
1571
+ } else if (p0[0] == 'f' &&
1572
+ ((p0[1] >= '1' && p0[1] <= '2' && p0[2] >= '0' && p0[2] <= '9') ||
1573
+ (p0[1] == '3' && p0[2] >= '0' && p0[2] <= '5')) &&
1574
+ !p0[3]) {
1575
+ *code = xpdfKeyCodeF1 + 10 * (p0[1] - '0') + (p0[2] - '0') - 1;
1576
+ } else if (!strncmp(p0, "mousePress", 10) &&
1577
+ p0[10] >= '1' && p0[10] <= '7' && !p0[11]) {
1578
+ *code = xpdfKeyCodeMousePress1 + (p0[10] - '1');
1579
+ } else if (!strncmp(p0, "mouseRelease", 12) &&
1580
+ p0[12] >= '1' && p0[12] <= '7' && !p0[13]) {
1581
+ *code = xpdfKeyCodeMouseRelease1 + (p0[12] - '1');
1582
+ } else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) {
1583
+ *code = (int)*p0;
1584
+ } else {
1585
+ error(-1, "Bad key/modifier in '%s' config file command (%s:%d)",
1586
+ cmdName, fileName->getCString(), line);
1587
+ return gFalse;
1588
+ }
1589
+
1590
+ p0 = contextStr->getCString();
1591
+ if (!strcmp(p0, "any")) {
1592
+ *context = xpdfKeyContextAny;
1593
+ } else {
1594
+ *context = xpdfKeyContextAny;
1595
+ while (1) {
1596
+ if (!strncmp(p0, "fullScreen", 10)) {
1597
+ *context |= xpdfKeyContextFullScreen;
1598
+ p0 += 10;
1599
+ } else if (!strncmp(p0, "window", 6)) {
1600
+ *context |= xpdfKeyContextWindow;
1601
+ p0 += 6;
1602
+ } else if (!strncmp(p0, "continuous", 10)) {
1603
+ *context |= xpdfKeyContextContinuous;
1604
+ p0 += 10;
1605
+ } else if (!strncmp(p0, "singlePage", 10)) {
1606
+ *context |= xpdfKeyContextSinglePage;
1607
+ p0 += 10;
1608
+ } else if (!strncmp(p0, "overLink", 8)) {
1609
+ *context |= xpdfKeyContextOverLink;
1610
+ p0 += 8;
1611
+ } else if (!strncmp(p0, "offLink", 7)) {
1612
+ *context |= xpdfKeyContextOffLink;
1613
+ p0 += 7;
1614
+ } else if (!strncmp(p0, "outline", 7)) {
1615
+ *context |= xpdfKeyContextOutline;
1616
+ p0 += 7;
1617
+ } else if (!strncmp(p0, "mainWin", 7)) {
1618
+ *context |= xpdfKeyContextMainWin;
1619
+ p0 += 7;
1620
+ } else if (!strncmp(p0, "scrLockOn", 9)) {
1621
+ *context |= xpdfKeyContextScrLockOn;
1622
+ p0 += 9;
1623
+ } else if (!strncmp(p0, "scrLockOff", 10)) {
1624
+ *context |= xpdfKeyContextScrLockOff;
1625
+ p0 += 10;
1626
+ } else {
1627
+ error(-1, "Bad context in '%s' config file command (%s:%d)",
1628
+ cmdName, fileName->getCString(), line);
1629
+ return gFalse;
1630
+ }
1631
+ if (!*p0) {
1632
+ break;
1633
+ }
1634
+ if (*p0 != ',') {
1635
+ error(-1, "Bad context in '%s' config file command (%s:%d)",
1636
+ cmdName, fileName->getCString(), line);
1637
+ return gFalse;
1638
+ }
1639
+ ++p0;
1640
+ }
1641
+ }
1642
+
1643
+ return gTrue;
1644
+ }
1645
+
1646
+ void GlobalParams::parseCommand(char *cmdName, GString **val,
1647
+ GList *tokens, GString *fileName, int line) {
1648
+ if (tokens->getLength() != 2) {
1649
+ error(-1, "Bad '%s' config file command (%s:%d)",
1650
+ cmdName, fileName->getCString(), line);
1651
+ return;
1652
+ }
1653
+ if (*val) {
1654
+ delete *val;
1655
+ }
1656
+ *val = ((GString *)tokens->get(1))->copy();
1657
+ }
1658
+
1659
+ void GlobalParams::parseYesNo(char *cmdName, GBool *flag,
1660
+ GList *tokens, GString *fileName, int line) {
1661
+ GString *tok;
1662
+
1663
+ if (tokens->getLength() != 2) {
1664
+ error(-1, "Bad '%s' config file command (%s:%d)",
1665
+ cmdName, fileName->getCString(), line);
1666
+ return;
1667
+ }
1668
+ tok = (GString *)tokens->get(1);
1669
+ if (!parseYesNo2(tok->getCString(), flag)) {
1670
+ error(-1, "Bad '%s' config file command (%s:%d)",
1671
+ cmdName, fileName->getCString(), line);
1672
+ }
1673
+ }
1674
+
1675
+ GBool GlobalParams::parseYesNo2(char *token, GBool *flag) {
1676
+ if (!strcmp(token, "yes")) {
1677
+ *flag = gTrue;
1678
+ } else if (!strcmp(token, "no")) {
1679
+ *flag = gFalse;
1680
+ } else {
1681
+ return gFalse;
1682
+ }
1683
+ return gTrue;
1684
+ }
1685
+
1686
+ void GlobalParams::parseInteger(char *cmdName, int *val,
1687
+ GList *tokens, GString *fileName, int line) {
1688
+ GString *tok;
1689
+ int i;
1690
+
1691
+ if (tokens->getLength() != 2) {
1692
+ error(-1, "Bad '%s' config file command (%s:%d)",
1693
+ cmdName, fileName->getCString(), line);
1694
+ return;
1695
+ }
1696
+ tok = (GString *)tokens->get(1);
1697
+ if (tok->getLength() == 0) {
1698
+ error(-1, "Bad '%s' config file command (%s:%d)",
1699
+ cmdName, fileName->getCString(), line);
1700
+ return;
1701
+ }
1702
+ if (tok->getChar(0) == '-') {
1703
+ i = 1;
1704
+ } else {
1705
+ i = 0;
1706
+ }
1707
+ for (; i < tok->getLength(); ++i) {
1708
+ if (tok->getChar(i) < '0' || tok->getChar(i) > '9') {
1709
+ error(-1, "Bad '%s' config file command (%s:%d)",
1710
+ cmdName, fileName->getCString(), line);
1711
+ return;
1712
+ }
1713
+ }
1714
+ *val = atoi(tok->getCString());
1715
+ }
1716
+
1717
+ void GlobalParams::parseFloat(char *cmdName, double *val,
1718
+ GList *tokens, GString *fileName, int line) {
1719
+ GString *tok;
1720
+ int i;
1721
+
1722
+ if (tokens->getLength() != 2) {
1723
+ error(-1, "Bad '%s' config file command (%s:%d)",
1724
+ cmdName, fileName->getCString(), line);
1725
+ return;
1726
+ }
1727
+ tok = (GString *)tokens->get(1);
1728
+ if (tok->getLength() == 0) {
1729
+ error(-1, "Bad '%s' config file command (%s:%d)",
1730
+ cmdName, fileName->getCString(), line);
1731
+ return;
1732
+ }
1733
+ if (tok->getChar(0) == '-') {
1734
+ i = 1;
1735
+ } else {
1736
+ i = 0;
1737
+ }
1738
+ for (; i < tok->getLength(); ++i) {
1739
+ if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') ||
1740
+ tok->getChar(i) == '.')) {
1741
+ error(-1, "Bad '%s' config file command (%s:%d)",
1742
+ cmdName, fileName->getCString(), line);
1743
+ return;
1744
+ }
1745
+ }
1746
+ *val = atof(tok->getCString());
1747
+ }
1748
+
1749
+ GlobalParams::~GlobalParams() {
1750
+ GHashIter *iter;
1751
+ GString *key;
1752
+ GList *list;
1753
+
1754
+ freeBuiltinFontTables();
1755
+
1756
+ delete macRomanReverseMap;
1757
+
1758
+ delete baseDir;
1759
+ delete nameToUnicode;
1760
+ deleteGHash(cidToUnicodes, GString);
1761
+ deleteGHash(unicodeToUnicodes, GString);
1762
+ deleteGHash(residentUnicodeMaps, UnicodeMap);
1763
+ deleteGHash(unicodeMaps, GString);
1764
+ deleteGList(toUnicodeDirs, GString);
1765
+ deleteGHash(displayFonts, DisplayFontParam);
1766
+ deleteGHash(displayCIDFonts, DisplayFontParam);
1767
+ deleteGHash(displayNamedCIDFonts, DisplayFontParam);
1768
+ #ifdef WIN32
1769
+ if (winFontList) {
1770
+ delete winFontList;
1771
+ }
1772
+ #endif
1773
+ if (psFile) {
1774
+ delete psFile;
1775
+ }
1776
+ deleteGHash(psFonts, PSFontParam);
1777
+ deleteGList(psNamedFonts16, PSFontParam);
1778
+ deleteGList(psFonts16, PSFontParam);
1779
+ delete textEncoding;
1780
+ deleteGList(fontDirs, GString);
1781
+ delete initialZoom;
1782
+ if (urlCommand) {
1783
+ delete urlCommand;
1784
+ }
1785
+ if (movieCommand) {
1786
+ delete movieCommand;
1787
+ }
1788
+ deleteGList(keyBindings, KeyBinding);
1789
+
1790
+ cMapDirs->startIter(&iter);
1791
+ while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
1792
+ deleteGList(list, GString);
1793
+ }
1794
+ delete cMapDirs;
1795
+
1796
+ delete cidToUnicodeCache;
1797
+ delete unicodeToUnicodeCache;
1798
+ delete unicodeMapCache;
1799
+ delete cMapCache;
1800
+
1801
+ #ifdef ENABLE_PLUGINS
1802
+ delete securityHandlers;
1803
+ deleteGList(plugins, Plugin);
1804
+ #endif
1805
+
1806
+ #if MULTITHREADED
1807
+ gDestroyMutex(&mutex);
1808
+ gDestroyMutex(&unicodeMapCacheMutex);
1809
+ gDestroyMutex(&cMapCacheMutex);
1810
+ #endif
1811
+ }
1812
+
1813
+ //------------------------------------------------------------------------
1814
+
1815
+ void GlobalParams::setBaseDir(char *dir) {
1816
+ delete baseDir;
1817
+ baseDir = new GString(dir);
1818
+ }
1819
+
1820
+ void GlobalParams::setupBaseFonts(char *dir) {
1821
+ GString *fontName;
1822
+ GString *fileName;
1823
+ #ifdef WIN32
1824
+ HMODULE shell32Lib;
1825
+ BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner,
1826
+ LPTSTR lpszPath,
1827
+ int nFolder,
1828
+ BOOL fCreate);
1829
+ char winFontDir[MAX_PATH];
1830
+ #endif
1831
+ FILE *f;
1832
+ DisplayFontParamKind kind;
1833
+ DisplayFontParam *dfp;
1834
+ int i, j;
1835
+
1836
+ #ifdef WIN32
1837
+ // SHGetSpecialFolderPath isn't available in older versions of
1838
+ // shell32.dll (Win95 and WinNT4), so do a dynamic load
1839
+ winFontDir[0] = '\0';
1840
+ if ((shell32Lib = LoadLibrary("shell32.dll"))) {
1841
+ if ((SHGetSpecialFolderPathFunc =
1842
+ (BOOL (__stdcall *)(HWND hwndOwner, LPTSTR lpszPath,
1843
+ int nFolder, BOOL fCreate))
1844
+ GetProcAddress(shell32Lib, "SHGetSpecialFolderPathA"))) {
1845
+ if (!(*SHGetSpecialFolderPathFunc)(NULL, winFontDir,
1846
+ CSIDL_FONTS, FALSE)) {
1847
+ winFontDir[0] = '\0';
1848
+ }
1849
+ }
1850
+ }
1851
+ #endif
1852
+ for (i = 0; displayFontTab[i].name; ++i) {
1853
+ fontName = new GString(displayFontTab[i].name);
1854
+ if (getDisplayFont(fontName)) {
1855
+ delete fontName;
1856
+ continue;
1857
+ }
1858
+ fileName = NULL;
1859
+ kind = displayFontT1; // make gcc happy
1860
+ if (dir) {
1861
+ fileName = appendToPath(new GString(dir), displayFontTab[i].t1FileName);
1862
+ kind = displayFontT1;
1863
+ if ((f = fopen(fileName->getCString(), "rb"))) {
1864
+ fclose(f);
1865
+ } else {
1866
+ delete fileName;
1867
+ fileName = NULL;
1868
+ }
1869
+ }
1870
+ #ifdef WIN32
1871
+ if (!fileName && winFontDir[0] && displayFontTab[i].ttFileName) {
1872
+ fileName = appendToPath(new GString(winFontDir),
1873
+ displayFontTab[i].ttFileName);
1874
+ kind = displayFontTT;
1875
+ if ((f = fopen(fileName->getCString(), "rb"))) {
1876
+ fclose(f);
1877
+ } else {
1878
+ delete fileName;
1879
+ fileName = NULL;
1880
+ }
1881
+ }
1882
+ // SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server
1883
+ // or Win2003 Server, or with older versions of shell32.dll, so check
1884
+ // the "standard" directories
1885
+ if (displayFontTab[i].ttFileName) {
1886
+ for (j = 0; !fileName && displayFontDirs[j]; ++j) {
1887
+ fileName = appendToPath(new GString(displayFontDirs[j]),
1888
+ displayFontTab[i].ttFileName);
1889
+ kind = displayFontTT;
1890
+ if ((f = fopen(fileName->getCString(), "rb"))) {
1891
+ fclose(f);
1892
+ } else {
1893
+ delete fileName;
1894
+ fileName = NULL;
1895
+ }
1896
+ }
1897
+ }
1898
+ #else
1899
+ for (j = 0; !fileName && displayFontDirs[j]; ++j) {
1900
+ fileName = appendToPath(new GString(displayFontDirs[j]),
1901
+ displayFontTab[i].t1FileName);
1902
+ kind = displayFontT1;
1903
+ if ((f = fopen(fileName->getCString(), "rb"))) {
1904
+ fclose(f);
1905
+ } else {
1906
+ delete fileName;
1907
+ fileName = NULL;
1908
+ }
1909
+ }
1910
+ #endif
1911
+ if (!fileName) {
1912
+ error(-1, "No display font for '%s'", displayFontTab[i].name);
1913
+ delete fontName;
1914
+ continue;
1915
+ }
1916
+ dfp = new DisplayFontParam(fontName, kind);
1917
+ dfp->t1.fileName = fileName;
1918
+ globalParams->addDisplayFont(dfp);
1919
+ }
1920
+
1921
+ #ifdef WIN32
1922
+ if (winFontDir[0]) {
1923
+ winFontList = new WinFontList(winFontDir);
1924
+ }
1925
+ #endif
1926
+ }
1927
+
1928
+ //------------------------------------------------------------------------
1929
+ // accessors
1930
+ //------------------------------------------------------------------------
1931
+
1932
+ CharCode GlobalParams::getMacRomanCharCode(char *charName) {
1933
+ // no need to lock - macRomanReverseMap is constant
1934
+ return macRomanReverseMap->lookup(charName);
1935
+ }
1936
+
1937
+ GString *GlobalParams::getBaseDir() {
1938
+ GString *s;
1939
+
1940
+ lockGlobalParams;
1941
+ s = baseDir->copy();
1942
+ unlockGlobalParams;
1943
+ return s;
1944
+ }
1945
+
1946
+ Unicode GlobalParams::mapNameToUnicode(char *charName) {
1947
+ // no need to lock - nameToUnicode is constant
1948
+ return nameToUnicode->lookup(charName);
1949
+ }
1950
+
1951
+ UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {
1952
+ UnicodeMap *map;
1953
+
1954
+ lockGlobalParams;
1955
+ map = (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
1956
+ unlockGlobalParams;
1957
+ if (map) {
1958
+ map->incRefCnt();
1959
+ }
1960
+ return map;
1961
+ }
1962
+
1963
+ FILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
1964
+ GString *fileName;
1965
+ FILE *f;
1966
+
1967
+ lockGlobalParams;
1968
+ if ((fileName = (GString *)unicodeMaps->lookup(encodingName))) {
1969
+ f = fopen(fileName->getCString(), "r");
1970
+ } else {
1971
+ f = NULL;
1972
+ }
1973
+ unlockGlobalParams;
1974
+ return f;
1975
+ }
1976
+
1977
+ FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
1978
+ GList *list;
1979
+ GString *dir;
1980
+ GString *fileName;
1981
+ FILE *f;
1982
+ int i;
1983
+
1984
+ lockGlobalParams;
1985
+ if (!(list = (GList *)cMapDirs->lookup(collection))) {
1986
+ unlockGlobalParams;
1987
+ return NULL;
1988
+ }
1989
+ for (i = 0; i < list->getLength(); ++i) {
1990
+ dir = (GString *)list->get(i);
1991
+ fileName = appendToPath(dir->copy(), cMapName->getCString());
1992
+ f = fopen(fileName->getCString(), "r");
1993
+ delete fileName;
1994
+ if (f) {
1995
+ unlockGlobalParams;
1996
+ return f;
1997
+ }
1998
+ }
1999
+ unlockGlobalParams;
2000
+ return NULL;
2001
+ }
2002
+
2003
+ FILE *GlobalParams::findToUnicodeFile(GString *name) {
2004
+ GString *dir, *fileName;
2005
+ FILE *f;
2006
+ int i;
2007
+
2008
+ lockGlobalParams;
2009
+ for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
2010
+ dir = (GString *)toUnicodeDirs->get(i);
2011
+ fileName = appendToPath(dir->copy(), name->getCString());
2012
+ f = fopen(fileName->getCString(), "r");
2013
+ delete fileName;
2014
+ if (f) {
2015
+ unlockGlobalParams;
2016
+ return f;
2017
+ }
2018
+ }
2019
+ unlockGlobalParams;
2020
+ return NULL;
2021
+ }
2022
+
2023
+ DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
2024
+ DisplayFontParam *dfp;
2025
+
2026
+ lockGlobalParams;
2027
+ dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
2028
+ #ifdef WIN32
2029
+ if (!dfp && winFontList) {
2030
+ dfp = winFontList->find(fontName);
2031
+ }
2032
+ #endif
2033
+ unlockGlobalParams;
2034
+ return dfp;
2035
+ }
2036
+
2037
+ DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName,
2038
+ GString *collection) {
2039
+ DisplayFontParam *dfp;
2040
+
2041
+ lockGlobalParams;
2042
+ if (!fontName ||
2043
+ !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
2044
+ dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
2045
+ }
2046
+ unlockGlobalParams;
2047
+ return dfp;
2048
+ }
2049
+
2050
+ GString *GlobalParams::getPSFile() {
2051
+ GString *s;
2052
+
2053
+ lockGlobalParams;
2054
+ s = psFile ? psFile->copy() : (GString *)NULL;
2055
+ unlockGlobalParams;
2056
+ return s;
2057
+ }
2058
+
2059
+ int GlobalParams::getPSPaperWidth() {
2060
+ int w;
2061
+
2062
+ lockGlobalParams;
2063
+ w = psPaperWidth;
2064
+ unlockGlobalParams;
2065
+ return w;
2066
+ }
2067
+
2068
+ int GlobalParams::getPSPaperHeight() {
2069
+ int h;
2070
+
2071
+ lockGlobalParams;
2072
+ h = psPaperHeight;
2073
+ unlockGlobalParams;
2074
+ return h;
2075
+ }
2076
+
2077
+ void GlobalParams::getPSImageableArea(int *llx, int *lly, int *urx, int *ury) {
2078
+ lockGlobalParams;
2079
+ *llx = psImageableLLX;
2080
+ *lly = psImageableLLY;
2081
+ *urx = psImageableURX;
2082
+ *ury = psImageableURY;
2083
+ unlockGlobalParams;
2084
+ }
2085
+
2086
+ GBool GlobalParams::getPSCrop() {
2087
+ GBool f;
2088
+
2089
+ lockGlobalParams;
2090
+ f = psCrop;
2091
+ unlockGlobalParams;
2092
+ return f;
2093
+ }
2094
+
2095
+ GBool GlobalParams::getPSExpandSmaller() {
2096
+ GBool f;
2097
+
2098
+ lockGlobalParams;
2099
+ f = psExpandSmaller;
2100
+ unlockGlobalParams;
2101
+ return f;
2102
+ }
2103
+
2104
+ GBool GlobalParams::getPSShrinkLarger() {
2105
+ GBool f;
2106
+
2107
+ lockGlobalParams;
2108
+ f = psShrinkLarger;
2109
+ unlockGlobalParams;
2110
+ return f;
2111
+ }
2112
+
2113
+ GBool GlobalParams::getPSCenter() {
2114
+ GBool f;
2115
+
2116
+ lockGlobalParams;
2117
+ f = psCenter;
2118
+ unlockGlobalParams;
2119
+ return f;
2120
+ }
2121
+
2122
+ GBool GlobalParams::getPSDuplex() {
2123
+ GBool d;
2124
+
2125
+ lockGlobalParams;
2126
+ d = psDuplex;
2127
+ unlockGlobalParams;
2128
+ return d;
2129
+ }
2130
+
2131
+ GBool GlobalParams::getPSNoText() {
2132
+ GBool d;
2133
+
2134
+ lockGlobalParams;
2135
+ d = psNoText;
2136
+ unlockGlobalParams;
2137
+ return d;
2138
+ }
2139
+
2140
+ PSLevel GlobalParams::getPSLevel() {
2141
+ PSLevel level;
2142
+
2143
+ lockGlobalParams;
2144
+ level = psLevel;
2145
+ unlockGlobalParams;
2146
+ return level;
2147
+ }
2148
+
2149
+ PSFontParam *GlobalParams::getPSFont(GString *fontName) {
2150
+ PSFontParam *p;
2151
+
2152
+ lockGlobalParams;
2153
+ p = (PSFontParam *)psFonts->lookup(fontName);
2154
+ unlockGlobalParams;
2155
+ return p;
2156
+ }
2157
+
2158
+ PSFontParam *GlobalParams::getPSFont16(GString *fontName,
2159
+ GString *collection, int wMode) {
2160
+ PSFontParam *p;
2161
+ int i;
2162
+
2163
+ lockGlobalParams;
2164
+ p = NULL;
2165
+ if (fontName) {
2166
+ for (i = 0; i < psNamedFonts16->getLength(); ++i) {
2167
+ p = (PSFontParam *)psNamedFonts16->get(i);
2168
+ if (!p->pdfFontName->cmp(fontName) &&
2169
+ p->wMode == wMode) {
2170
+ break;
2171
+ }
2172
+ p = NULL;
2173
+ }
2174
+ }
2175
+ if (!p && collection) {
2176
+ for (i = 0; i < psFonts16->getLength(); ++i) {
2177
+ p = (PSFontParam *)psFonts16->get(i);
2178
+ if (!p->pdfFontName->cmp(collection) &&
2179
+ p->wMode == wMode) {
2180
+ break;
2181
+ }
2182
+ p = NULL;
2183
+ }
2184
+ }
2185
+ unlockGlobalParams;
2186
+ return p;
2187
+ }
2188
+
2189
+ GBool GlobalParams::getPSEmbedType1() {
2190
+ GBool e;
2191
+
2192
+ lockGlobalParams;
2193
+ e = psEmbedType1;
2194
+ unlockGlobalParams;
2195
+ return e;
2196
+ }
2197
+
2198
+ GBool GlobalParams::getPSEmbedTrueType() {
2199
+ GBool e;
2200
+
2201
+ lockGlobalParams;
2202
+ e = psEmbedTrueType;
2203
+ unlockGlobalParams;
2204
+ return e;
2205
+ }
2206
+
2207
+ GBool GlobalParams::getPSEmbedCIDPostScript() {
2208
+ GBool e;
2209
+
2210
+ lockGlobalParams;
2211
+ e = psEmbedCIDPostScript;
2212
+ unlockGlobalParams;
2213
+ return e;
2214
+ }
2215
+
2216
+ GBool GlobalParams::getPSEmbedCIDTrueType() {
2217
+ GBool e;
2218
+
2219
+ lockGlobalParams;
2220
+ e = psEmbedCIDTrueType;
2221
+ unlockGlobalParams;
2222
+ return e;
2223
+ }
2224
+
2225
+ GBool GlobalParams::getPSPreload() {
2226
+ GBool preload;
2227
+
2228
+ lockGlobalParams;
2229
+ preload = psPreload;
2230
+ unlockGlobalParams;
2231
+ return preload;
2232
+ }
2233
+
2234
+ GBool GlobalParams::getPSOPI() {
2235
+ GBool opi;
2236
+
2237
+ lockGlobalParams;
2238
+ opi = psOPI;
2239
+ unlockGlobalParams;
2240
+ return opi;
2241
+ }
2242
+
2243
+ GBool GlobalParams::getPSASCIIHex() {
2244
+ GBool ah;
2245
+
2246
+ lockGlobalParams;
2247
+ ah = psASCIIHex;
2248
+ unlockGlobalParams;
2249
+ return ah;
2250
+ }
2251
+
2252
+ GString *GlobalParams::getTextEncodingName() {
2253
+ GString *s;
2254
+
2255
+ lockGlobalParams;
2256
+ s = textEncoding->copy();
2257
+ unlockGlobalParams;
2258
+ return s;
2259
+ }
2260
+
2261
+ EndOfLineKind GlobalParams::getTextEOL() {
2262
+ EndOfLineKind eol;
2263
+
2264
+ lockGlobalParams;
2265
+ eol = textEOL;
2266
+ unlockGlobalParams;
2267
+ return eol;
2268
+ }
2269
+
2270
+ GBool GlobalParams::getTextPageBreaks() {
2271
+ GBool pageBreaks;
2272
+
2273
+ lockGlobalParams;
2274
+ pageBreaks = textPageBreaks;
2275
+ unlockGlobalParams;
2276
+ return pageBreaks;
2277
+ }
2278
+
2279
+ GBool GlobalParams::getTextKeepTinyChars() {
2280
+ GBool tiny;
2281
+
2282
+ lockGlobalParams;
2283
+ tiny = textKeepTinyChars;
2284
+ unlockGlobalParams;
2285
+ return tiny;
2286
+ }
2287
+
2288
+ GString *GlobalParams::findFontFile(GString *fontName, char **exts) {
2289
+ GString *dir, *fileName;
2290
+ char **ext;
2291
+ FILE *f;
2292
+ int i;
2293
+
2294
+ lockGlobalParams;
2295
+ for (i = 0; i < fontDirs->getLength(); ++i) {
2296
+ dir = (GString *)fontDirs->get(i);
2297
+ for (ext = exts; *ext; ++ext) {
2298
+ fileName = appendToPath(dir->copy(), fontName->getCString());
2299
+ fileName->append(*ext);
2300
+ if ((f = fopen(fileName->getCString(), "rb"))) {
2301
+ fclose(f);
2302
+ unlockGlobalParams;
2303
+ return fileName;
2304
+ }
2305
+ delete fileName;
2306
+ }
2307
+ }
2308
+ unlockGlobalParams;
2309
+ return NULL;
2310
+ }
2311
+
2312
+ GString *GlobalParams::getInitialZoom() {
2313
+ GString *s;
2314
+
2315
+ lockGlobalParams;
2316
+ s = initialZoom->copy();
2317
+ unlockGlobalParams;
2318
+ return s;
2319
+ }
2320
+
2321
+ GBool GlobalParams::getContinuousView() {
2322
+ GBool f;
2323
+
2324
+ lockGlobalParams;
2325
+ f = continuousView;
2326
+ unlockGlobalParams;
2327
+ return f;
2328
+ }
2329
+
2330
+ GBool GlobalParams::getEnableT1lib() {
2331
+ GBool f;
2332
+
2333
+ lockGlobalParams;
2334
+ f = enableT1lib;
2335
+ unlockGlobalParams;
2336
+ return f;
2337
+ }
2338
+
2339
+ GBool GlobalParams::getEnableFreeType() {
2340
+ GBool f;
2341
+
2342
+ lockGlobalParams;
2343
+ f = enableFreeType;
2344
+ unlockGlobalParams;
2345
+ return f;
2346
+ }
2347
+
2348
+
2349
+ GBool GlobalParams::getAntialias() {
2350
+ GBool f;
2351
+
2352
+ lockGlobalParams;
2353
+ f = antialias;
2354
+ unlockGlobalParams;
2355
+ return f;
2356
+ }
2357
+
2358
+ GBool GlobalParams::getVectorAntialias() {
2359
+ GBool f;
2360
+
2361
+ lockGlobalParams;
2362
+ f = vectorAntialias;
2363
+ unlockGlobalParams;
2364
+ return f;
2365
+ }
2366
+
2367
+ GBool GlobalParams::getStrokeAdjust() {
2368
+ GBool f;
2369
+
2370
+ lockGlobalParams;
2371
+ f = strokeAdjust;
2372
+ unlockGlobalParams;
2373
+ return f;
2374
+ }
2375
+
2376
+ ScreenType GlobalParams::getScreenType() {
2377
+ ScreenType t;
2378
+
2379
+ lockGlobalParams;
2380
+ t = screenType;
2381
+ unlockGlobalParams;
2382
+ return t;
2383
+ }
2384
+
2385
+ int GlobalParams::getScreenSize() {
2386
+ int size;
2387
+
2388
+ lockGlobalParams;
2389
+ size = screenSize;
2390
+ unlockGlobalParams;
2391
+ return size;
2392
+ }
2393
+
2394
+ int GlobalParams::getScreenDotRadius() {
2395
+ int r;
2396
+
2397
+ lockGlobalParams;
2398
+ r = screenDotRadius;
2399
+ unlockGlobalParams;
2400
+ return r;
2401
+ }
2402
+
2403
+ double GlobalParams::getScreenGamma() {
2404
+ double gamma;
2405
+
2406
+ lockGlobalParams;
2407
+ gamma = screenGamma;
2408
+ unlockGlobalParams;
2409
+ return gamma;
2410
+ }
2411
+
2412
+ double GlobalParams::getScreenBlackThreshold() {
2413
+ double thresh;
2414
+
2415
+ lockGlobalParams;
2416
+ thresh = screenBlackThreshold;
2417
+ unlockGlobalParams;
2418
+ return thresh;
2419
+ }
2420
+
2421
+ double GlobalParams::getScreenWhiteThreshold() {
2422
+ double thresh;
2423
+
2424
+ lockGlobalParams;
2425
+ thresh = screenWhiteThreshold;
2426
+ unlockGlobalParams;
2427
+ return thresh;
2428
+ }
2429
+
2430
+ GBool GlobalParams::getMapNumericCharNames() {
2431
+ GBool map;
2432
+
2433
+ lockGlobalParams;
2434
+ map = mapNumericCharNames;
2435
+ unlockGlobalParams;
2436
+ return map;
2437
+ }
2438
+
2439
+ GBool GlobalParams::getMapUnknownCharNames() {
2440
+ GBool map;
2441
+
2442
+ lockGlobalParams;
2443
+ map = mapUnknownCharNames;
2444
+ unlockGlobalParams;
2445
+ return map;
2446
+ }
2447
+
2448
+ GList *GlobalParams::getKeyBinding(int code, int mods, int context) {
2449
+ KeyBinding *binding;
2450
+ GList *cmds;
2451
+ int modMask;
2452
+ int i, j;
2453
+
2454
+ lockGlobalParams;
2455
+ cmds = NULL;
2456
+ // for ASCII chars, ignore the shift modifier
2457
+ modMask = code <= 0xff ? ~xpdfKeyModShift : ~0;
2458
+ for (i = 0; i < keyBindings->getLength(); ++i) {
2459
+ binding = (KeyBinding *)keyBindings->get(i);
2460
+ if (binding->code == code &&
2461
+ (binding->mods & modMask) == (mods & modMask) &&
2462
+ (~binding->context | context) == ~0) {
2463
+ cmds = new GList();
2464
+ for (j = 0; j < binding->cmds->getLength(); ++j) {
2465
+ cmds->append(((GString *)binding->cmds->get(j))->copy());
2466
+ }
2467
+ break;
2468
+ }
2469
+ }
2470
+ unlockGlobalParams;
2471
+ return cmds;
2472
+ }
2473
+
2474
+ GBool GlobalParams::getPrintCommands() {
2475
+ GBool p;
2476
+
2477
+ lockGlobalParams;
2478
+ p = printCommands;
2479
+ unlockGlobalParams;
2480
+ return p;
2481
+ }
2482
+
2483
+ GBool GlobalParams::getErrQuiet() {
2484
+ // no locking -- this function may get called from inside a locked
2485
+ // section
2486
+ return errQuiet;
2487
+ }
2488
+
2489
+ CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
2490
+ GString *fileName;
2491
+ CharCodeToUnicode *ctu;
2492
+
2493
+ lockGlobalParams;
2494
+ if (!(ctu = cidToUnicodeCache->getCharCodeToUnicode(collection))) {
2495
+ if ((fileName = (GString *)cidToUnicodes->lookup(collection)) &&
2496
+ (ctu = CharCodeToUnicode::parseCIDToUnicode(fileName, collection))) {
2497
+ cidToUnicodeCache->add(ctu);
2498
+ }
2499
+ }
2500
+ unlockGlobalParams;
2501
+ return ctu;
2502
+ }
2503
+
2504
+ CharCodeToUnicode *GlobalParams::getUnicodeToUnicode(GString *fontName) {
2505
+ CharCodeToUnicode *ctu;
2506
+ GHashIter *iter;
2507
+ GString *fontPattern, *fileName;
2508
+
2509
+ lockGlobalParams;
2510
+ fileName = NULL;
2511
+ unicodeToUnicodes->startIter(&iter);
2512
+ while (unicodeToUnicodes->getNext(&iter, &fontPattern, (void **)&fileName)) {
2513
+ if (strstr(fontName->getCString(), fontPattern->getCString())) {
2514
+ unicodeToUnicodes->killIter(&iter);
2515
+ break;
2516
+ }
2517
+ fileName = NULL;
2518
+ }
2519
+ if (fileName) {
2520
+ if (!(ctu = unicodeToUnicodeCache->getCharCodeToUnicode(fileName))) {
2521
+ if ((ctu = CharCodeToUnicode::parseUnicodeToUnicode(fileName))) {
2522
+ unicodeToUnicodeCache->add(ctu);
2523
+ }
2524
+ }
2525
+ } else {
2526
+ ctu = NULL;
2527
+ }
2528
+ unlockGlobalParams;
2529
+ return ctu;
2530
+ }
2531
+
2532
+ UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
2533
+ return getUnicodeMap2(encodingName);
2534
+ }
2535
+
2536
+ UnicodeMap *GlobalParams::getUnicodeMap2(GString *encodingName) {
2537
+ UnicodeMap *map;
2538
+
2539
+ if (!(map = getResidentUnicodeMap(encodingName))) {
2540
+ lockUnicodeMapCache;
2541
+ map = unicodeMapCache->getUnicodeMap(encodingName);
2542
+ unlockUnicodeMapCache;
2543
+ }
2544
+ return map;
2545
+ }
2546
+
2547
+ CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) {
2548
+ CMap *cMap;
2549
+
2550
+ lockCMapCache;
2551
+ cMap = cMapCache->getCMap(collection, cMapName);
2552
+ unlockCMapCache;
2553
+ return cMap;
2554
+ }
2555
+
2556
+ UnicodeMap *GlobalParams::getTextEncoding() {
2557
+ return getUnicodeMap2(textEncoding);
2558
+ }
2559
+
2560
+ //------------------------------------------------------------------------
2561
+ // functions to set parameters
2562
+ //------------------------------------------------------------------------
2563
+
2564
+ void GlobalParams::addDisplayFont(DisplayFontParam *param) {
2565
+ DisplayFontParam *old;
2566
+
2567
+ lockGlobalParams;
2568
+ if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) {
2569
+ delete old;
2570
+ }
2571
+ displayFonts->add(param->name, param);
2572
+ unlockGlobalParams;
2573
+ }
2574
+
2575
+ void GlobalParams::setPSFile(char *file) {
2576
+ lockGlobalParams;
2577
+ if (psFile) {
2578
+ delete psFile;
2579
+ }
2580
+ psFile = new GString(file);
2581
+ unlockGlobalParams;
2582
+ }
2583
+
2584
+ GBool GlobalParams::setPSPaperSize(char *size) {
2585
+ lockGlobalParams;
2586
+ if (!strcmp(size, "match")) {
2587
+ psPaperWidth = psPaperHeight = -1;
2588
+ } else if (!strcmp(size, "letter")) {
2589
+ psPaperWidth = 612;
2590
+ psPaperHeight = 792;
2591
+ } else if (!strcmp(size, "legal")) {
2592
+ psPaperWidth = 612;
2593
+ psPaperHeight = 1008;
2594
+ } else if (!strcmp(size, "A4")) {
2595
+ psPaperWidth = 595;
2596
+ psPaperHeight = 842;
2597
+ } else if (!strcmp(size, "A3")) {
2598
+ psPaperWidth = 842;
2599
+ psPaperHeight = 1190;
2600
+ } else {
2601
+ unlockGlobalParams;
2602
+ return gFalse;
2603
+ }
2604
+ psImageableLLX = psImageableLLY = 0;
2605
+ psImageableURX = psPaperWidth;
2606
+ psImageableURY = psPaperHeight;
2607
+ unlockGlobalParams;
2608
+ return gTrue;
2609
+ }
2610
+
2611
+ void GlobalParams::setPSPaperWidth(int width) {
2612
+ lockGlobalParams;
2613
+ psPaperWidth = width;
2614
+ psImageableLLX = 0;
2615
+ psImageableURX = psPaperWidth;
2616
+ unlockGlobalParams;
2617
+ }
2618
+
2619
+ void GlobalParams::setPSPaperHeight(int height) {
2620
+ lockGlobalParams;
2621
+ psPaperHeight = height;
2622
+ psImageableLLY = 0;
2623
+ psImageableURY = psPaperHeight;
2624
+ unlockGlobalParams;
2625
+ }
2626
+
2627
+ void GlobalParams::setPSImageableArea(int llx, int lly, int urx, int ury) {
2628
+ lockGlobalParams;
2629
+ psImageableLLX = llx;
2630
+ psImageableLLY = lly;
2631
+ psImageableURX = urx;
2632
+ psImageableURY = ury;
2633
+ unlockGlobalParams;
2634
+ }
2635
+
2636
+ void GlobalParams::setPSCrop(GBool crop) {
2637
+ lockGlobalParams;
2638
+ psCrop = crop;
2639
+ unlockGlobalParams;
2640
+ }
2641
+
2642
+ void GlobalParams::setPSExpandSmaller(GBool expand) {
2643
+ lockGlobalParams;
2644
+ psExpandSmaller = expand;
2645
+ unlockGlobalParams;
2646
+ }
2647
+
2648
+ void GlobalParams::setPSShrinkLarger(GBool shrink) {
2649
+ lockGlobalParams;
2650
+ psShrinkLarger = shrink;
2651
+ unlockGlobalParams;
2652
+ }
2653
+
2654
+ void GlobalParams::setPSCenter(GBool center) {
2655
+ lockGlobalParams;
2656
+ psCenter = center;
2657
+ unlockGlobalParams;
2658
+ }
2659
+
2660
+ void GlobalParams::setPSDuplex(GBool duplex) {
2661
+ lockGlobalParams;
2662
+ psDuplex = duplex;
2663
+ unlockGlobalParams;
2664
+ }
2665
+
2666
+ void GlobalParams::setPSNoText(GBool notext)
2667
+ {
2668
+ lockGlobalParams;
2669
+ psNoText = notext;
2670
+ unlockGlobalParams;
2671
+ }
2672
+
2673
+ void GlobalParams::setPSLevel(PSLevel level) {
2674
+ lockGlobalParams;
2675
+ psLevel = level;
2676
+ unlockGlobalParams;
2677
+ }
2678
+
2679
+ void GlobalParams::setPSEmbedType1(GBool embed) {
2680
+ lockGlobalParams;
2681
+ psEmbedType1 = embed;
2682
+ unlockGlobalParams;
2683
+ }
2684
+
2685
+ void GlobalParams::setPSEmbedTrueType(GBool embed) {
2686
+ lockGlobalParams;
2687
+ psEmbedTrueType = embed;
2688
+ unlockGlobalParams;
2689
+ }
2690
+
2691
+ void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
2692
+ lockGlobalParams;
2693
+ psEmbedCIDPostScript = embed;
2694
+ unlockGlobalParams;
2695
+ }
2696
+
2697
+ void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
2698
+ lockGlobalParams;
2699
+ psEmbedCIDTrueType = embed;
2700
+ unlockGlobalParams;
2701
+ }
2702
+
2703
+ void GlobalParams::setPSPreload(GBool preload) {
2704
+ lockGlobalParams;
2705
+ psPreload = preload;
2706
+ unlockGlobalParams;
2707
+ }
2708
+
2709
+ void GlobalParams::setPSOPI(GBool opi) {
2710
+ lockGlobalParams;
2711
+ psOPI = opi;
2712
+ unlockGlobalParams;
2713
+ }
2714
+
2715
+ void GlobalParams::setPSASCIIHex(GBool hex) {
2716
+ lockGlobalParams;
2717
+ psASCIIHex = hex;
2718
+ unlockGlobalParams;
2719
+ }
2720
+
2721
+ void GlobalParams::setTextEncoding(char *encodingName) {
2722
+ lockGlobalParams;
2723
+ delete textEncoding;
2724
+ textEncoding = new GString(encodingName);
2725
+ unlockGlobalParams;
2726
+ }
2727
+
2728
+ GBool GlobalParams::setTextEOL(char *s) {
2729
+ lockGlobalParams;
2730
+ if (!strcmp(s, "unix")) {
2731
+ textEOL = eolUnix;
2732
+ } else if (!strcmp(s, "dos")) {
2733
+ textEOL = eolDOS;
2734
+ } else if (!strcmp(s, "mac")) {
2735
+ textEOL = eolMac;
2736
+ } else {
2737
+ unlockGlobalParams;
2738
+ return gFalse;
2739
+ }
2740
+ unlockGlobalParams;
2741
+ return gTrue;
2742
+ }
2743
+
2744
+ void GlobalParams::setTextPageBreaks(GBool pageBreaks) {
2745
+ lockGlobalParams;
2746
+ textPageBreaks = pageBreaks;
2747
+ unlockGlobalParams;
2748
+ }
2749
+
2750
+ void GlobalParams::setTextKeepTinyChars(GBool keep) {
2751
+ lockGlobalParams;
2752
+ textKeepTinyChars = keep;
2753
+ unlockGlobalParams;
2754
+ }
2755
+
2756
+ void GlobalParams::setInitialZoom(char *s) {
2757
+ lockGlobalParams;
2758
+ delete initialZoom;
2759
+ initialZoom = new GString(s);
2760
+ unlockGlobalParams;
2761
+ }
2762
+
2763
+ void GlobalParams::setContinuousView(GBool cont) {
2764
+ lockGlobalParams;
2765
+ continuousView = cont;
2766
+ unlockGlobalParams;
2767
+ }
2768
+
2769
+ GBool GlobalParams::setEnableT1lib(char *s) {
2770
+ GBool ok;
2771
+
2772
+ lockGlobalParams;
2773
+ ok = parseYesNo2(s, &enableT1lib);
2774
+ unlockGlobalParams;
2775
+ return ok;
2776
+ }
2777
+
2778
+ GBool GlobalParams::setEnableFreeType(char *s) {
2779
+ GBool ok;
2780
+
2781
+ lockGlobalParams;
2782
+ ok = parseYesNo2(s, &enableFreeType);
2783
+ unlockGlobalParams;
2784
+ return ok;
2785
+ }
2786
+
2787
+
2788
+ GBool GlobalParams::setAntialias(char *s) {
2789
+ GBool ok;
2790
+
2791
+ lockGlobalParams;
2792
+ ok = parseYesNo2(s, &antialias);
2793
+ unlockGlobalParams;
2794
+ return ok;
2795
+ }
2796
+
2797
+ GBool GlobalParams::setVectorAntialias(char *s) {
2798
+ GBool ok;
2799
+
2800
+ lockGlobalParams;
2801
+ ok = parseYesNo2(s, &vectorAntialias);
2802
+ unlockGlobalParams;
2803
+ return ok;
2804
+ }
2805
+
2806
+ void GlobalParams::setScreenType(ScreenType t) {
2807
+ lockGlobalParams;
2808
+ screenType = t;
2809
+ unlockGlobalParams;
2810
+ }
2811
+
2812
+ void GlobalParams::setScreenSize(int size) {
2813
+ lockGlobalParams;
2814
+ screenSize = size;
2815
+ unlockGlobalParams;
2816
+ }
2817
+
2818
+ void GlobalParams::setScreenDotRadius(int r) {
2819
+ lockGlobalParams;
2820
+ screenDotRadius = r;
2821
+ unlockGlobalParams;
2822
+ }
2823
+
2824
+ void GlobalParams::setScreenGamma(double gamma) {
2825
+ lockGlobalParams;
2826
+ screenGamma = gamma;
2827
+ unlockGlobalParams;
2828
+ }
2829
+
2830
+ void GlobalParams::setScreenBlackThreshold(double thresh) {
2831
+ lockGlobalParams;
2832
+ screenBlackThreshold = thresh;
2833
+ unlockGlobalParams;
2834
+ }
2835
+
2836
+ void GlobalParams::setScreenWhiteThreshold(double thresh) {
2837
+ lockGlobalParams;
2838
+ screenWhiteThreshold = thresh;
2839
+ unlockGlobalParams;
2840
+ }
2841
+
2842
+ void GlobalParams::setMapNumericCharNames(GBool map) {
2843
+ lockGlobalParams;
2844
+ mapNumericCharNames = map;
2845
+ unlockGlobalParams;
2846
+ }
2847
+
2848
+ void GlobalParams::setMapUnknownCharNames(GBool map) {
2849
+ lockGlobalParams;
2850
+ mapUnknownCharNames = map;
2851
+ unlockGlobalParams;
2852
+ }
2853
+
2854
+ void GlobalParams::setPrintCommands(GBool printCommandsA) {
2855
+ lockGlobalParams;
2856
+ printCommands = printCommandsA;
2857
+ unlockGlobalParams;
2858
+ }
2859
+
2860
+ void GlobalParams::setErrQuiet(GBool errQuietA) {
2861
+ lockGlobalParams;
2862
+ errQuiet = errQuietA;
2863
+ unlockGlobalParams;
2864
+ }
2865
+
2866
+ void GlobalParams::addSecurityHandler(XpdfSecurityHandler *handler) {
2867
+ #ifdef ENABLE_PLUGINS
2868
+ lockGlobalParams;
2869
+ securityHandlers->append(handler);
2870
+ unlockGlobalParams;
2871
+ #endif
2872
+ }
2873
+
2874
+ XpdfSecurityHandler *GlobalParams::getSecurityHandler(char *name) {
2875
+ #ifdef ENABLE_PLUGINS
2876
+ XpdfSecurityHandler *hdlr;
2877
+ int i;
2878
+
2879
+ lockGlobalParams;
2880
+ for (i = 0; i < securityHandlers->getLength(); ++i) {
2881
+ hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
2882
+ if (!strcasecmp(hdlr->name, name)) {
2883
+ unlockGlobalParams;
2884
+ return hdlr;
2885
+ }
2886
+ }
2887
+ unlockGlobalParams;
2888
+
2889
+ if (!loadPlugin("security", name)) {
2890
+ return NULL;
2891
+ }
2892
+
2893
+ lockGlobalParams;
2894
+ for (i = 0; i < securityHandlers->getLength(); ++i) {
2895
+ hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
2896
+ if (!strcmp(hdlr->name, name)) {
2897
+ unlockGlobalParams;
2898
+ return hdlr;
2899
+ }
2900
+ }
2901
+ unlockGlobalParams;
2902
+ #endif
2903
+
2904
+ return NULL;
2905
+ }
2906
+
2907
+ #ifdef ENABLE_PLUGINS
2908
+ //------------------------------------------------------------------------
2909
+ // plugins
2910
+ //------------------------------------------------------------------------
2911
+
2912
+ GBool GlobalParams::loadPlugin(char *type, char *name) {
2913
+ Plugin *plugin;
2914
+
2915
+ if (!(plugin = Plugin::load(type, name))) {
2916
+ return gFalse;
2917
+ }
2918
+ lockGlobalParams;
2919
+ plugins->append(plugin);
2920
+ unlockGlobalParams;
2921
+ return gTrue;
2922
+ }
2923
+
2924
+ #endif // ENABLE_PLUGINS