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,114 @@
1
+ //========================================================================
2
+ //
3
+ // XPDFApp.h
4
+ //
5
+ // Copyright 2002-2003 Glyph & Cog, LLC
6
+ //
7
+ //========================================================================
8
+
9
+ #ifndef XPDFAPP_H
10
+ #define XPDFAPP_H
11
+
12
+ #include <aconf.h>
13
+
14
+ #ifdef USE_GCC_PRAGMAS
15
+ #pragma interface
16
+ #endif
17
+
18
+ #define Object XtObject
19
+ #include <Xm/XmAll.h>
20
+ #undef Object
21
+ #include "gtypes.h"
22
+ #include "SplashTypes.h"
23
+
24
+ class GString;
25
+ class GList;
26
+ class PDFDoc;
27
+ class XPDFViewer;
28
+
29
+ //------------------------------------------------------------------------
30
+
31
+ #define xpdfAppName "Xpdf"
32
+
33
+ //------------------------------------------------------------------------
34
+ // XPDFApp
35
+ //------------------------------------------------------------------------
36
+
37
+ class XPDFApp {
38
+ public:
39
+
40
+ XPDFApp(int *argc, char *argv[]);
41
+ ~XPDFApp();
42
+
43
+ XPDFViewer *open(GString *fileName, int page = 1,
44
+ GString *ownerPassword = NULL,
45
+ GString *userPassword = NULL);
46
+ XPDFViewer *openAtDest(GString *fileName, GString *dest,
47
+ GString *ownerPassword = NULL,
48
+ GString *userPassword = NULL);
49
+ XPDFViewer *reopen(XPDFViewer *viewer, PDFDoc *doc, int page,
50
+ GBool fullScreenA);
51
+ void close(XPDFViewer *viewer, GBool closeLast);
52
+ void quit();
53
+
54
+ void run();
55
+
56
+ //----- remote server
57
+ void setRemoteName(char *remoteName);
58
+ GBool remoteServerRunning();
59
+ void remoteExec(char *cmd);
60
+ void remoteOpen(GString *fileName, int page, GBool raise);
61
+ void remoteOpenAtDest(GString *fileName, GString *dest, GBool raise);
62
+ void remoteReload(GBool raise);
63
+ void remoteRaise();
64
+ void remoteQuit();
65
+
66
+ //----- resource/option values
67
+ GString *getGeometry() { return geometry; }
68
+ GString *getTitle() { return title; }
69
+ GBool getInstallCmap() { return installCmap; }
70
+ int getRGBCubeSize() { return rgbCubeSize; }
71
+ GBool getReverseVideo() { return reverseVideo; }
72
+ SplashColorPtr getPaperRGB() { return paperRGB; }
73
+ Gulong getPaperPixel() { return paperPixel; }
74
+ Gulong getMattePixel(GBool fullScreenA)
75
+ { return fullScreenA ? fullScreenMattePixel : mattePixel; }
76
+ GString *getInitialZoom() { return initialZoom; }
77
+ void setFullScreen(GBool fullScreenA) { fullScreen = fullScreenA; }
78
+ GBool getFullScreen() { return fullScreen; }
79
+
80
+ XtAppContext getAppContext() { return appContext; }
81
+ Widget getAppShell() { return appShell; }
82
+
83
+ private:
84
+
85
+ void getResources();
86
+ static void remoteMsgCbk(Widget widget, XtPointer ptr,
87
+ XEvent *event, Boolean *cont);
88
+
89
+ Display *display;
90
+ int screenNum;
91
+ XtAppContext appContext;
92
+ Widget appShell;
93
+ GList *viewers; // [XPDFViewer]
94
+
95
+ Atom remoteAtom;
96
+ Window remoteXWin;
97
+ XPDFViewer *remoteViewer;
98
+ Widget remoteWin;
99
+
100
+ //----- resource/option values
101
+ GString *geometry;
102
+ GString *title;
103
+ GBool installCmap;
104
+ int rgbCubeSize;
105
+ GBool reverseVideo;
106
+ SplashColor paperRGB;
107
+ Gulong paperPixel;
108
+ Gulong mattePixel;
109
+ Gulong fullScreenMattePixel;
110
+ GString *initialZoom;
111
+ GBool fullScreen;
112
+ };
113
+
114
+ #endif
@@ -0,0 +1,1655 @@
1
+ //========================================================================
2
+ //
3
+ // XPDFCore.cc
4
+ //
5
+ // Copyright 2002-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 <X11/keysym.h>
16
+ #include <X11/cursorfont.h>
17
+ #include <string.h>
18
+ #include "gmem.h"
19
+ #include "GString.h"
20
+ #include "GList.h"
21
+ #include "Error.h"
22
+ #include "GlobalParams.h"
23
+ #include "PDFDoc.h"
24
+ #include "Link.h"
25
+ #include "ErrorCodes.h"
26
+ #include "GfxState.h"
27
+ #include "CoreOutputDev.h"
28
+ #include "PSOutputDev.h"
29
+ #include "TextOutputDev.h"
30
+ #include "SplashBitmap.h"
31
+ #include "SplashPattern.h"
32
+ #include "XPDFApp.h"
33
+ #include "XPDFCore.h"
34
+
35
+ // these macro defns conflict with xpdf's Object class
36
+ #ifdef LESSTIF_VERSION
37
+ #undef XtDisplay
38
+ #undef XtScreen
39
+ #undef XtWindow
40
+ #undef XtParent
41
+ #undef XtIsRealized
42
+ #endif
43
+
44
+ //------------------------------------------------------------------------
45
+
46
+ // Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result.
47
+ static inline Guchar div255(int x) {
48
+ return (Guchar)((x + (x >> 8) + 0x80) >> 8);
49
+ }
50
+
51
+ //------------------------------------------------------------------------
52
+
53
+ GString *XPDFCore::currentSelection = NULL;
54
+ XPDFCore *XPDFCore::currentSelectionOwner = NULL;
55
+ Atom XPDFCore::targetsAtom;
56
+
57
+ //------------------------------------------------------------------------
58
+ // XPDFCoreTile
59
+ //------------------------------------------------------------------------
60
+
61
+ class XPDFCoreTile: public PDFCoreTile {
62
+ public:
63
+ XPDFCoreTile(int xDestA, int yDestA);
64
+ virtual ~XPDFCoreTile();
65
+ XImage *image;
66
+ };
67
+
68
+ XPDFCoreTile::XPDFCoreTile(int xDestA, int yDestA):
69
+ PDFCoreTile(xDestA, yDestA)
70
+ {
71
+ image = NULL;
72
+ }
73
+
74
+ XPDFCoreTile::~XPDFCoreTile() {
75
+ if (image) {
76
+ gfree(image->data);
77
+ image->data = NULL;
78
+ XDestroyImage(image);
79
+ }
80
+ }
81
+
82
+ //------------------------------------------------------------------------
83
+ // XPDFCore
84
+ //------------------------------------------------------------------------
85
+
86
+ XPDFCore::XPDFCore(Widget shellA, Widget parentWidgetA,
87
+ SplashColorPtr paperColorA, Gulong paperPixelA,
88
+ Gulong mattePixelA, GBool fullScreenA, GBool reverseVideoA,
89
+ GBool installCmap, int rgbCubeSizeA):
90
+ PDFCore(splashModeRGB8, 4, reverseVideoA, paperColorA, !fullScreenA)
91
+ {
92
+ GString *initialZoom;
93
+
94
+ shell = shellA;
95
+ parentWidget = parentWidgetA;
96
+ display = XtDisplay(parentWidget);
97
+ screenNum = XScreenNumberOfScreen(XtScreen(parentWidget));
98
+ targetsAtom = XInternAtom(display, "TARGETS", False);
99
+
100
+ paperPixel = paperPixelA;
101
+ mattePixel = mattePixelA;
102
+ fullScreen = fullScreenA;
103
+
104
+ setupX(installCmap, rgbCubeSizeA);
105
+
106
+ scrolledWin = NULL;
107
+ hScrollBar = NULL;
108
+ vScrollBar = NULL;
109
+ drawAreaFrame = NULL;
110
+ drawArea = NULL;
111
+
112
+ // get the initial zoom value
113
+ if (fullScreen) {
114
+ zoom = zoomPage;
115
+ } else {
116
+ initialZoom = globalParams->getInitialZoom();
117
+ if (!initialZoom->cmp("page")) {
118
+ zoom = zoomPage;
119
+ } else if (!initialZoom->cmp("width")) {
120
+ zoom = zoomWidth;
121
+ } else {
122
+ zoom = atoi(initialZoom->getCString());
123
+ if (zoom <= 0) {
124
+ zoom = defZoom;
125
+ }
126
+ }
127
+ delete initialZoom;
128
+ }
129
+
130
+ linkAction = NULL;
131
+
132
+ panning = gFalse;
133
+
134
+ updateCbk = NULL;
135
+ actionCbk = NULL;
136
+ keyPressCbk = NULL;
137
+ mouseCbk = NULL;
138
+
139
+ // optional features default to on
140
+ hyperlinksEnabled = gTrue;
141
+ selectEnabled = gTrue;
142
+
143
+ // do X-specific initialization and create the widgets
144
+ initWindow();
145
+ initPasswordDialog();
146
+ }
147
+
148
+ XPDFCore::~XPDFCore() {
149
+ if (currentSelectionOwner == this && currentSelection) {
150
+ delete currentSelection;
151
+ currentSelection = NULL;
152
+ currentSelectionOwner = NULL;
153
+ }
154
+ if (drawAreaGC) {
155
+ XFreeGC(display, drawAreaGC);
156
+ }
157
+ if (scrolledWin) {
158
+ XtDestroyWidget(scrolledWin);
159
+ }
160
+ if (busyCursor) {
161
+ XFreeCursor(display, busyCursor);
162
+ }
163
+ if (linkCursor) {
164
+ XFreeCursor(display, linkCursor);
165
+ }
166
+ if (selectCursor) {
167
+ XFreeCursor(display, selectCursor);
168
+ }
169
+ }
170
+
171
+ //------------------------------------------------------------------------
172
+ // loadFile / displayPage / displayDest
173
+ //------------------------------------------------------------------------
174
+
175
+ int XPDFCore::loadFile(GString *fileName, GString *ownerPassword,
176
+ GString *userPassword) {
177
+ int err;
178
+
179
+ err = PDFCore::loadFile(fileName, ownerPassword, userPassword);
180
+ if (err == errNone) {
181
+ // save the modification time
182
+ modTime = getModTime(doc->getFileName()->getCString());
183
+
184
+ // update the parent window
185
+ if (updateCbk) {
186
+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
187
+ doc->getNumPages(), NULL);
188
+ }
189
+ }
190
+ return err;
191
+ }
192
+
193
+ int XPDFCore::loadFile(BaseStream *stream, GString *ownerPassword,
194
+ GString *userPassword) {
195
+ int err;
196
+
197
+ err = PDFCore::loadFile(stream, ownerPassword, userPassword);
198
+ if (err == errNone) {
199
+ // no file
200
+ modTime = 0;
201
+
202
+ // update the parent window
203
+ if (updateCbk) {
204
+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
205
+ doc->getNumPages(), NULL);
206
+ }
207
+ }
208
+ return err;
209
+ }
210
+
211
+ void XPDFCore::loadDoc(PDFDoc *docA) {
212
+ PDFCore::loadDoc(docA);
213
+
214
+ // save the modification time
215
+ if (doc->getFileName()) {
216
+ modTime = getModTime(doc->getFileName()->getCString());
217
+ }
218
+
219
+ // update the parent window
220
+ if (updateCbk) {
221
+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
222
+ doc->getNumPages(), NULL);
223
+ }
224
+ }
225
+
226
+ void XPDFCore::resizeToPage(int pg) {
227
+ Dimension width, height;
228
+ double width1, height1;
229
+ Dimension topW, topH, topBorder, daW, daH;
230
+ Dimension displayW, displayH;
231
+
232
+ displayW = DisplayWidth(display, screenNum);
233
+ displayH = DisplayHeight(display, screenNum);
234
+ if (fullScreen) {
235
+ width = displayW;
236
+ height = displayH;
237
+ } else {
238
+ if (!doc || pg <= 0 || pg > doc->getNumPages()) {
239
+ width1 = 612;
240
+ height1 = 792;
241
+ } else if (doc->getPageRotate(pg) == 90 ||
242
+ doc->getPageRotate(pg) == 270) {
243
+ width1 = doc->getPageCropHeight(pg);
244
+ height1 = doc->getPageCropWidth(pg);
245
+ } else {
246
+ width1 = doc->getPageCropWidth(pg);
247
+ height1 = doc->getPageCropHeight(pg);
248
+ }
249
+ if (zoom == zoomPage || zoom == zoomWidth) {
250
+ width = (Dimension)(width1 * 0.01 * defZoom + 0.5);
251
+ height = (Dimension)(height1 * 0.01 * defZoom + 0.5);
252
+ } else {
253
+ width = (Dimension)(width1 * 0.01 * zoom + 0.5);
254
+ height = (Dimension)(height1 * 0.01 * zoom + 0.5);
255
+ }
256
+ if (continuousMode) {
257
+ height += continuousModePageSpacing;
258
+ }
259
+ if (width > displayW - 100) {
260
+ width = displayW - 100;
261
+ }
262
+ if (height > displayH - 100) {
263
+ height = displayH - 100;
264
+ }
265
+ }
266
+
267
+ if (XtIsRealized(shell)) {
268
+ XtVaGetValues(shell, XmNwidth, &topW, XmNheight, &topH,
269
+ XmNborderWidth, &topBorder, NULL);
270
+ XtVaGetValues(drawArea, XmNwidth, &daW, XmNheight, &daH, NULL);
271
+ XtVaSetValues(shell, XmNwidth, width + (topW - daW),
272
+ XmNheight, height + (topH - daH), NULL);
273
+ } else {
274
+ XtVaSetValues(drawArea, XmNwidth, width, XmNheight, height, NULL);
275
+ }
276
+ }
277
+
278
+ void XPDFCore::update(int topPageA, int scrollXA, int scrollYA,
279
+ double zoomA, int rotateA,
280
+ GBool force, GBool addToHist) {
281
+ int oldPage;
282
+
283
+ oldPage = topPage;
284
+ PDFCore::update(topPageA, scrollXA, scrollYA, zoomA, rotateA,
285
+ force, addToHist);
286
+ linkAction = NULL;
287
+ if (doc && topPage != oldPage) {
288
+ if (updateCbk) {
289
+ (*updateCbk)(updateCbkData, NULL, topPage, -1, "");
290
+ }
291
+ }
292
+ }
293
+
294
+ GBool XPDFCore::checkForNewFile() {
295
+ time_t newModTime;
296
+
297
+ if (doc->getFileName()) {
298
+ newModTime = getModTime(doc->getFileName()->getCString());
299
+ if (newModTime != modTime) {
300
+ modTime = newModTime;
301
+ return gTrue;
302
+ }
303
+ }
304
+ return gFalse;
305
+ }
306
+
307
+ //------------------------------------------------------------------------
308
+ // page/position changes
309
+ //------------------------------------------------------------------------
310
+
311
+ GBool XPDFCore::gotoNextPage(int inc, GBool top) {
312
+ if (!PDFCore::gotoNextPage(inc, top)) {
313
+ XBell(display, 0);
314
+ return gFalse;
315
+ }
316
+ return gTrue;
317
+ }
318
+
319
+ GBool XPDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
320
+ if (!PDFCore::gotoPrevPage(dec, top, bottom)) {
321
+ XBell(display, 0);
322
+ return gFalse;
323
+ }
324
+ return gTrue;
325
+ }
326
+
327
+ GBool XPDFCore::goForward() {
328
+ if (!PDFCore::goForward()) {
329
+ XBell(display, 0);
330
+ return gFalse;
331
+ }
332
+ return gTrue;
333
+ }
334
+
335
+ GBool XPDFCore::goBackward() {
336
+ if (!PDFCore::goBackward()) {
337
+ XBell(display, 0);
338
+ return gFalse;
339
+ }
340
+ return gTrue;
341
+ }
342
+
343
+ void XPDFCore::startPan(int wx, int wy) {
344
+ panning = gTrue;
345
+ panMX = wx;
346
+ panMY = wy;
347
+ }
348
+
349
+ void XPDFCore::endPan(int wx, int wy) {
350
+ panning = gFalse;
351
+ }
352
+
353
+ //------------------------------------------------------------------------
354
+ // selection
355
+ //------------------------------------------------------------------------
356
+
357
+ void XPDFCore::startSelection(int wx, int wy) {
358
+ int pg, x, y;
359
+
360
+ takeFocus();
361
+ if (doc && doc->getNumPages() > 0) {
362
+ if (selectEnabled) {
363
+ if (cvtWindowToDev(wx, wy, &pg, &x, &y)) {
364
+ setSelection(pg, x, y, x, y);
365
+ setCursor(selectCursor);
366
+ dragging = gTrue;
367
+ }
368
+ }
369
+ }
370
+ }
371
+
372
+ void XPDFCore::endSelection(int wx, int wy) {
373
+ int pg, x, y;
374
+ GBool ok;
375
+
376
+ if (doc && doc->getNumPages() > 0) {
377
+ ok = cvtWindowToDev(wx, wy, &pg, &x, &y);
378
+ if (dragging) {
379
+ dragging = gFalse;
380
+ setCursor(None);
381
+ if (ok) {
382
+ moveSelection(pg, x, y);
383
+ }
384
+ #ifndef NO_TEXT_SELECT
385
+ if (selectULX != selectLRX &&
386
+ selectULY != selectLRY) {
387
+ if (doc->okToCopy()) {
388
+ copySelection();
389
+ } else {
390
+ error(-1, "Copying of text from this document is not allowed.");
391
+ }
392
+ }
393
+ #endif
394
+ }
395
+ }
396
+ }
397
+
398
+ // X's copy-and-paste mechanism is brain damaged. Xt doesn't help
399
+ // any, but doesn't make it too much worse, either. Motif, on the
400
+ // other hand, adds significant complexity to the mess. So here we
401
+ // blow off the Motif junk and stick to plain old Xt. The next two
402
+ // functions (copySelection and convertSelectionCbk) implement the
403
+ // magic needed to deal with Xt's mechanism. Note that this requires
404
+ // global variables (currentSelection and currentSelectionOwner).
405
+
406
+ void XPDFCore::copySelection() {
407
+ int pg;
408
+ double ulx, uly, lrx, lry;
409
+
410
+ if (!doc->okToCopy()) {
411
+ return;
412
+ }
413
+ if (getSelection(&pg, &ulx, &uly, &lrx, &lry)) {
414
+ //~ for multithreading: need a mutex here
415
+ if (currentSelection) {
416
+ delete currentSelection;
417
+ }
418
+ currentSelection = extractText(pg, ulx, uly, lrx, lry);
419
+ currentSelectionOwner = this;
420
+ XtOwnSelection(drawArea, XA_PRIMARY, XtLastTimestampProcessed(display),
421
+ &convertSelectionCbk, NULL, NULL);
422
+ }
423
+ }
424
+
425
+ Boolean XPDFCore::convertSelectionCbk(Widget widget, Atom *selection,
426
+ Atom *target, Atom *type,
427
+ XtPointer *value, unsigned long *length,
428
+ int *format) {
429
+ Atom *array;
430
+
431
+ // send back a list of supported conversion targets
432
+ if (*target == targetsAtom) {
433
+ if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
434
+ return False;
435
+ }
436
+ array[0] = XA_STRING;
437
+ *value = (XtPointer)array;
438
+ *type = XA_ATOM;
439
+ *format = 32;
440
+ *length = 1;
441
+ return True;
442
+
443
+ // send the selected text
444
+ } else if (*target == XA_STRING) {
445
+ //~ for multithreading: need a mutex here
446
+ *value = XtNewString(currentSelection->getCString());
447
+ *length = currentSelection->getLength();
448
+ *type = XA_STRING;
449
+ *format = 8; // 8-bit elements
450
+ return True;
451
+ }
452
+
453
+ return False;
454
+ }
455
+
456
+ //------------------------------------------------------------------------
457
+ // hyperlinks
458
+ //------------------------------------------------------------------------
459
+
460
+ void XPDFCore::doAction(LinkAction *action) {
461
+ LinkActionKind kind;
462
+ LinkDest *dest;
463
+ GString *namedDest;
464
+ char *s;
465
+ GString *fileName, *fileName2;
466
+ GString *cmd;
467
+ GString *actionName;
468
+ Object movieAnnot, obj1, obj2;
469
+ GString *msg;
470
+ int i;
471
+
472
+ switch (kind = action->getKind()) {
473
+
474
+ // GoTo / GoToR action
475
+ case actionGoTo:
476
+ case actionGoToR:
477
+ if (kind == actionGoTo) {
478
+ dest = NULL;
479
+ namedDest = NULL;
480
+ if ((dest = ((LinkGoTo *)action)->getDest())) {
481
+ dest = dest->copy();
482
+ } else if ((namedDest = ((LinkGoTo *)action)->getNamedDest())) {
483
+ namedDest = namedDest->copy();
484
+ }
485
+ } else {
486
+ dest = NULL;
487
+ namedDest = NULL;
488
+ if ((dest = ((LinkGoToR *)action)->getDest())) {
489
+ dest = dest->copy();
490
+ } else if ((namedDest = ((LinkGoToR *)action)->getNamedDest())) {
491
+ namedDest = namedDest->copy();
492
+ }
493
+ s = ((LinkGoToR *)action)->getFileName()->getCString();
494
+ //~ translate path name for VMS (deal with '/')
495
+ if (isAbsolutePath(s)) {
496
+ fileName = new GString(s);
497
+ } else {
498
+ fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);
499
+ }
500
+ if (loadFile(fileName) != errNone) {
501
+ if (dest) {
502
+ delete dest;
503
+ }
504
+ if (namedDest) {
505
+ delete namedDest;
506
+ }
507
+ delete fileName;
508
+ return;
509
+ }
510
+ delete fileName;
511
+ }
512
+ if (namedDest) {
513
+ dest = doc->findDest(namedDest);
514
+ delete namedDest;
515
+ }
516
+ if (dest) {
517
+ displayDest(dest, zoom, rotate, gTrue);
518
+ delete dest;
519
+ } else {
520
+ if (kind == actionGoToR) {
521
+ displayPage(1, zoom, 0, gFalse, gTrue);
522
+ }
523
+ }
524
+ break;
525
+
526
+ // Launch action
527
+ case actionLaunch:
528
+ fileName = ((LinkLaunch *)action)->getFileName();
529
+ s = fileName->getCString();
530
+ if (!strcmp(s + fileName->getLength() - 4, ".pdf") ||
531
+ !strcmp(s + fileName->getLength() - 4, ".PDF")) {
532
+ //~ translate path name for VMS (deal with '/')
533
+ if (isAbsolutePath(s)) {
534
+ fileName = fileName->copy();
535
+ } else {
536
+ fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);
537
+ }
538
+ if (loadFile(fileName) != errNone) {
539
+ delete fileName;
540
+ return;
541
+ }
542
+ delete fileName;
543
+ displayPage(1, zoom, rotate, gFalse, gTrue);
544
+ } else {
545
+ fileName = fileName->copy();
546
+ if (((LinkLaunch *)action)->getParams()) {
547
+ fileName->append(' ');
548
+ fileName->append(((LinkLaunch *)action)->getParams());
549
+ }
550
+ #ifdef VMS
551
+ fileName->insert(0, "spawn/nowait ");
552
+ #elif defined(__EMX__)
553
+ fileName->insert(0, "start /min /n ");
554
+ #else
555
+ fileName->append(" &");
556
+ #endif
557
+ msg = new GString("About to execute the command:\n");
558
+ msg->append(fileName);
559
+ if (doQuestionDialog("Launching external application", msg)) {
560
+ system(fileName->getCString());
561
+ }
562
+ delete fileName;
563
+ delete msg;
564
+ }
565
+ break;
566
+
567
+ // URI action
568
+ case actionURI:
569
+ if (!(cmd = globalParams->getURLCommand())) {
570
+ error(-1, "No urlCommand defined in config file");
571
+ break;
572
+ }
573
+ runCommand(cmd, ((LinkURI *)action)->getURI());
574
+ break;
575
+
576
+ // Named action
577
+ case actionNamed:
578
+ actionName = ((LinkNamed *)action)->getName();
579
+ if (!actionName->cmp("NextPage")) {
580
+ gotoNextPage(1, gTrue);
581
+ } else if (!actionName->cmp("PrevPage")) {
582
+ gotoPrevPage(1, gTrue, gFalse);
583
+ } else if (!actionName->cmp("FirstPage")) {
584
+ if (topPage != 1) {
585
+ displayPage(1, zoom, rotate, gTrue, gTrue);
586
+ }
587
+ } else if (!actionName->cmp("LastPage")) {
588
+ if (topPage != doc->getNumPages()) {
589
+ displayPage(doc->getNumPages(), zoom, rotate, gTrue, gTrue);
590
+ }
591
+ } else if (!actionName->cmp("GoBack")) {
592
+ goBackward();
593
+ } else if (!actionName->cmp("GoForward")) {
594
+ goForward();
595
+ } else if (!actionName->cmp("Quit")) {
596
+ if (actionCbk) {
597
+ (*actionCbk)(actionCbkData, actionName->getCString());
598
+ }
599
+ } else {
600
+ error(-1, "Unknown named action: '%s'", actionName->getCString());
601
+ }
602
+ break;
603
+
604
+ // Movie action
605
+ case actionMovie:
606
+ if (!(cmd = globalParams->getMovieCommand())) {
607
+ error(-1, "No movieCommand defined in config file");
608
+ break;
609
+ }
610
+ if (((LinkMovie *)action)->hasAnnotRef()) {
611
+ doc->getXRef()->fetch(((LinkMovie *)action)->getAnnotRef()->num,
612
+ ((LinkMovie *)action)->getAnnotRef()->gen,
613
+ &movieAnnot);
614
+ } else {
615
+ //~ need to use the correct page num here
616
+ doc->getCatalog()->getPage(topPage)->getAnnots(&obj1);
617
+ if (obj1.isArray()) {
618
+ for (i = 0; i < obj1.arrayGetLength(); ++i) {
619
+ if (obj1.arrayGet(i, &movieAnnot)->isDict()) {
620
+ if (movieAnnot.dictLookup("Subtype", &obj2)->isName("Movie")) {
621
+ obj2.free();
622
+ break;
623
+ }
624
+ obj2.free();
625
+ }
626
+ movieAnnot.free();
627
+ }
628
+ obj1.free();
629
+ }
630
+ }
631
+ if (movieAnnot.isDict()) {
632
+ if (movieAnnot.dictLookup("Movie", &obj1)->isDict()) {
633
+ if (obj1.dictLookup("F", &obj2)) {
634
+ if ((fileName = LinkAction::getFileSpecName(&obj2))) {
635
+ if (!isAbsolutePath(fileName->getCString())) {
636
+ fileName2 = appendToPath(
637
+ grabPath(doc->getFileName()->getCString()),
638
+ fileName->getCString());
639
+ delete fileName;
640
+ fileName = fileName2;
641
+ }
642
+ runCommand(cmd, fileName);
643
+ delete fileName;
644
+ }
645
+ obj2.free();
646
+ }
647
+ obj1.free();
648
+ }
649
+ }
650
+ movieAnnot.free();
651
+ break;
652
+
653
+ // unknown action type
654
+ case actionUnknown:
655
+ error(-1, "Unknown link action type: '%s'",
656
+ ((LinkUnknown *)action)->getAction()->getCString());
657
+ break;
658
+ }
659
+ }
660
+
661
+ // Run a command, given a <cmdFmt> string with one '%s' in it, and an
662
+ // <arg> string to insert in place of the '%s'.
663
+ void XPDFCore::runCommand(GString *cmdFmt, GString *arg) {
664
+ GString *cmd;
665
+ char *s;
666
+
667
+ if ((s = strstr(cmdFmt->getCString(), "%s"))) {
668
+ cmd = mungeURL(arg);
669
+ cmd->insert(0, cmdFmt->getCString(),
670
+ s - cmdFmt->getCString());
671
+ cmd->append(s + 2);
672
+ } else {
673
+ cmd = cmdFmt->copy();
674
+ }
675
+ #ifdef VMS
676
+ cmd->insert(0, "spawn/nowait ");
677
+ #elif defined(__EMX__)
678
+ cmd->insert(0, "start /min /n ");
679
+ #else
680
+ cmd->append(" &");
681
+ #endif
682
+ system(cmd->getCString());
683
+ delete cmd;
684
+ }
685
+
686
+ // Escape any characters in a URL which might cause problems when
687
+ // calling system().
688
+ GString *XPDFCore::mungeURL(GString *url) {
689
+ static char *allowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
690
+ "abcdefghijklmnopqrstuvwxyz"
691
+ "0123456789"
692
+ "-_.~/?:@&=+,#%";
693
+ GString *newURL;
694
+ char c;
695
+ char buf[4];
696
+ int i;
697
+
698
+ newURL = new GString();
699
+ for (i = 0; i < url->getLength(); ++i) {
700
+ c = url->getChar(i);
701
+ if (strchr(allowed, c)) {
702
+ newURL->append(c);
703
+ } else {
704
+ sprintf(buf, "%%%02x", c & 0xff);
705
+ newURL->append(buf);
706
+ }
707
+ }
708
+ return newURL;
709
+ }
710
+
711
+ //------------------------------------------------------------------------
712
+ // find
713
+ //------------------------------------------------------------------------
714
+
715
+ GBool XPDFCore::find(char *s, GBool caseSensitive,
716
+ GBool next, GBool backward, GBool onePageOnly) {
717
+ if (!PDFCore::find(s, caseSensitive, next, backward, onePageOnly)) {
718
+ XBell(display, 0);
719
+ return gFalse;
720
+ }
721
+ #ifndef NO_TEXT_SELECT
722
+ copySelection();
723
+ #endif
724
+ return gTrue;
725
+ }
726
+
727
+ GBool XPDFCore::findU(Unicode *u, int len, GBool caseSensitive,
728
+ GBool next, GBool backward, GBool onePageOnly) {
729
+ if (!PDFCore::findU(u, len, caseSensitive, next, backward, onePageOnly)) {
730
+ XBell(display, 0);
731
+ return gFalse;
732
+ }
733
+ #ifndef NO_TEXT_SELECT
734
+ copySelection();
735
+ #endif
736
+ return gTrue;
737
+ }
738
+
739
+ //------------------------------------------------------------------------
740
+ // misc access
741
+ //------------------------------------------------------------------------
742
+
743
+ void XPDFCore::setBusyCursor(GBool busy) {
744
+ setCursor(busy ? busyCursor : None);
745
+ }
746
+
747
+ void XPDFCore::takeFocus() {
748
+ XmProcessTraversal(drawArea, XmTRAVERSE_CURRENT);
749
+ }
750
+
751
+ //------------------------------------------------------------------------
752
+ // GUI code
753
+ //------------------------------------------------------------------------
754
+
755
+ void XPDFCore::setupX(GBool installCmap, int rgbCubeSizeA) {
756
+ XVisualInfo visualTempl;
757
+ XVisualInfo *visualList;
758
+ Gulong mask;
759
+ int nVisuals;
760
+ XColor xcolor;
761
+ XColor *xcolors;
762
+ int r, g, b, n, m;
763
+ GBool ok;
764
+
765
+ // for some reason, querying XmNvisual doesn't work (even if done
766
+ // after the window is mapped)
767
+ visual = DefaultVisual(display, screenNum);
768
+ XtVaGetValues(shell, XmNcolormap, &colormap, NULL);
769
+
770
+ // check for TrueColor visual
771
+ //~ this should scan the list, not just look at the first one
772
+ visualTempl.visualid = XVisualIDFromVisual(visual);
773
+ visualList = XGetVisualInfo(display, VisualIDMask,
774
+ &visualTempl, &nVisuals);
775
+ if (nVisuals < 1) {
776
+ // this shouldn't happen
777
+ XFree((XPointer)visualList);
778
+ visualList = XGetVisualInfo(display, VisualNoMask, &visualTempl,
779
+ &nVisuals);
780
+ }
781
+ depth = visualList->depth;
782
+ if (visualList->c_class == TrueColor) {
783
+ trueColor = gTrue;
784
+ for (mask = visualList->red_mask, rShift = 0;
785
+ mask && !(mask & 1);
786
+ mask >>= 1, ++rShift) ;
787
+ for (rDiv = 8; mask; mask >>= 1, --rDiv) ;
788
+ for (mask = visualList->green_mask, gShift = 0;
789
+ mask && !(mask & 1);
790
+ mask >>= 1, ++gShift) ;
791
+ for (gDiv = 8; mask; mask >>= 1, --gDiv) ;
792
+ for (mask = visualList->blue_mask, bShift = 0;
793
+ mask && !(mask & 1);
794
+ mask >>= 1, ++bShift) ;
795
+ for (bDiv = 8; mask; mask >>= 1, --bDiv) ;
796
+ } else {
797
+ trueColor = gFalse;
798
+ }
799
+ XFree((XPointer)visualList);
800
+
801
+ // allocate a color cube
802
+ if (!trueColor) {
803
+
804
+ // set colors in private colormap
805
+ if (installCmap) {
806
+ for (rgbCubeSize = xMaxRGBCube; rgbCubeSize >= 2; --rgbCubeSize) {
807
+ m = rgbCubeSize * rgbCubeSize * rgbCubeSize;
808
+ if (XAllocColorCells(display, colormap, False, NULL, 0, colors, m)) {
809
+ break;
810
+ }
811
+ }
812
+ if (rgbCubeSize >= 2) {
813
+ m = rgbCubeSize * rgbCubeSize * rgbCubeSize;
814
+ xcolors = (XColor *)gmallocn(m, sizeof(XColor));
815
+ n = 0;
816
+ for (r = 0; r < rgbCubeSize; ++r) {
817
+ for (g = 0; g < rgbCubeSize; ++g) {
818
+ for (b = 0; b < rgbCubeSize; ++b) {
819
+ xcolors[n].pixel = colors[n];
820
+ xcolors[n].red = (r * 65535) / (rgbCubeSize - 1);
821
+ xcolors[n].green = (g * 65535) / (rgbCubeSize - 1);
822
+ xcolors[n].blue = (b * 65535) / (rgbCubeSize - 1);
823
+ xcolors[n].flags = DoRed | DoGreen | DoBlue;
824
+ ++n;
825
+ }
826
+ }
827
+ }
828
+ XStoreColors(display, colormap, xcolors, m);
829
+ gfree(xcolors);
830
+ } else {
831
+ rgbCubeSize = 1;
832
+ colors[0] = BlackPixel(display, screenNum);
833
+ colors[1] = WhitePixel(display, screenNum);
834
+ }
835
+
836
+ // allocate colors in shared colormap
837
+ } else {
838
+ if (rgbCubeSize > xMaxRGBCube) {
839
+ rgbCubeSize = xMaxRGBCube;
840
+ }
841
+ ok = gFalse;
842
+ for (rgbCubeSize = rgbCubeSizeA; rgbCubeSize >= 2; --rgbCubeSize) {
843
+ ok = gTrue;
844
+ n = 0;
845
+ for (r = 0; r < rgbCubeSize && ok; ++r) {
846
+ for (g = 0; g < rgbCubeSize && ok; ++g) {
847
+ for (b = 0; b < rgbCubeSize && ok; ++b) {
848
+ if (n == 0) {
849
+ colors[n] = BlackPixel(display, screenNum);
850
+ ++n;
851
+ } else {
852
+ xcolor.red = (r * 65535) / (rgbCubeSize - 1);
853
+ xcolor.green = (g * 65535) / (rgbCubeSize - 1);
854
+ xcolor.blue = (b * 65535) / (rgbCubeSize - 1);
855
+ if (XAllocColor(display, colormap, &xcolor)) {
856
+ colors[n++] = xcolor.pixel;
857
+ } else {
858
+ ok = gFalse;
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+ if (ok) {
865
+ break;
866
+ }
867
+ XFreeColors(display, colormap, &colors[1], n-1, 0);
868
+ }
869
+ if (!ok) {
870
+ rgbCubeSize = 1;
871
+ colors[0] = BlackPixel(display, screenNum);
872
+ colors[1] = WhitePixel(display, screenNum);
873
+ }
874
+ }
875
+ }
876
+ }
877
+
878
+ void XPDFCore::initWindow() {
879
+ Arg args[20];
880
+ int n;
881
+
882
+ // create the cursors
883
+ busyCursor = XCreateFontCursor(display, XC_watch);
884
+ linkCursor = XCreateFontCursor(display, XC_hand2);
885
+ selectCursor = XCreateFontCursor(display, XC_cross);
886
+ currentCursor = 0;
887
+
888
+ // create the scrolled window and scrollbars
889
+ n = 0;
890
+ XtSetArg(args[n], XmNscrollingPolicy, XmAPPLICATION_DEFINED); ++n;
891
+ XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
892
+ scrolledWin = XmCreateScrolledWindow(parentWidget, "scroll", args, n);
893
+ XtManageChild(scrolledWin);
894
+ n = 0;
895
+ XtSetArg(args[n], XmNorientation, XmHORIZONTAL); ++n;
896
+ XtSetArg(args[n], XmNminimum, 0); ++n;
897
+ XtSetArg(args[n], XmNmaximum, 1); ++n;
898
+ XtSetArg(args[n], XmNsliderSize, 1); ++n;
899
+ XtSetArg(args[n], XmNvalue, 0); ++n;
900
+ XtSetArg(args[n], XmNincrement, 1); ++n;
901
+ XtSetArg(args[n], XmNpageIncrement, 1); ++n;
902
+ hScrollBar = XmCreateScrollBar(scrolledWin, "hScrollBar", args, n);
903
+ if (!fullScreen) {
904
+ XtManageChild(hScrollBar);
905
+ }
906
+ XtAddCallback(hScrollBar, XmNvalueChangedCallback,
907
+ &hScrollChangeCbk, (XtPointer)this);
908
+ #ifndef DISABLE_SMOOTH_SCROLL
909
+ XtAddCallback(hScrollBar, XmNdragCallback,
910
+ &hScrollDragCbk, (XtPointer)this);
911
+ #endif
912
+ n = 0;
913
+ XtSetArg(args[n], XmNorientation, XmVERTICAL); ++n;
914
+ XtSetArg(args[n], XmNminimum, 0); ++n;
915
+ XtSetArg(args[n], XmNmaximum, 1); ++n;
916
+ XtSetArg(args[n], XmNsliderSize, 1); ++n;
917
+ XtSetArg(args[n], XmNvalue, 0); ++n;
918
+ XtSetArg(args[n], XmNincrement, 1); ++n;
919
+ XtSetArg(args[n], XmNpageIncrement, 1); ++n;
920
+ vScrollBar = XmCreateScrollBar(scrolledWin, "vScrollBar", args, n);
921
+ if (!fullScreen) {
922
+ XtManageChild(vScrollBar);
923
+ }
924
+ XtAddCallback(vScrollBar, XmNvalueChangedCallback,
925
+ &vScrollChangeCbk, (XtPointer)this);
926
+ #ifndef DISABLE_SMOOTH_SCROLL
927
+ XtAddCallback(vScrollBar, XmNdragCallback,
928
+ &vScrollDragCbk, (XtPointer)this);
929
+ #endif
930
+
931
+ // create the drawing area
932
+ n = 0;
933
+ XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); ++n;
934
+ XtSetArg(args[n], XmNmarginWidth, 0); ++n;
935
+ XtSetArg(args[n], XmNmarginHeight, 0); ++n;
936
+ if (fullScreen) {
937
+ XtSetArg(args[n], XmNshadowThickness, 0); ++n;
938
+ }
939
+ drawAreaFrame = XmCreateFrame(scrolledWin, "drawAreaFrame", args, n);
940
+ XtManageChild(drawAreaFrame);
941
+ n = 0;
942
+ XtSetArg(args[n], XmNresizePolicy, XmRESIZE_ANY); ++n;
943
+ XtSetArg(args[n], XmNwidth, 700); ++n;
944
+ XtSetArg(args[n], XmNheight, 500); ++n;
945
+ drawArea = XmCreateDrawingArea(drawAreaFrame, "drawArea", args, n);
946
+ XtManageChild(drawArea);
947
+ XtAddCallback(drawArea, XmNresizeCallback, &resizeCbk, (XtPointer)this);
948
+ XtAddCallback(drawArea, XmNexposeCallback, &redrawCbk, (XtPointer)this);
949
+ XtAddCallback(drawArea, XmNinputCallback, &inputCbk, (XtPointer)this);
950
+ resizeCbk(drawArea, this, NULL);
951
+
952
+ // set up mouse motion translations
953
+ XtOverrideTranslations(drawArea, XtParseTranslationTable(
954
+ "<Btn1Down>:DrawingAreaInput()\n"
955
+ "<Btn1Up>:DrawingAreaInput()\n"
956
+ "<Btn1Motion>:DrawingAreaInput()\n"
957
+ "<Motion>:DrawingAreaInput()"));
958
+
959
+ // can't create a GC until the window gets mapped
960
+ drawAreaGC = NULL;
961
+ }
962
+
963
+ void XPDFCore::hScrollChangeCbk(Widget widget, XtPointer ptr,
964
+ XtPointer callData) {
965
+ XPDFCore *core = (XPDFCore *)ptr;
966
+ XmScrollBarCallbackStruct *data = (XmScrollBarCallbackStruct *)callData;
967
+
968
+ core->scrollTo(data->value, core->scrollY);
969
+ }
970
+
971
+ void XPDFCore::hScrollDragCbk(Widget widget, XtPointer ptr,
972
+ XtPointer callData) {
973
+ XPDFCore *core = (XPDFCore *)ptr;
974
+ XmScrollBarCallbackStruct *data = (XmScrollBarCallbackStruct *)callData;
975
+
976
+ core->scrollTo(data->value, core->scrollY);
977
+ }
978
+
979
+ void XPDFCore::vScrollChangeCbk(Widget widget, XtPointer ptr,
980
+ XtPointer callData) {
981
+ XPDFCore *core = (XPDFCore *)ptr;
982
+ XmScrollBarCallbackStruct *data = (XmScrollBarCallbackStruct *)callData;
983
+
984
+ core->scrollTo(core->scrollX, data->value);
985
+ }
986
+
987
+ void XPDFCore::vScrollDragCbk(Widget widget, XtPointer ptr,
988
+ XtPointer callData) {
989
+ XPDFCore *core = (XPDFCore *)ptr;
990
+ XmScrollBarCallbackStruct *data = (XmScrollBarCallbackStruct *)callData;
991
+
992
+ core->scrollTo(core->scrollX, data->value);
993
+ }
994
+
995
+ void XPDFCore::resizeCbk(Widget widget, XtPointer ptr, XtPointer callData) {
996
+ XPDFCore *core = (XPDFCore *)ptr;
997
+ XEvent event;
998
+ Widget top;
999
+ Window rootWin;
1000
+ int x1, y1;
1001
+ Guint w1, h1, bw1, depth1;
1002
+ Arg args[2];
1003
+ int n;
1004
+ Dimension w, h;
1005
+ int sx, sy;
1006
+
1007
+ // find the top-most widget which has an associated window, and look
1008
+ // for a pending ConfigureNotify in the event queue -- if there is
1009
+ // one, and it specifies a different width or height, that means
1010
+ // we're still resizing, and we want to skip the current event
1011
+ for (top = core->parentWidget;
1012
+ XtParent(top) && XtWindow(XtParent(top));
1013
+ top = XtParent(top)) ;
1014
+ if (XCheckTypedWindowEvent(core->display, XtWindow(top),
1015
+ ConfigureNotify, &event)) {
1016
+ XPutBackEvent(core->display, &event);
1017
+ XGetGeometry(core->display, event.xconfigure.window,
1018
+ &rootWin, &x1, &y1, &w1, &h1, &bw1, &depth1);
1019
+ if ((Guint)event.xconfigure.width != w1 ||
1020
+ (Guint)event.xconfigure.height != h1) {
1021
+ return;
1022
+ }
1023
+ }
1024
+
1025
+ n = 0;
1026
+ XtSetArg(args[n], XmNwidth, &w); ++n;
1027
+ XtSetArg(args[n], XmNheight, &h); ++n;
1028
+ XtGetValues(core->drawArea, args, n);
1029
+ core->drawAreaWidth = (int)w;
1030
+ core->drawAreaHeight = (int)h;
1031
+ if (core->zoom == zoomPage || core->zoom == zoomWidth) {
1032
+ sx = sy = -1;
1033
+ } else {
1034
+ sx = core->scrollX;
1035
+ sy = core->scrollY;
1036
+ }
1037
+ core->update(core->topPage, sx, sy, core->zoom, core->rotate, gTrue, gFalse);
1038
+ }
1039
+
1040
+ void XPDFCore::redrawCbk(Widget widget, XtPointer ptr, XtPointer callData) {
1041
+ XPDFCore *core = (XPDFCore *)ptr;
1042
+ XmDrawingAreaCallbackStruct *data = (XmDrawingAreaCallbackStruct *)callData;
1043
+ int x, y, w, h;
1044
+
1045
+ if (data->reason == XmCR_EXPOSE) {
1046
+ x = data->event->xexpose.x;
1047
+ y = data->event->xexpose.y;
1048
+ w = data->event->xexpose.width;
1049
+ h = data->event->xexpose.height;
1050
+ } else {
1051
+ x = 0;
1052
+ y = 0;
1053
+ w = core->drawAreaWidth;
1054
+ h = core->drawAreaHeight;
1055
+ }
1056
+ core->redrawWindow(x, y, w, h, gFalse);
1057
+ }
1058
+
1059
+ void XPDFCore::inputCbk(Widget widget, XtPointer ptr, XtPointer callData) {
1060
+ XPDFCore *core = (XPDFCore *)ptr;
1061
+ XmDrawingAreaCallbackStruct *data = (XmDrawingAreaCallbackStruct *)callData;
1062
+ LinkAction *action;
1063
+ int pg, x, y;
1064
+ double xu, yu;
1065
+ char *s;
1066
+ KeySym key;
1067
+ GBool ok;
1068
+
1069
+ switch (data->event->type) {
1070
+ case ButtonPress:
1071
+ if (*core->mouseCbk) {
1072
+ (*core->mouseCbk)(core->mouseCbkData, data->event);
1073
+ }
1074
+ break;
1075
+ case ButtonRelease:
1076
+ if (*core->mouseCbk) {
1077
+ (*core->mouseCbk)(core->mouseCbkData, data->event);
1078
+ }
1079
+ break;
1080
+ case MotionNotify:
1081
+ if (core->doc && core->doc->getNumPages() > 0) {
1082
+ ok = core->cvtWindowToDev(data->event->xmotion.x, data->event->xmotion.y,
1083
+ &pg, &x, &y);
1084
+ if (core->dragging) {
1085
+ if (ok) {
1086
+ core->moveSelection(pg, x, y);
1087
+ }
1088
+ } else if (core->hyperlinksEnabled) {
1089
+ core->cvtDevToUser(pg, x, y, &xu, &yu);
1090
+ if (ok && (action = core->findLink(pg, xu, yu))) {
1091
+ core->setCursor(core->linkCursor);
1092
+ if (action != core->linkAction) {
1093
+ core->linkAction = action;
1094
+ if (core->updateCbk) {
1095
+ s = "";
1096
+ switch (action->getKind()) {
1097
+ case actionGoTo:
1098
+ s = "[internal link]";
1099
+ break;
1100
+ case actionGoToR:
1101
+ s = ((LinkGoToR *)action)->getFileName()->getCString();
1102
+ break;
1103
+ case actionLaunch:
1104
+ s = ((LinkLaunch *)action)->getFileName()->getCString();
1105
+ break;
1106
+ case actionURI:
1107
+ s = ((LinkURI *)action)->getURI()->getCString();
1108
+ break;
1109
+ case actionNamed:
1110
+ s = ((LinkNamed *)action)->getName()->getCString();
1111
+ break;
1112
+ case actionMovie:
1113
+ s = "[movie]";
1114
+ break;
1115
+ case actionUnknown:
1116
+ s = "[unknown link]";
1117
+ break;
1118
+ }
1119
+ (*core->updateCbk)(core->updateCbkData, NULL, -1, -1, s);
1120
+ }
1121
+ }
1122
+ } else {
1123
+ core->setCursor(None);
1124
+ if (core->linkAction) {
1125
+ core->linkAction = NULL;
1126
+ if (core->updateCbk) {
1127
+ (*core->updateCbk)(core->updateCbkData, NULL, -1, -1, "");
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ if (core->panning) {
1134
+ core->scrollTo(core->scrollX - (data->event->xmotion.x - core->panMX),
1135
+ core->scrollY - (data->event->xmotion.y - core->panMY));
1136
+ core->panMX = data->event->xmotion.x;
1137
+ core->panMY = data->event->xmotion.y;
1138
+ }
1139
+ break;
1140
+ case KeyPress:
1141
+ if (core->keyPressCbk) {
1142
+ key = XLookupKeysym(&data->event->xkey,
1143
+ (data->event->xkey.state & ShiftMask) ? 1 : 0);
1144
+ (*core->keyPressCbk)(core->keyPressCbkData,
1145
+ key, data->event->xkey.state, data->event);
1146
+ }
1147
+ break;
1148
+ }
1149
+ }
1150
+
1151
+ PDFCoreTile *XPDFCore::newTile(int xDestA, int yDestA) {
1152
+ return new XPDFCoreTile(xDestA, yDestA);
1153
+ }
1154
+
1155
+ void XPDFCore::updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
1156
+ int width, int height, GBool composited) {
1157
+ XPDFCoreTile *tile = (XPDFCoreTile *)tileA;
1158
+ XImage *image;
1159
+ SplashColorPtr dataPtr, p;
1160
+ Gulong pixel;
1161
+ Guchar *ap;
1162
+ Guchar alpha, alpha1;
1163
+ int w, h, bw, x, y, r, g, b, gray;
1164
+ int *errDownR, *errDownG, *errDownB;
1165
+ int errRightR, errRightG, errRightB;
1166
+ int errDownRightR, errDownRightG, errDownRightB;
1167
+ int r0, g0, b0, re, ge, be;
1168
+
1169
+ if (!tile->image) {
1170
+ w = tile->xMax - tile->xMin;
1171
+ h = tile->yMax - tile->yMin;
1172
+ image = XCreateImage(display, visual, depth, ZPixmap, 0, NULL, w, h, 8, 0);
1173
+ image->data = (char *)gmalloc(h * image->bytes_per_line);
1174
+ tile->image = image;
1175
+ } else {
1176
+ image = (XImage *)tile->image;
1177
+ }
1178
+
1179
+ //~ optimize for known XImage formats
1180
+ bw = tile->bitmap->getRowSize();
1181
+ dataPtr = tile->bitmap->getDataPtr();
1182
+
1183
+ if (trueColor) {
1184
+ for (y = 0; y < height; ++y) {
1185
+ p = dataPtr + (ySrc + y) * bw + xSrc * 3;
1186
+ if (!composited && tile->bitmap->getAlphaPtr()) {
1187
+ ap = tile->bitmap->getAlphaPtr() +
1188
+ (ySrc + y) * tile->bitmap->getWidth() + xSrc;
1189
+ } else {
1190
+ ap = NULL;
1191
+ }
1192
+ for (x = 0; x < width; ++x) {
1193
+ r = splashRGB8R(p);
1194
+ g = splashRGB8G(p);
1195
+ b = splashRGB8B(p);
1196
+ if (ap) {
1197
+ alpha = *ap++;
1198
+ alpha1 = 255 - alpha;
1199
+ r = div255(alpha1 * paperColor[0] + alpha * r);
1200
+ g = div255(alpha1 * paperColor[1] + alpha * g);
1201
+ b = div255(alpha1 * paperColor[2] + alpha * b);
1202
+ }
1203
+ r >>= rDiv;
1204
+ g >>= gDiv;
1205
+ b >>= bDiv;
1206
+ pixel = ((Gulong)r << rShift) +
1207
+ ((Gulong)g << gShift) +
1208
+ ((Gulong)b << bShift);
1209
+ XPutPixel(image, xSrc + x, ySrc + y, pixel);
1210
+ p += 3;
1211
+ }
1212
+ }
1213
+ } else if (rgbCubeSize == 1) {
1214
+ //~ this should really use splashModeMono, with non-clustered dithering
1215
+ for (y = 0; y < height; ++y) {
1216
+ p = dataPtr + (ySrc + y) * bw + xSrc * 3;
1217
+ if (!composited && tile->bitmap->getAlphaPtr()) {
1218
+ ap = tile->bitmap->getAlphaPtr() +
1219
+ (ySrc + y) * tile->bitmap->getWidth() + xSrc;
1220
+ } else {
1221
+ ap = NULL;
1222
+ }
1223
+ for (x = 0; x < width; ++x) {
1224
+ r = splashRGB8R(p);
1225
+ g = splashRGB8G(p);
1226
+ b = splashRGB8B(p);
1227
+ if (ap) {
1228
+ alpha = *ap++;
1229
+ alpha1 = 255 - alpha;
1230
+ r = div255(alpha1 * paperColor[0] + alpha * r);
1231
+ g = div255(alpha1 * paperColor[1] + alpha * g);
1232
+ b = div255(alpha1 * paperColor[2] + alpha * b);
1233
+ }
1234
+ gray = (int)(0.299 * r + 0.587 * g + 0.114 * b + 0.5);
1235
+ if (gray < 128) {
1236
+ pixel = colors[0];
1237
+ } else {
1238
+ pixel = colors[1];
1239
+ }
1240
+ XPutPixel(image, xSrc + x, ySrc + y, pixel);
1241
+ p += 3;
1242
+ }
1243
+ }
1244
+ } else {
1245
+ // do Floyd-Steinberg dithering on the whole bitmap
1246
+ errDownR = (int *)gmallocn(width + 2, sizeof(int));
1247
+ errDownG = (int *)gmallocn(width + 2, sizeof(int));
1248
+ errDownB = (int *)gmallocn(width + 2, sizeof(int));
1249
+ errRightR = errRightG = errRightB = 0;
1250
+ errDownRightR = errDownRightG = errDownRightB = 0;
1251
+ memset(errDownR, 0, (width + 2) * sizeof(int));
1252
+ memset(errDownG, 0, (width + 2) * sizeof(int));
1253
+ memset(errDownB, 0, (width + 2) * sizeof(int));
1254
+ for (y = 0; y < height; ++y) {
1255
+ p = dataPtr + (ySrc + y) * bw + xSrc * 3;
1256
+ if (!composited && tile->bitmap->getAlphaPtr()) {
1257
+ ap = tile->bitmap->getAlphaPtr() +
1258
+ (ySrc + y) * tile->bitmap->getWidth() + xSrc;
1259
+ } else {
1260
+ ap = NULL;
1261
+ }
1262
+ for (x = 0; x < width; ++x) {
1263
+ r = splashRGB8R(p);
1264
+ g = splashRGB8G(p);
1265
+ b = splashRGB8B(p);
1266
+ if (ap) {
1267
+ alpha = *ap++;
1268
+ alpha1 = 255 - alpha;
1269
+ r = div255(alpha1 * paperColor[0] + alpha * r);
1270
+ g = div255(alpha1 * paperColor[1] + alpha * g);
1271
+ b = div255(alpha1 * paperColor[2] + alpha * b);
1272
+ }
1273
+ r0 = r + errRightR + errDownR[x+1];
1274
+ g0 = g + errRightG + errDownG[x+1];
1275
+ b0 = b + errRightB + errDownB[x+1];
1276
+ if (r0 < 0) {
1277
+ r = 0;
1278
+ } else if (r0 >= 255) {
1279
+ r = rgbCubeSize - 1;
1280
+ } else {
1281
+ r = div255(r0 * (rgbCubeSize - 1));
1282
+ }
1283
+ if (g0 < 0) {
1284
+ g = 0;
1285
+ } else if (g0 >= 255) {
1286
+ g = rgbCubeSize - 1;
1287
+ } else {
1288
+ g = div255(g0 * (rgbCubeSize - 1));
1289
+ }
1290
+ if (b0 < 0) {
1291
+ b = 0;
1292
+ } else if (b0 >= 255) {
1293
+ b = rgbCubeSize - 1;
1294
+ } else {
1295
+ b = div255(b0 * (rgbCubeSize - 1));
1296
+ }
1297
+ re = r0 - ((r << 8) - r) / (rgbCubeSize - 1);
1298
+ ge = g0 - ((g << 8) - g) / (rgbCubeSize - 1);
1299
+ be = b0 - ((b << 8) - b) / (rgbCubeSize - 1);
1300
+ errRightR = (re * 7) >> 4;
1301
+ errRightG = (ge * 7) >> 4;
1302
+ errRightB = (be * 7) >> 4;
1303
+ errDownR[x] += (re * 3) >> 4;
1304
+ errDownG[x] += (ge * 3) >> 4;
1305
+ errDownB[x] += (be * 3) >> 4;
1306
+ errDownR[x+1] = ((re * 5) >> 4) + errDownRightR;
1307
+ errDownG[x+1] = ((ge * 5) >> 4) + errDownRightG;
1308
+ errDownB[x+1] = ((be * 5) >> 4) + errDownRightB;
1309
+ errDownRightR = re >> 4;
1310
+ errDownRightG = ge >> 4;
1311
+ errDownRightB = be >> 4;
1312
+ pixel = colors[(r * rgbCubeSize + g) * rgbCubeSize + b];
1313
+ XPutPixel(image, xSrc + x, ySrc + y, pixel);
1314
+ p += 3;
1315
+ }
1316
+ }
1317
+ gfree(errDownR);
1318
+ gfree(errDownG);
1319
+ gfree(errDownB);
1320
+ }
1321
+ }
1322
+
1323
+ void XPDFCore::redrawRect(PDFCoreTile *tileA, int xSrc, int ySrc,
1324
+ int xDest, int yDest, int width, int height,
1325
+ GBool composited) {
1326
+ XPDFCoreTile *tile = (XPDFCoreTile *)tileA;
1327
+ Window drawAreaWin;
1328
+ XGCValues gcValues;
1329
+
1330
+ // create a GC for the drawing area
1331
+ drawAreaWin = XtWindow(drawArea);
1332
+ if (!drawAreaGC) {
1333
+ gcValues.foreground = mattePixel;
1334
+ drawAreaGC = XCreateGC(display, drawAreaWin, GCForeground, &gcValues);
1335
+ }
1336
+
1337
+ // draw the document
1338
+ if (tile) {
1339
+ XPutImage(display, drawAreaWin, drawAreaGC, tile->image,
1340
+ xSrc, ySrc, xDest, yDest, width, height);
1341
+
1342
+ // draw the background
1343
+ } else {
1344
+ XFillRectangle(display, drawAreaWin, drawAreaGC,
1345
+ xDest, yDest, width, height);
1346
+ }
1347
+ }
1348
+
1349
+ void XPDFCore::updateScrollbars() {
1350
+ Arg args[20];
1351
+ int n;
1352
+ int maxPos;
1353
+
1354
+ if (pages->getLength() > 0) {
1355
+ if (continuousMode) {
1356
+ maxPos = maxPageW;
1357
+ } else {
1358
+ maxPos = ((PDFCorePage *)pages->get(0))->w;
1359
+ }
1360
+ } else {
1361
+ maxPos = 1;
1362
+ }
1363
+ if (maxPos < drawAreaWidth) {
1364
+ maxPos = drawAreaWidth;
1365
+ }
1366
+ n = 0;
1367
+ XtSetArg(args[n], XmNvalue, scrollX); ++n;
1368
+ XtSetArg(args[n], XmNmaximum, maxPos); ++n;
1369
+ XtSetArg(args[n], XmNsliderSize, drawAreaWidth); ++n;
1370
+ XtSetArg(args[n], XmNincrement, 16); ++n;
1371
+ XtSetArg(args[n], XmNpageIncrement, drawAreaWidth); ++n;
1372
+ XtSetValues(hScrollBar, args, n);
1373
+
1374
+ if (pages->getLength() > 0) {
1375
+ if (continuousMode) {
1376
+ maxPos = totalDocH;
1377
+ } else {
1378
+ maxPos = ((PDFCorePage *)pages->get(0))->h;
1379
+ }
1380
+ } else {
1381
+ maxPos = 1;
1382
+ }
1383
+ if (maxPos < drawAreaHeight) {
1384
+ maxPos = drawAreaHeight;
1385
+ }
1386
+ n = 0;
1387
+ XtSetArg(args[n], XmNvalue, scrollY); ++n;
1388
+ XtSetArg(args[n], XmNmaximum, maxPos); ++n;
1389
+ XtSetArg(args[n], XmNsliderSize, drawAreaHeight); ++n;
1390
+ XtSetArg(args[n], XmNincrement, 16); ++n;
1391
+ XtSetArg(args[n], XmNpageIncrement, drawAreaHeight); ++n;
1392
+ XtSetValues(vScrollBar, args, n);
1393
+ }
1394
+
1395
+ void XPDFCore::setCursor(Cursor cursor) {
1396
+ Window topWin;
1397
+
1398
+ if (cursor == currentCursor) {
1399
+ return;
1400
+ }
1401
+ if (!(topWin = XtWindow(shell))) {
1402
+ return;
1403
+ }
1404
+ if (cursor == None) {
1405
+ XUndefineCursor(display, topWin);
1406
+ } else {
1407
+ XDefineCursor(display, topWin, cursor);
1408
+ }
1409
+ XFlush(display);
1410
+ currentCursor = cursor;
1411
+ }
1412
+
1413
+ GBool XPDFCore::doQuestionDialog(char *title, GString *msg) {
1414
+ return doDialog(XmDIALOG_QUESTION, gTrue, title, msg);
1415
+ }
1416
+
1417
+ void XPDFCore::doInfoDialog(char *title, GString *msg) {
1418
+ doDialog(XmDIALOG_INFORMATION, gFalse, title, msg);
1419
+ }
1420
+
1421
+ void XPDFCore::doErrorDialog(char *title, GString *msg) {
1422
+ doDialog(XmDIALOG_ERROR, gFalse, title, msg);
1423
+ }
1424
+
1425
+ GBool XPDFCore::doDialog(int type, GBool hasCancel,
1426
+ char *title, GString *msg) {
1427
+ Widget dialog, scroll, text;
1428
+ XtAppContext appContext;
1429
+ Arg args[20];
1430
+ int n;
1431
+ XmString s1, s2;
1432
+ XEvent event;
1433
+
1434
+ n = 0;
1435
+ XtSetArg(args[n], XmNdialogType, type); ++n;
1436
+ XtSetArg(args[n], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); ++n;
1437
+ s1 = XmStringCreateLocalized(title);
1438
+ XtSetArg(args[n], XmNdialogTitle, s1); ++n;
1439
+ s2 = NULL; // make gcc happy
1440
+ if (msg->getLength() <= 80) {
1441
+ s2 = XmStringCreateLocalized(msg->getCString());
1442
+ XtSetArg(args[n], XmNmessageString, s2); ++n;
1443
+ }
1444
+ dialog = XmCreateMessageDialog(drawArea, "questionDialog", args, n);
1445
+ XmStringFree(s1);
1446
+ if (msg->getLength() <= 80) {
1447
+ XmStringFree(s2);
1448
+ } else {
1449
+ n = 0;
1450
+ XtSetArg(args[n], XmNscrollingPolicy, XmAUTOMATIC); ++n;
1451
+ if (drawAreaWidth > 300) {
1452
+ XtSetArg(args[n], XmNwidth, drawAreaWidth - 100); ++n;
1453
+ }
1454
+ scroll = XmCreateScrolledWindow(dialog, "scroll", args, n);
1455
+ XtManageChild(scroll);
1456
+ n = 0;
1457
+ XtSetArg(args[n], XmNeditable, False); ++n;
1458
+ XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); ++n;
1459
+ XtSetArg(args[n], XmNvalue, msg->getCString()); ++n;
1460
+ XtSetArg(args[n], XmNshadowThickness, 0); ++n;
1461
+ text = XmCreateText(scroll, "text", args, n);
1462
+ XtManageChild(text);
1463
+ }
1464
+ XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
1465
+ XtAddCallback(dialog, XmNokCallback,
1466
+ &dialogOkCbk, (XtPointer)this);
1467
+ if (hasCancel) {
1468
+ XtAddCallback(dialog, XmNcancelCallback,
1469
+ &dialogCancelCbk, (XtPointer)this);
1470
+ } else {
1471
+ XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
1472
+ }
1473
+
1474
+ XtManageChild(dialog);
1475
+
1476
+ appContext = XtWidgetToApplicationContext(dialog);
1477
+ dialogDone = 0;
1478
+ do {
1479
+ XtAppNextEvent(appContext, &event);
1480
+ XtDispatchEvent(&event);
1481
+ } while (!dialogDone);
1482
+
1483
+ XtUnmanageChild(dialog);
1484
+ XtDestroyWidget(dialog);
1485
+
1486
+ return dialogDone > 0;
1487
+ }
1488
+
1489
+ void XPDFCore::dialogOkCbk(Widget widget, XtPointer ptr,
1490
+ XtPointer callData) {
1491
+ XPDFCore *core = (XPDFCore *)ptr;
1492
+
1493
+ core->dialogDone = 1;
1494
+ }
1495
+
1496
+ void XPDFCore::dialogCancelCbk(Widget widget, XtPointer ptr,
1497
+ XtPointer callData) {
1498
+ XPDFCore *core = (XPDFCore *)ptr;
1499
+
1500
+ core->dialogDone = -1;
1501
+ }
1502
+
1503
+ //------------------------------------------------------------------------
1504
+ // password dialog
1505
+ //------------------------------------------------------------------------
1506
+
1507
+ void XPDFCore::initPasswordDialog() {
1508
+ Widget row, label, okBtn, cancelBtn;
1509
+ Arg args[20];
1510
+ int n;
1511
+ XmString s;
1512
+
1513
+ //----- dialog
1514
+ n = 0;
1515
+ s = XmStringCreateLocalized(xpdfAppName ": Password");
1516
+ XtSetArg(args[n], XmNdialogTitle, s); ++n;
1517
+ XtSetArg(args[n], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); ++n;
1518
+ passwordDialog = XmCreateFormDialog(drawArea, "passwordDialog", args, n);
1519
+ XmStringFree(s);
1520
+
1521
+ //----- message
1522
+ n = 0;
1523
+ XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); ++n;
1524
+ XtSetArg(args[n], XmNtopOffset, 4); ++n;
1525
+ XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
1526
+ XtSetArg(args[n], XmNleftOffset, 4); ++n;
1527
+ s = XmStringCreateLocalized("This document requires a password.");
1528
+ XtSetArg(args[n], XmNlabelString, s); ++n;
1529
+ label = XmCreateLabel(passwordDialog, "msg", args, n);
1530
+ XmStringFree(s);
1531
+ XtManageChild(label);
1532
+
1533
+ //----- label and password entry
1534
+ n = 0;
1535
+ XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n;
1536
+ XtSetArg(args[n], XmNtopWidget, label); ++n;
1537
+ XtSetArg(args[n], XmNtopOffset, 4); ++n;
1538
+ XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
1539
+ XtSetArg(args[n], XmNleftOffset, 4); ++n;
1540
+ XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); ++n;
1541
+ XtSetArg(args[n], XmNleftOffset, 4); ++n;
1542
+ XtSetArg(args[n], XmNorientation, XmHORIZONTAL); ++n;
1543
+ XtSetArg(args[n], XmNpacking, XmPACK_TIGHT); ++n;
1544
+ row = XmCreateRowColumn(passwordDialog, "row", args, n);
1545
+ XtManageChild(row);
1546
+ n = 0;
1547
+ s = XmStringCreateLocalized("Password: ");
1548
+ XtSetArg(args[n], XmNlabelString, s); ++n;
1549
+ label = XmCreateLabel(row, "label", args, n);
1550
+ XmStringFree(s);
1551
+ XtManageChild(label);
1552
+ n = 0;
1553
+ XtSetArg(args[n], XmNcolumns, 16); ++n;
1554
+ passwordText = XmCreateTextField(row, "text", args, n);
1555
+ XtManageChild(passwordText);
1556
+ XtAddCallback(passwordText, XmNmodifyVerifyCallback,
1557
+ &passwordTextVerifyCbk, this);
1558
+
1559
+ //----- "Ok" and "Cancel" buttons
1560
+ n = 0;
1561
+ XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n;
1562
+ XtSetArg(args[n], XmNtopWidget, row); ++n;
1563
+ XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
1564
+ XtSetArg(args[n], XmNleftOffset, 4); ++n;
1565
+ XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
1566
+ XtSetArg(args[n], XmNbottomOffset, 4); ++n;
1567
+ XtSetArg(args[n], XmNnavigationType, XmEXCLUSIVE_TAB_GROUP); ++n;
1568
+ okBtn = XmCreatePushButton(passwordDialog, "Ok", args, n);
1569
+ XtManageChild(okBtn);
1570
+ XtAddCallback(okBtn, XmNactivateCallback,
1571
+ &passwordOkCbk, (XtPointer)this);
1572
+ n = 0;
1573
+ XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n;
1574
+ XtSetArg(args[n], XmNtopWidget, row); ++n;
1575
+ XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); ++n;
1576
+ XtSetArg(args[n], XmNrightOffset, 4); ++n;
1577
+ XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
1578
+ XtSetArg(args[n], XmNbottomOffset, 4); ++n;
1579
+ XtSetArg(args[n], XmNnavigationType, XmEXCLUSIVE_TAB_GROUP); ++n;
1580
+ cancelBtn = XmCreatePushButton(passwordDialog, "Cancel", args, n);
1581
+ XtManageChild(cancelBtn);
1582
+ XtAddCallback(cancelBtn, XmNactivateCallback,
1583
+ &passwordCancelCbk, (XtPointer)this);
1584
+ n = 0;
1585
+ XtSetArg(args[n], XmNdefaultButton, okBtn); ++n;
1586
+ XtSetArg(args[n], XmNcancelButton, cancelBtn); ++n;
1587
+ #if XmVersion > 1001
1588
+ XtSetArg(args[n], XmNinitialFocus, passwordText); ++n;
1589
+ #endif
1590
+ XtSetValues(passwordDialog, args, n);
1591
+ }
1592
+
1593
+ void XPDFCore::passwordTextVerifyCbk(Widget widget, XtPointer ptr,
1594
+ XtPointer callData) {
1595
+ XPDFCore *core = (XPDFCore *)ptr;
1596
+ XmTextVerifyCallbackStruct *data =
1597
+ (XmTextVerifyCallbackStruct *)callData;
1598
+ int i, n;
1599
+
1600
+ i = (int)data->startPos;
1601
+ n = (int)data->endPos - i;
1602
+ if (i > core->password->getLength()) {
1603
+ i = core->password->getLength();
1604
+ }
1605
+ if (i + n > core->password->getLength()) {
1606
+ n = core->password->getLength() - i;
1607
+ }
1608
+ core->password->del(i, n);
1609
+ core->password->insert(i, data->text->ptr, data->text->length);
1610
+
1611
+ for (i = 0; i < data->text->length; ++i) {
1612
+ data->text->ptr[i] = '*';
1613
+ }
1614
+ data->doit = True;
1615
+ }
1616
+
1617
+ void XPDFCore::passwordOkCbk(Widget widget, XtPointer ptr,
1618
+ XtPointer callData) {
1619
+ XPDFCore *core = (XPDFCore *)ptr;
1620
+
1621
+ core->dialogDone = 1;
1622
+ }
1623
+
1624
+ void XPDFCore::passwordCancelCbk(Widget widget, XtPointer ptr,
1625
+ XtPointer callData) {
1626
+ XPDFCore *core = (XPDFCore *)ptr;
1627
+
1628
+ core->dialogDone = -1;
1629
+ }
1630
+
1631
+ GString *XPDFCore::getPassword() {
1632
+ XtAppContext appContext;
1633
+ XEvent event;
1634
+
1635
+ // NB: set <password> before calling XmTextFieldSetString, because
1636
+ // SetString will trigger a call to passwordTextVerifyCbk, which
1637
+ // expects <password> to be valid
1638
+ password = new GString();
1639
+ XmTextFieldSetString(passwordText, "");
1640
+ XtManageChild(passwordDialog);
1641
+
1642
+ appContext = XtWidgetToApplicationContext(passwordDialog);
1643
+ dialogDone = 0;
1644
+ do {
1645
+ XtAppNextEvent(appContext, &event);
1646
+ XtDispatchEvent(&event);
1647
+ } while (!dialogDone);
1648
+ XtUnmanageChild(passwordDialog);
1649
+
1650
+ if (dialogDone < 0) {
1651
+ delete password;
1652
+ return NULL;
1653
+ }
1654
+ return password;
1655
+ }