rhodes 3.3.3.beta.4 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (497) hide show
  1. data/CHANGELOG +7 -5
  2. data/CREDITS +2215 -0
  3. data/Rakefile +225 -59
  4. data/bin/c2dm.rb +0 -0
  5. data/bin/get-rhodes-info.bat +0 -0
  6. data/bin/migrate-rhodes-app +0 -0
  7. data/bin/migrate-rhodes-app.bat +0 -0
  8. data/bin/rhodes +0 -0
  9. data/bin/rhodes-setup +0 -0
  10. data/bin/rhodes-setup.bat +0 -0
  11. data/bin/rhogen +0 -0
  12. data/bin/rhogen.bat +0 -0
  13. data/bin/set-rhodes-sdk +0 -0
  14. data/bin/set-rhodes-sdk.bat +0 -0
  15. data/bin/upgrade-rhodes-app +0 -0
  16. data/bin/upgrade-rhodes-app.bat +0 -0
  17. data/doc/build.txt +20 -9
  18. data/doc/configuration.txt +8 -8
  19. data/doc/connect-to-web-services.txt +1 -1
  20. data/doc/device-caps.txt +63 -26
  21. data/doc/extensions.txt +14 -2
  22. data/doc/install.txt +28 -19
  23. data/doc/introduction.txt +6 -3
  24. data/doc/jqt-jqm-transition.txt +10 -9
  25. data/doc/release.txt +5 -1
  26. data/doc/rhodes-command-line.txt +130 -0
  27. data/doc/rhom.txt +16 -11
  28. data/doc/rhostudio-eclipse.txt +3 -3
  29. data/doc/simulator.txt +28 -31
  30. data/doc/syncengine-ajax-api.txt +246 -0
  31. data/doc/synchronization.txt +21 -3
  32. data/doc/test-log-debug.txt +3 -1
  33. data/doc/ui.txt +16 -16
  34. data/ext/extconf.rb +8 -0
  35. data/lib/build/jake.rb +5 -5
  36. data/lib/extensions/barcode/ext/barcode/platform/android/Rakefile +9 -9
  37. data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/barcode.cpp +81 -1
  38. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/android/CaptureActivityHandler.java +6 -13
  39. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/android/DecodeHandler.java +2 -6
  40. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/rhomobile/barcode/Barcode.java +12 -1
  41. data/lib/extensions/barcode/ext/barcode/platform/bb/run.bat +0 -0
  42. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.h +2 -0
  43. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.mm +36 -0
  44. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.h +0 -0
  45. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.m +15 -5
  46. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/barcode.m +64 -1
  47. data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode.i +35 -1
  48. data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode_wrap.c +126 -2
  49. data/lib/extensions/barcode/ext/barcode/shared/src/zbar.c +18 -1
  50. data/lib/extensions/barcode/ext/build +0 -0
  51. data/lib/extensions/barcode/ext/build.bat +0 -0
  52. data/lib/extensions/digest-md5/ext/Rakefile +12 -10
  53. data/lib/extensions/digest-md5/ext/build +0 -0
  54. data/lib/extensions/digest-md5/ext/build.bat +0 -0
  55. data/lib/extensions/digest-md5/ext/digest-md5.sln +2 -2
  56. data/lib/extensions/digest-md5/ext/digest-md5.vcproj +41 -28
  57. data/lib/extensions/digest-sha1/ext/Rakefile +11 -10
  58. data/lib/extensions/digest-sha1/ext/build +0 -0
  59. data/lib/extensions/digest-sha1/ext/build.bat +0 -0
  60. data/lib/extensions/digest-sha1/ext/digest-sha1.sln +2 -2
  61. data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +41 -28
  62. data/lib/extensions/digest/ext/Rakefile +12 -11
  63. data/lib/extensions/digest/ext/build +0 -0
  64. data/lib/extensions/digest/ext/build.bat +0 -0
  65. data/lib/extensions/digest/ext/digest.sln +44 -0
  66. data/lib/extensions/digest/ext/digest.vcproj +40 -27
  67. data/lib/extensions/esri/ext/build +0 -0
  68. data/lib/extensions/esri/ext/build.bat +0 -0
  69. data/lib/extensions/fcntl/ext/Rakefile +10 -9
  70. data/lib/extensions/fcntl/ext/build +0 -0
  71. data/lib/extensions/fcntl/ext/build.bat +0 -0
  72. data/lib/extensions/fcntl/ext/fcntl.vcproj +1 -1
  73. data/lib/extensions/nfc/ext/build +0 -0
  74. data/lib/extensions/nfc/ext/build.bat +0 -0
  75. data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +11 -11
  76. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +0 -0
  77. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +12 -10
  78. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +16 -9
  79. data/lib/extensions/pdf-writer/color.rb +145 -0
  80. data/lib/extensions/pdf-writer/color/cmyk.rb +279 -0
  81. data/lib/extensions/pdf-writer/color/css.rb +28 -0
  82. data/lib/extensions/pdf-writer/color/grayscale.rb +212 -0
  83. data/lib/extensions/pdf-writer/color/hsl.rb +221 -0
  84. data/lib/extensions/pdf-writer/color/palette.rb +16 -0
  85. data/lib/extensions/pdf-writer/color/palette/adobecolor.rb +272 -0
  86. data/lib/extensions/pdf-writer/color/palette/gimp.rb +116 -0
  87. data/lib/extensions/pdf-writer/color/palette/monocontrast.rb +180 -0
  88. data/lib/extensions/pdf-writer/color/rgb-colors.rb +355 -0
  89. data/lib/extensions/pdf-writer/color/rgb.rb +453 -0
  90. data/lib/extensions/pdf-writer/color/rgb/metallic.rb +43 -0
  91. data/lib/extensions/pdf-writer/color/yiq.rb +84 -0
  92. data/lib/extensions/pdf-writer/ext/LICENSES/color/Licence.txt +27 -0
  93. data/lib/extensions/pdf-writer/ext/LICENSES/color/README.txt +32 -0
  94. data/lib/extensions/pdf-writer/ext/LICENSES/pdf-writer/LICENCE +131 -0
  95. data/lib/extensions/pdf-writer/ext/LICENSES/pdf-writer/README +33 -0
  96. data/lib/extensions/pdf-writer/ext/LICENSES/transaction-simple/Licence.txt +25 -0
  97. data/lib/extensions/pdf-writer/ext/LICENSES/transaction-simple/Readme.txt +204 -0
  98. data/lib/extensions/pdf-writer/pdf/charts.rb +13 -0
  99. data/lib/extensions/pdf-writer/pdf/charts/stddev.rb +430 -0
  100. data/lib/extensions/pdf-writer/pdf/math.rb +108 -0
  101. data/lib/extensions/pdf-writer/pdf/quickref.rb +332 -0
  102. data/lib/extensions/pdf-writer/pdf/simpletable.rb +947 -0
  103. data/lib/extensions/pdf-writer/pdf/techbook.rb +901 -0
  104. data/lib/extensions/pdf-writer/pdf/writer.rb +2729 -0
  105. data/lib/extensions/pdf-writer/pdf/writer/arc4.rb +63 -0
  106. data/lib/extensions/pdf-writer/pdf/writer/fontmetrics.rb +203 -0
  107. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-Bold.afm +342 -0
  108. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
  109. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-Oblique.afm +342 -0
  110. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier.afm +342 -0
  111. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
  112. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
  113. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
  114. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica.afm +3051 -0
  115. data/lib/extensions/pdf-writer/pdf/writer/fonts/MustRead.html +19 -0
  116. data/lib/extensions/pdf-writer/pdf/writer/fonts/Symbol.afm +213 -0
  117. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Bold.afm +2588 -0
  118. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
  119. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Italic.afm +2667 -0
  120. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Roman.afm +2419 -0
  121. data/lib/extensions/pdf-writer/pdf/writer/fonts/ZapfDingbats.afm +225 -0
  122. data/lib/extensions/pdf-writer/pdf/writer/graphics.rb +813 -0
  123. data/lib/extensions/pdf-writer/pdf/writer/graphics/imageinfo.rb +365 -0
  124. data/lib/extensions/pdf-writer/pdf/writer/lang.rb +43 -0
  125. data/lib/extensions/pdf-writer/pdf/writer/lang/en.rb +99 -0
  126. data/lib/extensions/pdf-writer/pdf/writer/object.rb +23 -0
  127. data/lib/extensions/pdf-writer/pdf/writer/object/action.rb +35 -0
  128. data/lib/extensions/pdf-writer/pdf/writer/object/annotation.rb +42 -0
  129. data/lib/extensions/pdf-writer/pdf/writer/object/catalog.rb +39 -0
  130. data/lib/extensions/pdf-writer/pdf/writer/object/contents.rb +65 -0
  131. data/lib/extensions/pdf-writer/pdf/writer/object/destination.rb +40 -0
  132. data/lib/extensions/pdf-writer/pdf/writer/object/encryption.rb +53 -0
  133. data/lib/extensions/pdf-writer/pdf/writer/object/font.rb +72 -0
  134. data/lib/extensions/pdf-writer/pdf/writer/object/fontdescriptor.rb +34 -0
  135. data/lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb +40 -0
  136. data/lib/extensions/pdf-writer/pdf/writer/object/image.rb +304 -0
  137. data/lib/extensions/pdf-writer/pdf/writer/object/info.rb +51 -0
  138. data/lib/extensions/pdf-writer/pdf/writer/object/outline.rb +30 -0
  139. data/lib/extensions/pdf-writer/pdf/writer/object/outlines.rb +30 -0
  140. data/lib/extensions/pdf-writer/pdf/writer/object/page.rb +195 -0
  141. data/lib/extensions/pdf-writer/pdf/writer/object/pages.rb +115 -0
  142. data/lib/extensions/pdf-writer/pdf/writer/object/procset.rb +46 -0
  143. data/lib/extensions/pdf-writer/pdf/writer/object/viewerpreferences.rb +74 -0
  144. data/lib/extensions/pdf-writer/pdf/writer/ohash.rb +58 -0
  145. data/lib/extensions/pdf-writer/pdf/writer/oreader.rb +25 -0
  146. data/lib/extensions/pdf-writer/pdf/writer/state.rb +48 -0
  147. data/lib/extensions/pdf-writer/pdf/writer/strokestyle.rb +138 -0
  148. data/lib/extensions/pdf-writer/transaction/simple.rb +486 -0
  149. data/lib/extensions/pdf-writer/transaction/simple/group.rb +146 -0
  150. data/lib/extensions/pdf-writer/transaction/simple/threadsafe.rb +68 -0
  151. data/lib/extensions/pdf-writer/transaction/simple/threadsafe/group.rb +36 -0
  152. data/lib/framework/builtinME.rb +0 -0
  153. data/lib/framework/dateOrig.rb +8 -2
  154. data/lib/framework/rational.rb +0 -0
  155. data/lib/framework/res/esri.wm.png +0 -0
  156. data/lib/framework/rho/rho.rb +6 -0
  157. data/lib/framework/rho/rhobluetooth.rb +0 -0
  158. data/lib/framework/rho/rhofsconnector.rb +0 -0
  159. data/lib/framework/rho/rhonativeviewmanager.rb +0 -0
  160. data/lib/framework/rhofsconnector.rb +0 -0
  161. data/lib/framework/rhom/rhom_object_factory.rb +8 -0
  162. data/lib/framework/rhomotoapi.rb +3 -2
  163. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +9 -1
  164. data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +1 -0
  165. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +26 -2
  166. data/platform/android/Rhodes/jni/src/callbacks.cpp +0 -5
  167. data/platform/android/Rhodes/jni/src/camera.cpp +1 -1
  168. data/platform/android/Rhodes/jni/src/fileapi.cpp +39 -19
  169. data/platform/android/Rhodes/jni/src/geolocation.cpp +3 -3
  170. data/platform/android/Rhodes/jni/src/mapview.cpp +206 -64
  171. data/platform/android/Rhodes/jni/src/nativeview.cpp +1 -1
  172. data/platform/android/Rhodes/jni/src/rhodes.cpp +13 -0
  173. data/platform/android/Rhodes/jni/src/rhodesapp.cpp +20 -0
  174. data/platform/android/Rhodes/jni/src/rhodessystem.cpp +36 -3
  175. data/platform/android/Rhodes/jni/src/signature.cpp +22 -2
  176. data/platform/android/Rhodes/res/drawable/alert_info.png +0 -0
  177. data/platform/android/Rhodes/res/drawable/esri.png +0 -0
  178. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +17 -16
  179. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Logger.java +4 -1
  180. data/platform/android/Rhodes/src/com/rhomobile/rhodes/MemoryInfoCollector.java +67 -0
  181. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +139 -114
  182. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +106 -13
  183. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +11 -3
  184. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +71 -16
  185. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraNewService.java +4 -1
  186. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraSemiService.java +4 -1
  187. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java +22 -1
  188. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/Config.java +243 -0
  189. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +19 -1
  190. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +9 -1
  191. data/platform/android/Rhodes/src/com/rhomobile/rhodes/{RhodesActivityListener.java → extmanager/IRhoListener.java} +16 -12
  192. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManager.java +63 -1
  193. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +239 -14
  194. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhodesStartupListeners.java +9 -0
  195. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/WebkitExtension.java +53 -0
  196. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +27 -12
  197. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +124 -62
  198. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +49 -137
  199. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +84 -114
  200. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +75 -82
  201. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +3 -2
  202. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Callout.java +4 -0
  203. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapBitmapManager.java +124 -0
  204. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +232 -43
  205. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Request.java +193 -0
  206. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/IRhoCustomView.java +13 -0
  207. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +32 -23
  208. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java +74 -0
  209. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality.java +6 -7
  210. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality01.java +37 -0
  211. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality03.java +14 -1
  212. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality05.java +51 -38
  213. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality07.java +9 -1
  214. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality08.java +48 -31
  215. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionalityManager.java +15 -16
  216. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +52 -15
  217. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +20 -2
  218. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +1 -0
  219. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +77 -34
  220. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/IRhoWebView.java +9 -0
  221. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebChromeClient.java +105 -0
  222. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +1 -1
  223. data/platform/android/build/RhodesSRC_build.files +8 -7
  224. data/platform/android/build/android.rake +326 -216
  225. data/platform/android/build/androidcommon.rb +27 -13
  226. data/platform/bb/RubyVM/src/com/rho/file/SimpleFile.java +27 -1
  227. data/platform/bb/RubyVM/src/j2me/io/File.java +104 -38
  228. data/platform/bb/build/bb.rake +1 -0
  229. data/platform/bb/build/runRAPC.bat +0 -0
  230. data/platform/bb/rhodes/resources/background.png +0 -0
  231. data/platform/bb/rhodes/resources/esri.png +0 -0
  232. data/platform/bb/rhodes/resources/mappin.png +0 -0
  233. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +5 -1
  234. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +2 -2
  235. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +0 -0
  236. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapProvider.java +0 -0
  237. data/platform/bb/rhodes/src/rhomobile/mapview/GeoCoding.java +0 -0
  238. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleGeoCoding.java +0 -0
  239. data/platform/bb/rhodes/src/rhomobile/mapview/MapTools.java +0 -0
  240. data/platform/iphone/Classes/AppManager/AppManager.m +7 -1
  241. data/platform/iphone/Classes/Camera/PickImageDelegate.h +9 -0
  242. data/platform/iphone/Classes/Camera/PickImageDelegate.m +75 -4
  243. data/platform/iphone/Classes/GeoLocation/LocationController.h +8 -2
  244. data/platform/iphone/Classes/GeoLocation/LocationController.m +74 -76
  245. data/platform/iphone/Classes/InitMemoryInfoCollector.h +33 -0
  246. data/platform/iphone/Classes/InitMemoryInfoCollector.mm +52 -0
  247. data/platform/iphone/Classes/NativeView/NVViewController.h +0 -0
  248. data/platform/iphone/Classes/NativeView/NVViewController.m +34 -2
  249. data/platform/iphone/Classes/Rhodes.m +22 -2
  250. data/platform/iphone/Classes/Signature/SignatureDelegate.m +19 -0
  251. data/platform/iphone/Classes/Signature/SignatureViewController.h +0 -0
  252. data/platform/iphone/Classes/Signature/SignatureViewController.m +0 -0
  253. data/platform/iphone/Classes/SimpleMainView.h +0 -0
  254. data/platform/iphone/Classes/SimpleMainView.m +3 -3
  255. data/platform/iphone/ESRI/BluePushpin.png +0 -0
  256. data/platform/iphone/ESRI/BluePushpin@2x.png +0 -0
  257. data/platform/iphone/ESRI/esri.png +0 -0
  258. data/platform/iphone/ESRI/esri@2x.png +0 -0
  259. data/platform/iphone/rbuild/iphone.rake +75 -7
  260. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +13 -4
  261. data/platform/linux/target/compiler/rubylinux +0 -0
  262. data/platform/mac/target/compiler/RubyMac +0 -0
  263. data/platform/osx/Rhodes Launcher/rhorunner.app/rhorunner b/data/platform/osx/Rhodes → Launcher/rhorunner.app/rhorunner +0 -0
  264. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore +0 -0
  265. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib +0 -0
  266. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui +0 -0
  267. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork +0 -0
  268. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtWebKit.framework/Versions/4/QtWebKit +0 -0
  269. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
  270. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
  271. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib +0 -0
  272. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib +0 -0
  273. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqgenericbearer.dylib +0 -0
  274. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqcncodecs.dylib +0 -0
  275. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqjpcodecs.dylib +0 -0
  276. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqkrcodecs.dylib +0 -0
  277. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqtwcodecs.dylib +0 -0
  278. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/graphicssystems/libqtracegraphicssystem.dylib +0 -0
  279. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqgif.dylib +0 -0
  280. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqico.dylib +0 -0
  281. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqjpeg.dylib +0 -0
  282. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqmng.dylib +0 -0
  283. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtga.dylib +0 -0
  284. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtiff.dylib +0 -0
  285. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_inspector.dylib +0 -0
  286. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_tcp.dylib +0 -0
  287. data/platform/osx/build/osx.rake +6 -8
  288. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +165 -33
  289. data/platform/shared/RhoConnectClient/RhoConnectClient.h +10 -1
  290. data/platform/shared/common/BundleManager.cpp +27 -16
  291. data/platform/shared/common/ExtManager.h +15 -2
  292. data/platform/shared/common/RhoConf.cpp +17 -2
  293. data/platform/shared/common/RhoConf.h +3 -1
  294. data/platform/shared/common/RhoDefs.h +6 -6
  295. data/platform/shared/common/RhoFatalError.h +1 -1
  296. data/platform/shared/common/RhoFile.cpp +9 -9
  297. data/platform/shared/common/RhoFilePath.h +7 -3
  298. data/platform/shared/common/RhoPort.h +3 -3
  299. data/platform/shared/common/RhoSystem.h +1 -1
  300. data/platform/shared/common/RhodesApp.cpp +426 -26
  301. data/platform/shared/common/RhodesApp.h +11 -3
  302. data/platform/shared/common/RhodesAppBase.cpp +4 -1
  303. data/platform/shared/common/StringConverter.h +3 -3
  304. data/platform/shared/common/app_build_capabilities.h +8 -0
  305. data/platform/shared/common/map/BaseMapEngine.cpp +302 -21
  306. data/platform/shared/common/map/BaseMapEngine.h +132 -6
  307. data/platform/shared/common/map/ESRIMapEngine.cpp +2 -1
  308. data/platform/shared/common/map/GeocodingMapEngine.cpp +22 -4
  309. data/platform/shared/common/map/GeocodingMapEngine.h +40 -0
  310. data/platform/shared/common/map/GoogleMapEngine.cpp +13 -1
  311. data/platform/shared/common/map/MapEngine.h +7 -0
  312. data/platform/shared/common/map/OSMMapEngine.cpp +12 -1
  313. data/platform/shared/json/JSONIterator.cpp +1 -1
  314. data/platform/shared/json/RJSONTokener.c +2 -0
  315. data/platform/shared/json/config.h +3 -3
  316. data/platform/shared/logging/RhoLog.cpp +12 -3
  317. data/platform/shared/logging/RhoLog.h +2 -1
  318. data/platform/shared/logging/RhoLogConf.cpp +147 -11
  319. data/platform/shared/logging/RhoLogConf.h +39 -1
  320. data/platform/shared/logging/RhoLogSink.cpp +1 -1
  321. data/platform/shared/net/HttpServer.cpp +8 -4
  322. data/platform/shared/net/INetRequest.cpp +7 -0
  323. data/platform/shared/net/INetRequest.h +2 -0
  324. data/platform/shared/net/RawSocket.cpp +1 -1
  325. data/platform/shared/qt/pbxproj2pro.pl +0 -0
  326. data/platform/shared/qt/pro_vcproj_diff.pl +0 -0
  327. data/platform/shared/qt/rhodes/QtMainWindow.cpp +1 -1
  328. data/platform/shared/qt/rhodes/impl/RhoClassFactoryImpl.h +2 -2
  329. data/platform/shared/qt/rhodes/impl/RhoThreadImpl.cpp +2 -2
  330. data/platform/shared/qt/rhodes/impl/SystemImpl.cpp +11 -1
  331. data/platform/shared/qt/rhodes/main.cpp +5 -5
  332. data/platform/shared/ruby/ext/alert/alert_wrap.c +8 -8
  333. data/platform/shared/ruby/ext/bluetooth/bluetooth.i +0 -0
  334. data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +16 -9
  335. data/platform/shared/ruby/ext/camera/camera.i +2 -2
  336. data/platform/shared/ruby/ext/camera/camera_wrap.c +18 -3
  337. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +37 -8
  338. data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +8 -8
  339. data/platform/shared/ruby/ext/mapview/mapview_wrap.c +16 -9
  340. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +16 -9
  341. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager.i +0 -0
  342. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +16 -9
  343. data/platform/shared/ruby/ext/phonebook/phonebook_wrap.c +8 -1
  344. data/platform/shared/ruby/ext/rho/rhoruby.c +7 -1
  345. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  346. data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +16 -9
  347. data/platform/shared/ruby/ext/signature/signature.i +0 -0
  348. data/platform/shared/ruby/ext/signature/signature_wrap.c +9 -9
  349. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +16 -9
  350. data/platform/shared/ruby/ext/system/system_wrap.c +16 -9
  351. data/platform/shared/ruby/ext/webview/webview_wrap.c +16 -9
  352. data/platform/shared/ruby/gc.c +1 -0
  353. data/platform/shared/ruby/regint.h +6 -4
  354. data/platform/shared/ruby/vm.c +1 -0
  355. data/platform/shared/ruby/wince/wince.h +1 -1
  356. data/platform/shared/rubyext/System.cpp +1 -1
  357. data/platform/shared/shttpd/src/rdispatcher.c +3 -3
  358. data/platform/shared/shttpd/src/std_includes.h +1 -1
  359. data/platform/shared/sqlite/sqlite3.c +1 -0
  360. data/platform/shared/statistic/test/TestProfiling.cpp +1 -1
  361. data/platform/shared/stlport/build/lib/configure +0 -0
  362. data/platform/shared/stlport/build/lib/configure.bat +0 -0
  363. data/platform/shared/sync/SyncEngine.cpp +9 -12
  364. data/platform/shared/sync/SyncNotify.cpp +36 -3
  365. data/platform/shared/sync/SyncNotify.h +11 -4
  366. data/platform/shared/sync/SyncSource.cpp +32 -16
  367. data/platform/shared/sync/SyncSource.h +2 -3
  368. data/platform/shared/sync/SyncThread.cpp +13 -4
  369. data/platform/shared/sync/SyncThread.h +4 -0
  370. data/platform/shared/tcmalloc/page_heap.h +1 -1
  371. data/platform/shared/tcmalloc/rhomem.h +1 -1
  372. data/platform/shared/tcmalloc/windows/port.cpp +12 -3
  373. data/platform/shared/test/Tests.cpp +4 -4
  374. data/platform/shared/test/test_helper.cpp +4 -4
  375. data/platform/symbian/sqlite3/src/sqlite3.h +1 -1
  376. data/platform/win32/RhoSimulator/Microsoft.VC90.CRT.manifest +6 -0
  377. data/platform/win32/RhoSimulator/Microsoft.VC90.OpenMP.manifest +6 -0
  378. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  379. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  380. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  381. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  382. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  383. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  384. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  385. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  386. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  387. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  388. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  389. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  390. data/platform/win32/RhoSimulator/msvcm90.dll +0 -0
  391. data/platform/win32/RhoSimulator/msvcp90.dll +0 -0
  392. data/platform/win32/RhoSimulator/msvcr90.dll +0 -0
  393. data/platform/win32/RhoSimulator/phonon4.dll +0 -0
  394. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  395. data/platform/win32/RhoSimulator/vcomp90.dll +0 -0
  396. data/platform/win32/target/replaceicon/replaceicon.exe +0 -0
  397. data/platform/win32/target/updateresstring/updateresstring.exe +0 -0
  398. data/platform/wm/RhoLib/RhoLib.vcproj +394 -69
  399. data/platform/wm/build/build_inf.js +83 -23
  400. data/platform/wm/build/wm.rake +127 -81
  401. data/platform/wm/rhodes.sln +6 -6
  402. data/platform/wm/rhodes/DateTimePicker.h +2 -2
  403. data/platform/wm/rhodes/IBrowserEngine.h +3 -0
  404. data/platform/wm/rhodes/IEBrowserEngine.cpp +34 -2
  405. data/platform/wm/rhodes/IEBrowserEngine.h +4 -1
  406. data/platform/wm/rhodes/LicenseStub.cpp +73 -0
  407. data/platform/{android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java → wm/rhodes/LogMemory.cpp} +32 -20
  408. data/platform/{android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettings.java → wm/rhodes/LogMemory.h} +11 -8
  409. data/platform/wm/rhodes/LogOptionsDlg.h +1 -1
  410. data/platform/wm/rhodes/LogView.cpp +10 -10
  411. data/platform/wm/rhodes/LogView.h +10 -10
  412. data/platform/wm/rhodes/MainWindow.cpp +431 -173
  413. data/platform/wm/rhodes/MainWindow.h +37 -19
  414. data/platform/wm/rhodes/MapView/MapViewManager.h +1 -1
  415. data/platform/wm/rhodes/OkCancelModalDialog.h +1 -1
  416. data/platform/wm/rhodes/Rhodes.cpp +210 -47
  417. data/platform/wm/rhodes/Rhodes.rc +38 -0
  418. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +2 -2
  419. data/platform/wm/rhodes/bluetooth/Bluetooth.h +3 -3
  420. data/platform/wm/rhodes/camera/Camera.cpp +2 -1
  421. data/platform/wm/rhodes/camera/Camera.h +1 -1
  422. data/platform/wm/rhodes/resource.h +1 -1
  423. data/platform/wm/rhodes/rho/common/ExtManager.cpp +93 -5
  424. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +2 -2
  425. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +2 -2
  426. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +13 -7
  427. data/platform/wm/rhodes/rhodes.vcproj +1409 -1008
  428. data/platform/wm/rhodes/simulator/MainWindowQt.h +1 -1
  429. data/platform/wm/rhodes/stdafx.h +2 -2
  430. data/platform/wm/rhoelements.sln +7 -9
  431. data/platform/wm/rubylib/rubylib.vcproj +62 -1
  432. data/platform/wm/sqlite3/sqlite3.vcproj +62 -1
  433. data/platform/wm/syncengine/syncengine.vcproj +62 -1
  434. data/platform/wm/tcmalloc/tcmalloc.vcproj +72 -53
  435. data/platform/wm/tools/detool/detool.cpp +1435 -1357
  436. data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +0 -0
  437. data/platform/wp7/RhoRubyLib/common/RhoLicense.cs +105 -0
  438. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +23 -5
  439. data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +5 -0
  440. data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +22 -3
  441. data/platform/wp7/build/wp.rake +1 -0
  442. data/platform/wp7/rhodes/MainPage.xaml.cs +11 -0
  443. data/rakefile.rb +225 -59
  444. data/res/build-tools/7za.exe +0 -0
  445. data/res/build-tools/RhoAppRunner.exe +0 -0
  446. data/res/build-tools/RhoLogServer.exe +0 -0
  447. data/res/build-tools/RhoRuby.exe +0 -0
  448. data/res/build-tools/RubyMac +0 -0
  449. data/res/build-tools/detool.exe +0 -0
  450. data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +1 -1
  451. data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
  452. data/res/build-tools/iphonesim/build/Release/iphonesim_43 +0 -0
  453. data/res/build-tools/license_rc.dll +0 -0
  454. data/res/build-tools/make.exe +0 -0
  455. data/res/build-tools/rubylinux +0 -0
  456. data/res/build-tools/swig_patch/Lib/typemaps/fragments.swg +235 -0
  457. data/res/build-tools/wmdc_connect.exe +0 -0
  458. data/res/build-tools/wp7explorer.exe +0 -0
  459. data/res/generators/rhogen.rb +2 -2
  460. data/res/generators/templates/application/app/Settings/controller.rb +1 -1
  461. data/res/generators/templates/application/app/layout.erb +1 -1
  462. data/res/generators/templates/application/app/loading.png +0 -0
  463. data/res/generators/templates/application/public/css/re_webkit.css +736 -0
  464. data/res/generators/templates/application/public/css/windows_mobile.css +0 -0
  465. data/res/generators/templates/application/public/images/listArrow.png +0 -0
  466. data/res/generators/templates/application/public/jqmobile/images/ajax-loader.png +0 -0
  467. data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
  468. data/res/generators/templates/application/public/jqmobile/images/icons-18-white.png +0 -0
  469. data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
  470. data/res/generators/templates/application/public/jqmobile/images/icons-36-white.png +0 -0
  471. data/res/generators/templates/application/public/js/syncengine.js +409 -52
  472. data/res/generators/templates/extension/extensions/montana/ext/build +0 -0
  473. data/res/generators/templates/extension/extensions/montana/ext/build.bat +0 -0
  474. data/res/generators/templates/extension/extensions/montana/ext/montana/platform/android/Rakefile +10 -10
  475. data/res/generators/templates/spec/app/SpecRunner/controller.rb +2 -0
  476. data/res/libs/motorolalicence/android/MotorolaLicence.h +13 -0
  477. data/res/libs/motorolalicence/android/libMotorolaLicence.a +0 -0
  478. data/res/libs/motorolalicence/iphone/MotorolaLicence.h +13 -0
  479. data/res/libs/motorolalicence/iphone/libMotorolaLicence.a +0 -0
  480. data/rhodes.gemspec +1 -1
  481. data/spec/framework_spec/app/SpecRunner/controller.rb +2 -0
  482. data/spec/phone_spec/app/SpecRunner/controller.rb +2 -0
  483. data/version +1 -1
  484. metadata +487 -412
  485. data/Manifest.txt +0 -7960
  486. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityStartupListeners.java +0 -12
  487. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +0 -52
  488. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsOld.java +0 -62
  489. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/phonon.framework/Versions/4/phonon +0 -0
  490. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/phonon_backend/libphonon_qt7.dylib +0 -0
  491. data/platform/win32/RhoSimulator/Microsoft.VC80.CRT.manifest +0 -8
  492. data/platform/win32/RhoSimulator/Microsoft.VC80.OpenMP.manifest +0 -7
  493. data/platform/win32/RhoSimulator/msvcm80.dll +0 -0
  494. data/platform/win32/RhoSimulator/msvcp80.dll +0 -0
  495. data/platform/win32/RhoSimulator/msvcr80.dll +0 -0
  496. data/platform/win32/RhoSimulator/vcomp.dll +0 -0
  497. data/rhomobile-debug-1.0.6.gem +0 -0
@@ -0,0 +1,332 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: quickref.rb 186 2007-12-10 22:58:48Z sandal $
10
+ #++
11
+ require 'pdf/simpletable'
12
+
13
+ # = QuickRef
14
+ # A formatting language to create a quick reference sheet. This is a
15
+ # multi-column page in landscape mode that generally has three or four
16
+ # columns. This format may also be used for brochures, but brochure
17
+ # creation requires a bit of management to create properly.
18
+ #
19
+ # == Reference Sheets
20
+ # A three-column reference sheet is generally in the form of:
21
+ #
22
+ # Page 1:
23
+ # column 1 | column 2 | column 3
24
+ # Page 2:
25
+ # column 4 | column 5 | column 6
26
+ #
27
+ # The formatting language provided in QuickRef is based around this text
28
+ # flow. The title of the quick reference sheet is in column 1. The two
29
+ # pages are intended to be printed on both sides of pieces of paper so
30
+ # that columns 1 and 6 are matched. This will use a Z-fold that places
31
+ # columns 5 and 6 face to face and columns 2 and 3 face to face. In the
32
+ # folded reference sheet, columns 1 and 4 will be facing out.
33
+ #
34
+ # == Brochures
35
+ # In contrast, brochures differ vastly in their design, although the
36
+ # common brochure is also three columns and either follows the same layout
37
+ # as a reference sheet or uses an overlapping fold.
38
+ #
39
+ # When an overlapping fold is used, the title is typically on column 6
40
+ # (assuming a left-to-right reading order). A short summary will appear on
41
+ # column 4. Contact information about the maker of the brochure is
42
+ # typically in column 5. Columns 1, 2, and 3 will contain the main body of
43
+ # the brochure. The brochure will be folded so that columns 2 and 3 are
44
+ # face to face. After this, column 1 will face column 4 (exposed by the
45
+ # first fold). In the folded brochure, columns 5 and 6 are facing out.
46
+ #
47
+ # == Usage
48
+ # qr = PDF::QuickRef.new # 3-column LETTER
49
+ # qr.title "My QuickRef"
50
+ # qr.h1 "H1 Text"
51
+ # qr.lines "Text to put after the header."
52
+ # qr.save_as "MyQuickRef.pdf"
53
+ class PDF::QuickRef
54
+
55
+ # Create the quick reference document. +paper+ is passed unchanged to
56
+ # the PDF::Writer.new; the page is always created landscape. Margins
57
+ # are initialized to 18 points. After some additional initialization is
58
+ # performed, the quick reference document is yielded to an optional
59
+ # block for further configuration. All of this is done before the
60
+ # columns are started.
61
+ #
62
+ # After the columns are started, lines will be drawn between column
63
+ # positions.
64
+ def initialize(paper = "LETTER", columns = 3, column_separators_visible = true)
65
+ @pdf = PDF::Writer.new(:paper => paper, :orientation => :landscape)
66
+ @pdf.margins_pt 18
67
+ @pdf.y = @pdf.absolute_top_margin
68
+
69
+ @title_font = "Times-Roman"
70
+ @heading_font = "Times-Roman"
71
+ @body_font = "Times-Roman"
72
+ @code_font = "Courier"
73
+ @title_font_size = 14
74
+ @h1_font_size = 11
75
+ @h2_font_size = 9
76
+ @h3_font_size = 8
77
+ @h4_font_size = 7
78
+ @body_font_size = 6
79
+
80
+ @ptab = PDF::SimpleTable.new do |tab|
81
+ tab.column_order.replace %w(one two)
82
+
83
+ tab.font_size = @body_font_size
84
+ tab.show_lines = :none
85
+ tab.show_headings = false
86
+ tab.orientation = :center
87
+ tab.position = :center
88
+ end
89
+ @ltab = PDF::SimpleTable.new do |tab|
90
+ tab.column_order.replace %w(line)
91
+
92
+ tab.font_size = @body_font_size
93
+ tab.show_lines = :none
94
+ tab.show_headings = false
95
+ tab.orientation = :center
96
+ tab.position = :center
97
+ end
98
+
99
+ yield self if block_given?
100
+
101
+ @pdf.start_columns columns
102
+
103
+ @ptab.font_size = @body_font_size
104
+ @ltab.font_size = @body_font_size
105
+
106
+ @ptab.maximum_width = @pdf.column_width - 10
107
+ @ltab.maximum_width = @pdf.column_width - 10
108
+
109
+ if column_separators_visible
110
+ # Put lines between the columns.
111
+ all = @pdf.open_object
112
+ @pdf.save_state
113
+ @pdf.stroke_color! Color::RGB::Black
114
+ @pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
115
+ (1 .. (columns - 1)).each do |ii|
116
+ x = @pdf.left_margin + (@pdf.column_width * ii)
117
+ x += (@pdf.column_gutter * (ii - 0.5))
118
+ @pdf.line(x, @pdf.page_height - @pdf.top_margin, x, @pdf.bottom_margin)
119
+ @pdf.stroke
120
+ end
121
+ @pdf.restore_state
122
+ @pdf.close_object
123
+ @pdf.add_object(all, :all_pages)
124
+ end
125
+ end
126
+
127
+ # Access to the raw PDF canvas for normal PDF::Writer configuration.
128
+ attr_reader :pdf
129
+
130
+ # The name of the font that will be used for #title text. The default
131
+ # font is Times-Roman.
132
+ attr_accessor :title_font
133
+ # The font encoding for #title text.
134
+ attr_accessor :title_font_encoding
135
+ # The size #title text. The default is 14 points.
136
+ attr_accessor :title_font_size
137
+
138
+ # The name of the font that will be used for #h1, #h2, #h3, and #h4
139
+ # text. The default is Times-Roman.
140
+ attr_accessor :heading_font
141
+ # The font encoding for #h1, #h2, #h3, and #h4 text.
142
+ attr_accessor :heading_font_encoding
143
+ # The size #h1 text. The default is 11 points.
144
+ attr_accessor :h1_font_size
145
+ # The size #h2 text. The default is 9 points.
146
+ attr_accessor :h2_font_size
147
+ # The size #h3 text. The default is 8 points.
148
+ attr_accessor :h3_font_size
149
+ # The size #h4 text. The default is 7 points.
150
+ attr_accessor :h4_font_size
151
+
152
+ # The name of the font that will be used for #body, #lines, and #pairs
153
+ # text. The default is 'Times-Roman'.
154
+ attr_accessor :body_font
155
+ # The font encoding for #body, #lines, and #pairs text.
156
+ attr_accessor :body_font_encoding
157
+ # The name of the font that will be used for #code, #codelines, and
158
+ # #codepairs text; this is generally a fixed-pitch font. The default is
159
+ # 'Courier'.
160
+ attr_accessor :code_font
161
+ # The font encoding for #code, #codelines, and #codepairs text.
162
+ attr_accessor :code_font_encoding
163
+ # The size #body and #code text. The default is 7 points.
164
+ attr_accessor :body_font_size
165
+
166
+ # Creates a two-column zebra-striped table using the #body font. Each
167
+ # line of the text is a separate row; the two columns are separated by
168
+ # tab characters.
169
+ def pairs(text)
170
+ data = text.split($/).map do |line|
171
+ one, two = line.split(/\t/)
172
+ { 'one' => one, 'two' => two }
173
+ end
174
+ @ptab.data.replace data
175
+ @ptab.render_on(@pdf)
176
+ @pdf.text "\n", :font_size => @body_font_size
177
+ end
178
+ # Creates a two-column zebra-striped table using the #code font. Each
179
+ # line of the text is a separate row; the two columns are separated by
180
+ # tab characters.
181
+ def codepairs(text)
182
+ data = text.split($/).map do |line|
183
+ one, two = line.split(/\t/)
184
+ { 'one' => one, 'two' => two }
185
+ end
186
+ @ptab.data.replace data
187
+ use_code_font
188
+ @ptab.render_on(@pdf)
189
+ use_body_font
190
+ @pdf.text "\n", :font_size => @body_font_size
191
+ end
192
+ # Creates a one-column zebra-striped table using the #body font. Each
193
+ # line of the text is a separate row.
194
+ def lines(text)
195
+ data = text.split($/).map { |line| { "line" => line } }
196
+ @ltab.data.replace data
197
+ @ltab.render_on(@pdf)
198
+ @pdf.text "\n", :font_size => @body_font_size
199
+ end
200
+ # Creates a one-column zebra-striped table using the #code font. Each
201
+ # line of the text is a separate row.
202
+ def codelines(text)
203
+ data = text.split($/).map { |line| { "line" => line } }
204
+ @ltab.data.replace data
205
+ use_code_font
206
+ @ltab.render_on(@pdf)
207
+ use_body_font
208
+ @pdf.text "\n", :font_size => @body_font_size
209
+ end
210
+
211
+ # Change the current font to the #title font.
212
+ def use_title_font
213
+ @pdf.select_font @title_font, @title_font_encoding
214
+ end
215
+ # Change the current font to the heading font (used normally by #h1,
216
+ # #h2, #h3, and #h4|).
217
+ def use_heading_font
218
+ @pdf.select_font @heading_font, @heading_font_encoding
219
+ end
220
+ # Change the current font to the #body font.
221
+ def use_body_font
222
+ @pdf.select_font @body_font, @body_font_encoding
223
+ end
224
+ # Change the current font to the #code font.
225
+ def use_code_font
226
+ @pdf.select_font @code_font, @code_font_encoding
227
+ end
228
+
229
+ # Writes the +text+ with the #title_font and #title_font_size centered
230
+ # in the column. After the title has been written, an #hline will be
231
+ # drawn under the title. The font is set to #body_font after the title
232
+ # is drawn.
233
+ def title(text)
234
+ use_title_font
235
+ @pdf.text text, :font_size => @title_font_size, :justification => :center
236
+ use_body_font
237
+ hline
238
+ end
239
+ # Writes the +text+ with the #heading_font and #h1_font_size left
240
+ # justified in the column. The font is set to #body_font after the
241
+ # heading is drawn.
242
+ def h1(text)
243
+ use_heading_font
244
+ @pdf.text text, :font_size => @h1_font_size
245
+ use_body_font
246
+ end
247
+ # Writes the +text+ with the #heading_font and #h2_font_size left
248
+ # justified in the column. The font is set to #body_font after the
249
+ # heading is drawn.
250
+ def h2(text)
251
+ use_heading_font
252
+ @pdf.text "<i>#{text}</i>", :font_size => @h2_font_size
253
+ use_body_font
254
+ end
255
+ # Writes the +text+ with the #heading_font and #h3_font_size left
256
+ # justified in the column. The font is set to #body_font after the
257
+ # heading is drawn.
258
+ def h3(text)
259
+ use_heading_font
260
+ @pdf.text "<i>#{text}</i>", :font_size => @h3_font_size
261
+ use_body_font
262
+ end
263
+ # Writes the +text+ with the #heading_font and #h4_font_size left
264
+ # justified in the column. The font is set to #body_font after the
265
+ # heading is drawn.
266
+ def h4(text)
267
+ use_heading_font
268
+ @pdf.text "<b><i>#{text}</i></b>", :font_size => @h4_font_size
269
+ use_body_font
270
+ end
271
+ # Writes body text. Paragraphs will be reflowed for optimal placement of
272
+ # text. Text separated by two line separators (e.g., \n\n, although the
273
+ # separator is platform dependent). The text will be placed with full
274
+ # justification.
275
+ def body(text)
276
+ # Transform the text a little.
277
+ paras = text.split(%r(#{$/}{2}))
278
+ paras.map! { |para| para.split($/).join(" ").squeeze(" ") }
279
+ text = paras.join("\n\n")
280
+
281
+ @pdf.text "#{text}\n", :font_size => @body_font_size, :justification => :full
282
+ end
283
+ # Writes code text. Newlines and spaces will be preserved.
284
+ def pre(text)
285
+ use_code_font
286
+ @pdf.text "#{text}\n", :font_size => @body_font_size
287
+ use_body_font
288
+ end
289
+
290
+ # Draws a horizontal line with the specified style and colour.
291
+ def hline(style = PDF::Writer::StrokeStyle::DEFAULT,
292
+ color = Color::RGB::Black)
293
+ @pdf.y -= 2.5
294
+ @pdf.save_state
295
+ @pdf.stroke_style style
296
+ @pdf.stroke_color! color
297
+ x0 = @pdf.left_margin
298
+ x1 = @pdf.left_margin + pdf.column_width
299
+ @pdf.line(x0, @pdf.y, x1, @pdf.y)
300
+ @pdf.stroke
301
+ @pdf.restore_state
302
+ @pdf.y -= 2.5
303
+ end
304
+
305
+ # Writes the Quick Reference to disk.
306
+ def save_as(filename)
307
+ @pdf.save_as(filename)
308
+ end
309
+
310
+ # Generates the PDF document as a string.
311
+ def render
312
+ @pdf.render
313
+ end
314
+
315
+ alias to_s render
316
+
317
+ # Creates a QuickRef document and then calls #instance_eval on the
318
+ # document. This allows for a more natural use of the QuickRef class as
319
+ # a DSL for creating these documents.
320
+ #
321
+ # === Using #make
322
+ # PDF::QuickRef.make do # 3-column LETTER
323
+ # title "My QuickRef"
324
+ # h1 "H1 Text"
325
+ # lines "Text to put after the header."
326
+ # save_as "MyQuickRef.pdf"
327
+ # end
328
+ def self.make(*args, &block)
329
+ qr = PDF::QuickRef.new(*args)
330
+ qr.__send__(:instance_eval, &block)
331
+ end
332
+ end
@@ -0,0 +1,947 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: simpletable.rb 186 2007-12-10 22:58:48Z sandal $
10
+ #++
11
+ require 'pdf/writer'
12
+ require 'transaction/simple/group'
13
+
14
+ # This class will create tables with a relatively simple API and internal
15
+ # implementation.
16
+ class PDF::SimpleTable
17
+
18
+ include Transaction::Simple
19
+
20
+ # Defines formatting options for a column.
21
+ class Column
22
+ def initialize(name)
23
+ @name = name
24
+
25
+ yield self if block_given?
26
+ end
27
+
28
+ # The heading of the column. This should be an instance of
29
+ # PDF::SimpleTable::Column::Heading. If it is not, it will be
30
+ # converted into one.
31
+ attr_accessor :heading
32
+ def heading=(hh) #:nodoc:
33
+ unless hh.kind_of?(Heading)
34
+ hh = Heading.new(hh)
35
+ end
36
+ @heading = hh
37
+ end
38
+ # The name of the column.
39
+ attr_reader :name
40
+ # The width of the column. If this value is set, the column will be
41
+ # exactly this number of units wide.
42
+ attr_accessor :width
43
+ # The data name that will be used to provide a hyperlink for values in
44
+ # this column.
45
+ attr_accessor :link_name
46
+ # The justification of the column. May be :left, :right, :center, or
47
+ # :full.
48
+ attr_accessor :justification
49
+
50
+ # Formatting options for heading rows. Each column can have a separate
51
+ # heading value.
52
+ class Heading
53
+ def initialize(title = nil)
54
+ @title = title
55
+ yield self if block_given?
56
+ end
57
+
58
+ # Indicates that the heading should be rendered bold.
59
+ attr_accessor :bold
60
+ # The justification of the heading of the column. May be :left,
61
+ # :center, :right, or :full.
62
+ attr_accessor :justification
63
+ # The title of the heading. If nothing is present, the name of the
64
+ # column will be used when headings are displayed.
65
+ attr_accessor :title
66
+ end
67
+ end
68
+
69
+ def initialize
70
+ @column_order = []
71
+ @data = []
72
+ @columns = {}
73
+
74
+ @show_lines = :outer
75
+ @show_headings = true
76
+ @shade_rows = :shaded
77
+ @shade_color = Color::RGB::Grey80
78
+ @shade_color2 = Color::RGB::Grey70
79
+ @shade_headings = false
80
+ @shade_heading_color = Color::RGB::Grey90
81
+ @font_size = 10
82
+ @heading_font_size = 12
83
+ @title_font_size = 12
84
+ @title_gap = 5
85
+ @title_color = Color::RGB::Black
86
+ @heading_color = Color::RGB::Black
87
+ @text_color = Color::RGB::Black
88
+ @line_color = Color::RGB::Black
89
+ @position = :center
90
+ @orientation = :center
91
+ @bold_headings = false
92
+
93
+ @cols = PDF::Writer::OHash.new
94
+ @width = 0
95
+ @maximum_width = 0
96
+
97
+ @gap = 5
98
+ @row_gap = 2
99
+ @column_gap = 5
100
+ @header_gap = 0
101
+
102
+ @minimum_space = 0
103
+ @protect_rows = 1
104
+ @split_rows = false
105
+
106
+ @inner_line_style = PDF::Writer::StrokeStyle.new(1)
107
+ @outer_line_style = PDF::Writer::StrokeStyle.new(1)
108
+
109
+ yield self if block_given?
110
+ end
111
+
112
+ # An array of Hash entries. Each row is a Hash where the keys are the
113
+ # names of the columns as specified in #column_order and the values are
114
+ # the values of the cell.
115
+ attr_accessor :data
116
+ # An array that defines the order of the columns in the table. The
117
+ # values in this array are the column names in #data. The columns will
118
+ # be presented in the order defined here.
119
+ attr_accessor :column_order
120
+ # An array that defines columns and column options for the table. The
121
+ # entries should be PDF::SimpleTable::Column objects.
122
+ attr_accessor :columns
123
+
124
+ # The title to be put on the top of the table.
125
+ attr_accessor :title
126
+
127
+ # Whether to display the lines on the table or not. Valid values are:
128
+ #
129
+ # <tt>:none</tt>:: Displays no lines.
130
+ # <tt>:outer</tt>:: Displays outer lines only. *Default*
131
+ # <tt>:inner</tt>:: Displays inner lines only.
132
+ # <tt>:all</tt>:: Displays all lines, inner and outer.
133
+ attr_accessor :show_lines
134
+ # Displays the headings for the table if +true+. The default is +true+.
135
+ attr_accessor :show_headings
136
+ # Controls row shading.
137
+ #
138
+ # <tt>:none</tt>:: No row shading; all rows are the standard
139
+ # background colour.
140
+ # <tt>:shaded</tt>:: Alternate lines will be shaded; half of the rows
141
+ # will be the standard background colour; the rest
142
+ # of the rows will be shaded with #shade_color.
143
+ # *Default*
144
+ # <tt>:striped</tt>:: Alternate lines will be shaded; half of the rows
145
+ # will be shaded with #shade_color; the rest of the
146
+ # rows will be shaded with #shade_color2.
147
+ attr_accessor :shade_rows
148
+ # The main row shading colour. Defaults to Color::RGB::Grey80. Used with
149
+ # #shade_rows of <tt>:shaded</tt> and <tt>:striped</tt>.
150
+ attr_accessor :shade_color
151
+ # The alternate row shading colour, used with #shade_rows of
152
+ # <tt>:striped</tt>. Defaults to Color::RGB::Grey70.
153
+ attr_accessor :shade_color2
154
+ # Places a background colour in the heading if +true+.
155
+ attr_accessor :shade_headings
156
+ # Defines the colour of the background shading for the heading if
157
+ # #shade_headings is +true+. Default is Color::RGB::Grey90.
158
+ attr_accessor :shade_heading_color
159
+ # The font size of the data cells, in points. Defaults to 10 points.
160
+ attr_accessor :font_size
161
+ # The font size of the heading cells, in points. Defaults to 12 points.
162
+ attr_accessor :heading_font_size
163
+ # The font size of the title, in points. Defaults to 12 points.
164
+ attr_accessor :title_font_size
165
+ # The gap, in PDF units, between the title and the table. Defaults to 5
166
+ # units.
167
+ attr_accessor :title_gap
168
+ # The text colour of the title. Defaults to Color::RGB::Black.
169
+ attr_accessor :title_color
170
+ # The text colour of the heading. Defaults to Color::RGB::Black.
171
+ attr_accessor :heading_color
172
+ # The text colour of the body cells. Defaults to Color::RGB::Black.
173
+ attr_accessor :text_color
174
+ # The colour of the table lines. Defaults to Color::RGB::Black.
175
+ attr_accessor :line_color
176
+ # The +x+ position of the table. This will be one of:
177
+ #
178
+ # <tt>:left</tt>:: Aligned with the left margin.
179
+ # <tt>:right</tt>:: Aligned with the right margin.
180
+ # <tt>:center</tt>:: Centered between the margins. *Default*.
181
+ # <em>offset</em>:: The absolute position of the table, relative from
182
+ # the left margin.
183
+ attr_accessor :position
184
+ # The orientation of the table relative to #position.
185
+ #
186
+ # <tt>:left</tt>:: The table is to the left of #position.
187
+ # <tt>:right</tt>:: The table is to the right of #position.
188
+ # <tt>:center</tt>:: The table is centred at #position.
189
+ # <em>offset</em>:: The left of the table is offset from #position.
190
+ attr_accessor :orientation
191
+ # Makes the heading text bold if +true+. Defaults to +false+.
192
+ attr_accessor :bold_headings
193
+ # Specifies the width of the table. If the table is smaller than the
194
+ # provided width, columns are proportionally stretched to fit the width
195
+ # of the table. If the table is wider than the provided width, columns
196
+ # are proportionally shrunk to fit the width of the table. Content may
197
+ # need to wrap in this case.
198
+ #
199
+ # Defaults to zero, which indicates that the size whould be determined
200
+ # automatically based on the content and the margins.
201
+ attr_accessor :width
202
+ # Specifies the maximum width of the table. The table will not grow
203
+ # larger than this width under any circumstances.
204
+ #
205
+ # Defaults to zero, which indicates that there is no maximum width
206
+ # (aside from the margin size).
207
+ attr_accessor :maximum_width
208
+ # The space, in PDF user units, added to the top and bottom of each row
209
+ # between the text and the lines of the cell. Default 2 units.
210
+ attr_accessor :row_gap
211
+ # The space, in PDF user units, on the left and right sides of each
212
+ # cell. Default 5 units.
213
+ attr_accessor :column_gap
214
+
215
+ # The minimum space between the bottom of each row and the bottom
216
+ # margin. If the amount of space is less than this, a new page will be
217
+ # started. Default is 100 PDF user units.
218
+ attr_accessor :minimum_space
219
+ # The number of rows to hold with the heading on the page. If there are
220
+ # less than this number of rows on the page, then move the whole lot
221
+ # onto the next page. Default is one row.
222
+ attr_accessor :protect_rows
223
+ # Allows a table's rows to be split across page boundaries if +true+.
224
+ # This defaults to +false+.
225
+ attr_accessor :split_rows
226
+ # The number of PDF user units to leave open at the top of a page after
227
+ # a page break. This is typically used for a repeating page header, etc.
228
+ # Defaults to zero units.
229
+ attr_accessor :header_gap
230
+ # Defines the inner line style. The default style is a solid line with a
231
+ # thickness of 1 unit.
232
+ attr_accessor :inner_line_style
233
+ # Defines the outer line style. The default style is a solid line with a
234
+ # thickness of 1 unit.
235
+ attr_accessor :outer_line_style
236
+
237
+ # Render the table on the PDF::Writer document provided.
238
+ def render_on(pdf)
239
+ if @column_order.empty?
240
+ raise TypeError, PDF::Writer::Lang[:simpletable_columns_undefined]
241
+ end
242
+ if @data.empty?
243
+ raise TypeError, PDF::Writer::Lang[:simpletable_data_empty]
244
+ end
245
+
246
+ low_y = descender = y0 = y1 = y = nil
247
+
248
+ @cols = PDF::Writer::OHash.new
249
+ @column_order.each do |name|
250
+ col = @columns[name]
251
+ if col
252
+ @cols[name] = col
253
+ else
254
+ @cols[name] = PDF::SimpleTable::Column.new(name)
255
+ end
256
+ end
257
+
258
+ @gap = 2 * @column_gap
259
+
260
+ max_width = __find_table_max_width__(pdf)
261
+ pos, t, x, adjustment_width, set_width = __find_table_positions__(pdf, max_width)
262
+
263
+ # if max_width is specified, and the table is too wide, and the width
264
+ # has not been set, then set the width.
265
+ if @width.zero? and @maximum_width.nonzero? and ((t - x) > @maximum_width)
266
+ @width = @maximum_width
267
+ end
268
+
269
+ if @width and (adjustment_width > 0) and (set_width < @width)
270
+ # First find the current widths of the columns involved in this
271
+ # mystery
272
+ cols0 = PDF::Writer::OHash.new
273
+ cols1 = PDF::Writer::OHash.new
274
+
275
+ xq = presentWidth = 0
276
+ last = nil
277
+
278
+ pos.each do |name, colpos|
279
+ if @cols[last].nil? or
280
+ @cols[last].width.nil? or
281
+ @cols[last].width <= 0
282
+ unless last.nil? or last.empty?
283
+ cols0[last] = colpos - xq - @gap
284
+ presentWidth += (colpos - xq - @gap)
285
+ end
286
+ else
287
+ cols1[last] = colpos - xq
288
+ end
289
+ last = name
290
+ xq = colpos
291
+ end
292
+
293
+ # cols0 contains the widths of all the columns which are not set
294
+ needed_width = @width - set_width
295
+
296
+ # If needed width is negative then add it equally to each column,
297
+ # else get more tricky.
298
+ if presentWidth < needed_width
299
+ diff = (needed_width - presentWidth) / cols0.size.to_f
300
+ cols0.each_key { |name| cols0[name] += diff }
301
+ else
302
+ cnt = 0
303
+ loop do
304
+ break if (presentWidth <= needed_width) or (cnt >= 100)
305
+ cnt += 1 # insurance policy
306
+ # Find the widest columns and the next to widest width
307
+ aWidest = []
308
+ nWidest = widest = 0
309
+ cols0.each do |name, w|
310
+ if w > widest
311
+ aWidest = [ name ]
312
+ nWidest = widest
313
+ widest = w
314
+ elsif w == widest
315
+ aWidest << name
316
+ end
317
+ end
318
+
319
+ # Then figure out what the width of the widest columns would
320
+ # have to be to take up all the slack.
321
+ newWidestWidth = widest - (presentWidth - needed_width) / aWidest.size.to_f
322
+ if newWidestWidth > nWidest
323
+ aWidest.each { |name| cols0[name] = newWidestWidth }
324
+ presentWidth = needed_width
325
+ else
326
+ # There is no space, reduce the size of the widest ones down
327
+ # to the next size down, and we will go round again
328
+ aWidest.each { |name| cols0[name] = nWidest }
329
+ presentWidth -= (widest - nWidest) * aWidest.size
330
+ end
331
+ end
332
+ end
333
+
334
+ # cols0 now contains the new widths of the constrained columns. now
335
+ # need to update the pos and max_width arrays
336
+ xq = 0
337
+ pos.each do |name, colpos|
338
+ pos[name] = xq
339
+
340
+ if @cols[name].nil? or
341
+ @cols[name].width.nil? or
342
+ @cols[name].width <= 0
343
+ if not cols0[name].nil?
344
+ xq += cols0[name] + @gap
345
+ max_width[name] = cols0[name]
346
+ end
347
+ else
348
+ xq += cols1[name] unless cols1[name].nil?
349
+ end
350
+ end
351
+
352
+ t = x + @width
353
+ pos[:__last_column__] = t
354
+ end
355
+
356
+ # now adjust the table to the correct location across the page
357
+ case @position
358
+ when :left
359
+ xref = pdf.absolute_left_margin
360
+ when :right
361
+ xref = pdf.absolute_right_margin
362
+ when :center
363
+ xref = pdf.margin_x_middle
364
+ else
365
+ xref = @position
366
+ end
367
+
368
+ case @orientation
369
+ when :left
370
+ dx = xref - t
371
+ when :right
372
+ dx = xref
373
+ when :center
374
+ dx = xref - (t / 2.0)
375
+ else
376
+ dx = xref + @orientation
377
+ end
378
+
379
+ pos.each { |k, v| pos[k] = v + dx }
380
+
381
+ base_x0 = x0 = x + dx
382
+ base_x1 = x1 = t + dx
383
+
384
+ base_left_margin = pdf.absolute_left_margin
385
+ base_pos = pos.dup
386
+
387
+ # Ok, just about ready to make me a table.
388
+ pdf.fill_color @text_color
389
+ pdf.stroke_color @shade_color
390
+
391
+ middle = (x0 + x1) / 2.0
392
+
393
+ # Start a transaction. This transaction will be used to regress the
394
+ # table if there are not enough rows protected.
395
+ tg = Transaction::Simple::Group.new(pdf, self)
396
+ tg.start_transaction(:table)
397
+ moved_once = false if @protect_rows.nonzero?
398
+
399
+ abortTable = true
400
+ loop do # while abortTable
401
+ break unless abortTable
402
+ abortTable = false
403
+
404
+ dm = pdf.absolute_left_margin - base_left_margin
405
+ base_pos.each { |k, v| pos[k] = v + dm }
406
+ x0 = base_x0 + dm
407
+ x1 = base_x1 + dm
408
+ middle = (x0 + x1) / 2.0
409
+
410
+ # If the title is set, then render it.
411
+ unless @title.nil? or @title.empty?
412
+ w = pdf.text_width(@title, @title_font_size)
413
+ _y = pdf.y - pdf.font_height(@title_font_size)
414
+ if _y < pdf.absolute_bottom_margin
415
+ pdf.start_new_page
416
+
417
+ # margins may have changed on the new page
418
+ dm = pdf.absolute_left_margin - base_left_margin
419
+ base_pos.each { |k, v| pos[k] = v + dm }
420
+ x0 = base_x0 + dm
421
+ x1 = base_x1 + dm
422
+ middle = (x0 + x1) / 2.0
423
+ end
424
+
425
+ pdf.y -= pdf.font_height(@title_font_size)
426
+ pdf.fill_color @title_color
427
+ pdf.add_text(middle - w / 2.0, pdf.y, title, @title_font_size)
428
+ pdf.y -= @title_gap
429
+ end
430
+
431
+ # Margins may have changed on the new_page.
432
+ dm = pdf.absolute_left_margin - base_left_margin
433
+ base_pos.each { |k, v| pos[k] = v + dm }
434
+ x0 = base_x0 + dm
435
+ x1 = base_x1 + dm
436
+ middle = (x0 + x1) / 2.0
437
+
438
+ y = pdf.y # simplifies the code a bit
439
+ low_y = y if low_y.nil? or y < low_y
440
+
441
+ # Make the table
442
+ height = pdf.font_height @font_size
443
+ descender = pdf.font_descender @font_size
444
+
445
+ y0 = y + descender
446
+ dy = 0
447
+
448
+ if @show_headings
449
+ # This function will move the start of the table to a new page if
450
+ # it does not fit on this one.
451
+ hOID = __open_new_object__(pdf) if @shade_headings
452
+ pdf.fill_color @heading_color
453
+ _height, y = __table_column_headings__(pdf, pos, max_width, height,
454
+ descender, @row_gap, @heading_font_size, y)
455
+ pdf.fill_color @text_color
456
+ y0 = y + _height
457
+ y1 = y
458
+
459
+ if @shade_headings
460
+ pdf.close_object
461
+ pdf.fill_color! @shade_heading_color
462
+ pdf.rectangle(x0 - @gap / 2.0, y, x1 - x0, _height).fill
463
+ pdf.reopen_object(hOID)
464
+ pdf.close_object
465
+ pdf.restore_state
466
+ end
467
+
468
+ # Margins may have changed on the new_page
469
+ dm = pdf.absolute_left_margin - base_left_margin
470
+ base_pos.each { |k, v| pos[k] = v + dm }
471
+ x0 = base_x0 + dm
472
+ x1 = base_x1 + dm
473
+ middle = (x0 + x1) / 2.0
474
+ else
475
+ y1 = y0
476
+ end
477
+
478
+ first_line = true
479
+
480
+ # open an object here so that the text can be put in over the
481
+ # shading
482
+ tOID = __open_new_object__(pdf) unless :none == @shade_rows
483
+
484
+ cnt = 0
485
+ cnt = 1 unless @shade_headings
486
+ newPage = false
487
+ @data.each do |row|
488
+ cnt += 1
489
+ # Start a transaction that will be used for this row to prevent it
490
+ # from being split.
491
+ unless @split_rows
492
+ pageStart = pdf.pageset.size
493
+
494
+ columnStart = pdf.column_number if pdf.columns?
495
+
496
+ tg.start_transaction(:row)
497
+ row_orig = row
498
+ y_orig = y
499
+ y0_orig = y0
500
+ y1_orig = y1
501
+ end # unless @split_rows
502
+
503
+ ok = false
504
+ second_turn = false
505
+ loop do # while !abortTable and !ok
506
+ break if abortTable or ok
507
+
508
+ mx = 0
509
+ newRow = true
510
+
511
+ loop do # while !abortTable and (newPage or newRow)
512
+ break if abortTable or not (newPage or newRow)
513
+
514
+ y -= height
515
+ low_y = y if low_y.nil? or y < low_y
516
+
517
+ if newPage or y < (pdf.absolute_bottom_margin + @minimum_space)
518
+ # check that enough rows are with the heading
519
+ moved_once = abortTable = true if @protect_rows.nonzero? and not moved_once and cnt <= @protect_rows
520
+
521
+ y2 = y - mx + (2 * height) + descender - (newRow ? 1 : 0) * height
522
+
523
+ unless :none == @show_lines
524
+ y0 = y1 unless @show_headings
525
+
526
+ __table_draw_lines__(pdf, pos, @gap, x0, x1, y0, y1, y2,
527
+ @line_color, @inner_line_style, @outer_line_style,
528
+ @show_lines)
529
+ end
530
+
531
+ unless :none == @shade_rows
532
+ pdf.close_object
533
+ pdf.restore_state
534
+ end
535
+
536
+ pdf.start_new_page
537
+ pdf.save_state
538
+
539
+ # and the margins may have changed, this is due to the
540
+ # possibility of the columns being turned on as the columns are
541
+ # managed by manipulating the margins
542
+ dm = pdf.absolute_left_margin - base_left_margin
543
+ base_pos.each { |k, v| pos[k] = v + dm }
544
+ x0 = base_x0 + dm
545
+ x1 = base_x1 + dm
546
+
547
+ tOID = __open_new_object__(pdf) unless :none == @shade_rows
548
+
549
+ pdf.fill_color! @text_color
550
+
551
+ y = pdf.absolute_top_margin - @header_gap
552
+ low_y = y
553
+ y0 = y + descender
554
+ mx = 0
555
+
556
+ if @show_headings
557
+ old_y = y
558
+
559
+ pdf.fill_color @heading_color
560
+ _height, y = __table_column_headings__(pdf, pos, max_width,
561
+ height, descender, @row_gap, @heading_font_size, y)
562
+ pdf.fill_color @text_color
563
+
564
+ y0 = y + _height
565
+ y1 = y
566
+
567
+ if @shade_headings
568
+ pdf.fill_color! @shade_heading_color
569
+ pdf.rectangle(x0 - @gap / 2, y, x1 - x0, _height).fill
570
+ pdf.fill_color @heading_color
571
+ __table_column_headings__(pdf, pos, max_width, height,
572
+ descender, @row_gap,
573
+ @heading_font_size, old_y)
574
+ pdf.fill_color @text_color
575
+ end
576
+
577
+ dm = pdf.absolute_left_margin - base_left_margin
578
+ base_pos.each { |k, v| pos[k] = v + dm }
579
+ x0 = base_x0 + dm
580
+ x1 = base_x1 + dm
581
+ middle = (x0 + x1) / 2.0
582
+ else
583
+ y1 = y0
584
+ end
585
+
586
+ first_line = true
587
+ y -= height
588
+ low_y = y if low_y.nil? or y < low_y
589
+ end
590
+
591
+ newRow = false
592
+
593
+ # Write the actual data. If these cells need to be split over
594
+ # a page, then newPage will be set, and the remaining text
595
+ # will be placed in leftOvers
596
+ newPage = false
597
+ leftOvers = PDF::Writer::OHash.new
598
+
599
+ @cols.each do |name, column|
600
+ pdf.pointer = y + height
601
+ colNewPage = false
602
+
603
+ unless row[name].nil?
604
+ lines = row[name].to_s.split(/\n/)
605
+ if column and column.link_name
606
+ lines.map! do |kk|
607
+ link = row[column.link_name]
608
+ if link
609
+ "<c:alink uri='#{link}'>#{kk}</c:alink>"
610
+ else
611
+ kk
612
+ end
613
+ end
614
+ end
615
+ else
616
+ lines = []
617
+ end
618
+
619
+ pdf.y -= @row_gap
620
+
621
+ lines.each do |line|
622
+ pdf.send(:preprocess_text, line)
623
+ start = true
624
+
625
+ loop do
626
+ break if (line.nil? or line.empty?) and not start
627
+ start = false
628
+
629
+ _y = pdf.y - height if not colNewPage
630
+
631
+ # a new page is required
632
+ newPage = colNewPage = true if _y < pdf.absolute_bottom_margin
633
+
634
+ if colNewPage
635
+ if leftOvers[name].nil?
636
+ leftOvers[name] = [line]
637
+ else
638
+ leftOvers[name] << "\n#{line}"
639
+ end
640
+ line = nil
641
+ else
642
+ if column and column.justification
643
+ just = column.justification
644
+ end
645
+ just ||= :left
646
+
647
+ pdf.y = _y
648
+ line = pdf.add_text_wrap(pos[name], pdf.y,
649
+ max_width[name], line,
650
+ @font_size, just)
651
+ end
652
+ end
653
+ end
654
+
655
+ dy = y + height - pdf.y + @row_gap
656
+ mx = dy - height * (newPage ? 1 : 0) if (dy - height * (newPage ? 1 : 0)) > mx
657
+ end
658
+
659
+ # Set row to leftOvers so that they will be processed onto the
660
+ # new page
661
+ row = leftOvers
662
+
663
+ # Now add the shading underneath
664
+ unless :none == @shade_rows
665
+ pdf.close_object
666
+
667
+ if (cnt % 2).zero?
668
+ pdf.fill_color!(@shade_color)
669
+ pdf.rectangle(x0 - @gap / 2.0, y + descender + height - mx, x1 - x0, mx).fill
670
+ elsif (cnt % 2).nonzero? and :striped == @shade_rows
671
+ pdf.fill_color!(@shade_color2)
672
+ pdf.rectangle(x0 - @gap / 2.0, y + descender + height - mx, x1 - x0, mx).fill
673
+ end
674
+ pdf.reopen_object(tOID)
675
+ end
676
+
677
+ if :inner == @show_lines or :all == @show_lines
678
+ # draw a line on the top of the block
679
+ pdf.save_state
680
+ pdf.stroke_color! @line_color
681
+ if first_line
682
+ pdf.stroke_style @outer_line_style
683
+ first_line = false
684
+ else
685
+ pdf.stroke_style @inner_line_style
686
+ end
687
+ pdf.line(x0 - @gap / 2.0, y + descender + height, x1 - @gap / 2.0, y + descender + height).stroke
688
+ pdf.restore_state
689
+ end
690
+ end
691
+
692
+ y = y - mx + height
693
+ pdf.y = y
694
+ low_y = y if low_y.nil? or y < low_y
695
+
696
+ # checking row split over pages
697
+ unless @split_rows
698
+ if (((pdf.pageset.size != pageStart) or (pdf.columns? and columnStart != pdf.column_number)) and not second_turn)
699
+ # then we need to go back and try that again!
700
+ newPage = second_turn = true
701
+ tg.rewind_transaction(:row)
702
+ row = row_orig
703
+ low_y = y = y_orig
704
+ y0 = y0_orig
705
+ y1 = y1_orig
706
+ ok = false
707
+
708
+ dm = pdf.absolute_left_margin - base_left_margin
709
+ base_pos.each { |k, v| pos[k] = v + dm }
710
+ x0 = base_x0 + dm
711
+ x1 = base_x1 + dm
712
+ else
713
+ tg.commit_transaction(:row)
714
+ ok = true
715
+ end
716
+ else
717
+ ok = true # don't go 'round the loop if splitting rows is allowed
718
+ end
719
+ end
720
+
721
+ if abortTable
722
+ # abort_transaction if not ok only the outer transaction should
723
+ # be operational.
724
+ tg.rewind_transaction(:table)
725
+ pdf.start_new_page
726
+ # fix a bug where a moved table will take up the whole page.
727
+ low_y = nil
728
+ pdf.save_state
729
+ break
730
+ end
731
+ end
732
+ end
733
+
734
+ if low_y <= y
735
+ y2 = low_y + descender
736
+ else
737
+ y2 = y + descender
738
+ end
739
+
740
+ unless :none == @show_lines
741
+ y0 = y1 unless @show_headings
742
+
743
+ __table_draw_lines__(pdf, pos, @gap, x0, x1, y0, y1, y2, @line_color,
744
+ @inner_line_style, @outer_line_style, @show_lines)
745
+ end
746
+
747
+ # close the object for drawing the text on top
748
+ unless :none == @shade_rows
749
+ pdf.close_object
750
+ pdf.restore_state
751
+ end
752
+
753
+ pdf.y = low_y
754
+
755
+ # Table has been put on the page, the rows guarded as required; commit.
756
+ tg.commit_transaction(:table)
757
+
758
+ y
759
+ rescue Exception => ex
760
+ begin
761
+ tg.abort_transaction(:table) if tg.transaction_open?
762
+ rescue
763
+ nil
764
+ end
765
+ raise ex
766
+ end
767
+
768
+ WIDTH_FACTOR = 1.01
769
+
770
+ # Find the maximum widths of the text within each column. Default to
771
+ # zero.
772
+ def __find_table_max_width__(pdf)
773
+ max_width = PDF::Writer::OHash.new(-1)
774
+
775
+ # Find the maximum cell widths based on the data and the headings.
776
+ # Passing through the data multiple times is unavoidable as we must
777
+ # do some analysis first.
778
+ @data.each do |row|
779
+ @cols.each do |name, column|
780
+ w = pdf.text_width(row[name].to_s, @font_size)
781
+ w *= PDF::SimpleTable::WIDTH_FACTOR
782
+
783
+ max_width[name] = w if w > max_width[name]
784
+ end
785
+ end
786
+
787
+ @cols.each do |name, column|
788
+ title = column.heading.title if column.heading
789
+ title ||= column.name
790
+ w = pdf.text_width(title, @heading_font_size)
791
+ w *= PDF::SimpleTable::WIDTH_FACTOR
792
+ max_width[name] = w if w > max_width[name]
793
+ end
794
+ max_width
795
+ end
796
+ private :__find_table_max_width__
797
+
798
+ # Calculate the start positions of each of the columns. This is based
799
+ # on max_width, but may be modified with column options.
800
+ def __find_table_positions__(pdf, max_width)
801
+ pos = PDF::Writer::OHash.new
802
+ x = t = adjustment_width = set_width = 0
803
+
804
+ max_width.each do |name, w|
805
+ pos[name] = t
806
+ # If the column width has been specified then set that here, also
807
+ # total the width avaliable for adjustment.
808
+ if not @cols[name].nil? and
809
+ not @cols[name].width.nil? and
810
+ @cols[name].width > 0
811
+ t += @cols[name].width
812
+ max_width[name] = @cols[name].width - @gap
813
+ set_width += @cols[name].width
814
+ else
815
+ t += w + @gap
816
+ adjustment_width += w
817
+ set_width += @gap
818
+ end
819
+ end
820
+ pos[:__last_column__] = t
821
+
822
+ [pos, t, x, adjustment_width, set_width]
823
+ end
824
+ private :__find_table_positions__
825
+
826
+ # Uses ezText to add the text, and returns the height taken by the
827
+ # largest heading. This page will move the headings to a new page if
828
+ # they will not fit completely on this one transaction support will be
829
+ # used to implement this.
830
+ def __table_column_headings__(pdf, pos, max_width, height, descender, gap, size, y)
831
+ mx = second_go = 0
832
+ start_page = pdf.pageset.size
833
+
834
+ # y is the position at which the top of the table should start, so the
835
+ # base of the first text, is y-height-gap-descender, but ezText starts
836
+ # by dropping height.
837
+
838
+ # The return from this function is the total cell height, including
839
+ # gaps, and y is adjusted to be the postion of the bottom line.
840
+ tg = Transaction::Simple::Group.new(pdf, self)
841
+ tg.start_transaction(:column_headings)
842
+
843
+ ok = false
844
+ y -= gap
845
+ loop do
846
+ break if ok
847
+ @cols.each do |name, column|
848
+ pdf.pointer = y
849
+
850
+ if column.heading
851
+ justification = column.heading.justification
852
+ bold = column.heading.bold
853
+ title = column.heading.title
854
+ end
855
+
856
+ justification ||= :left
857
+ bold ||= @bold_headings
858
+ title ||= column.name
859
+
860
+ title = "<b>#{title}</b>" if bold
861
+
862
+ pdf.text(title, :font_size => size, :absolute_left => pos[name],
863
+ :absolute_right => (max_width[name] + pos[name]),
864
+ :justification => justification)
865
+ dy = y - pdf.y
866
+ mx = dy if dy > mx
867
+ end
868
+
869
+ y -= (mx + gap) - descender # y = y - mx - gap + descender
870
+
871
+ # If this has been moved to a new page, then abort the transaction;
872
+ # move to a new page, and put it there. Do not check on the second
873
+ # time around to avoid an infinite loop.
874
+ if (pdf.pageset.size != start_page and not second_go)
875
+ tg.rewind_transaction(:column_headings)
876
+
877
+ pdf.start_new_page
878
+ save_state
879
+ y = @y - gap - descender
880
+ ok = false
881
+ second_go = true
882
+ mx = 0
883
+ else
884
+ tg.commit_transaction(:column_headings)
885
+ ok = true
886
+ end
887
+ end
888
+
889
+ return [mx + gap * 2 - descender, y]
890
+ rescue Exception => ex
891
+ begin
892
+ tg.abort_transaction(:column_headings) if tg.transaction_open?(:column_headings)
893
+ rescue
894
+ nil
895
+ end
896
+ raise ex
897
+ end
898
+ private :__table_column_headings__
899
+
900
+ def __table_draw_lines__(pdf, pos, gap, x0, x1, y0, y1, y2, col, inner, outer, opt = :outer)
901
+ x0 = 1000
902
+ x1 = 0
903
+
904
+ pdf.stroke_color(col)
905
+
906
+ cnt = 0
907
+ n = pos.size
908
+
909
+ pos.each do |name, x|
910
+ cnt += 1
911
+
912
+ if (cnt == 1 or cnt == n)
913
+ pdf.stroke_style outer
914
+ else
915
+ pdf.stroke_style inner
916
+ end
917
+
918
+ pdf.line(x - gap / 2.0, y0, x - gap / 2.0, y2).stroke
919
+ x1 = x if x > x1
920
+ x0 = x if x < x0
921
+ end
922
+
923
+ pdf.stroke_style outer
924
+
925
+ pdf.line(x0 - (gap / 2.0) - (outer.width / 2.0), y0,
926
+ x1 - (gap / 2.0) + (outer.width / 2.0), y0).stroke
927
+
928
+ # Only do the second line if it is different than the first AND each
929
+ # row does not have a line on it.
930
+ if y0 != y1 and @show_lines == :outer
931
+ pdf.line(x0 - gap / 2.0, y1, x1 - gap / 2.0, y1).stroke
932
+ end
933
+ pdf.line(x0 - (gap / 2.0) - (outer.width / 2.0), y2,
934
+ x1 - (gap / 2.0) + (outer.width / 2.0), y2).stroke
935
+ end
936
+ private :__table_draw_lines__
937
+
938
+ def __open_new_object__(pdf)
939
+ pdf.save_state
940
+ tOID = pdf.open_object
941
+ pdf.close_object
942
+ pdf.add_object(tOID)
943
+ pdf.reopen_object(tOID)
944
+ tOID
945
+ end
946
+ private :__open_new_object__
947
+ end