origami 1.2.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -0
  3. data/README.md +112 -0
  4. data/bin/config/pdfcop.conf.yml +232 -233
  5. data/bin/gui/about.rb +27 -37
  6. data/bin/gui/config.rb +108 -117
  7. data/bin/gui/file.rb +416 -365
  8. data/bin/gui/gtkhex.rb +1138 -1153
  9. data/bin/gui/hexview.rb +55 -57
  10. data/bin/gui/imgview.rb +48 -51
  11. data/bin/gui/menu.rb +388 -386
  12. data/bin/gui/properties.rb +114 -130
  13. data/bin/gui/signing.rb +571 -617
  14. data/bin/gui/textview.rb +77 -95
  15. data/bin/gui/treeview.rb +382 -387
  16. data/bin/gui/walker.rb +227 -232
  17. data/bin/gui/xrefs.rb +56 -60
  18. data/bin/pdf2pdfa +53 -57
  19. data/bin/pdf2ruby +212 -228
  20. data/bin/pdfcop +338 -348
  21. data/bin/pdfdecompress +58 -65
  22. data/bin/pdfdecrypt +56 -60
  23. data/bin/pdfencrypt +75 -80
  24. data/bin/pdfexplode +185 -182
  25. data/bin/pdfextract +201 -218
  26. data/bin/pdfmetadata +83 -82
  27. data/bin/pdfsh +4 -5
  28. data/bin/pdfwalker +1 -2
  29. data/bin/shell/.irbrc +45 -82
  30. data/bin/shell/console.rb +105 -130
  31. data/bin/shell/hexdump.rb +40 -64
  32. data/examples/README.md +34 -0
  33. data/examples/attachments/attachment.rb +38 -0
  34. data/examples/attachments/nested_document.rb +51 -0
  35. data/examples/encryption/encryption.rb +28 -0
  36. data/{samples/actions/triggerevents/trigger.rb → examples/events/events.rb} +13 -16
  37. data/examples/flash/flash.rb +37 -0
  38. data/{samples → examples}/flash/helloworld.swf +0 -0
  39. data/examples/forms/javascript.rb +54 -0
  40. data/examples/forms/xfa.rb +115 -0
  41. data/examples/javascript/hello_world.rb +22 -0
  42. data/examples/javascript/js_emulation.rb +54 -0
  43. data/examples/loop/goto.rb +32 -0
  44. data/examples/loop/named.rb +33 -0
  45. data/examples/signature/signature.rb +65 -0
  46. data/examples/uri/javascript.rb +56 -0
  47. data/examples/uri/open-uri.rb +21 -0
  48. data/examples/uri/submitform.rb +47 -0
  49. data/lib/origami.rb +29 -42
  50. data/lib/origami/3d.rb +350 -225
  51. data/lib/origami/acroform.rb +262 -288
  52. data/lib/origami/actions.rb +268 -288
  53. data/lib/origami/annotations.rb +697 -722
  54. data/lib/origami/array.rb +258 -184
  55. data/lib/origami/boolean.rb +74 -84
  56. data/lib/origami/catalog.rb +397 -434
  57. data/lib/origami/collections.rb +144 -0
  58. data/lib/origami/destinations.rb +233 -194
  59. data/lib/origami/dictionary.rb +253 -232
  60. data/lib/origami/encryption.rb +1274 -1243
  61. data/lib/origami/export.rb +232 -268
  62. data/lib/origami/extensions/fdf.rb +307 -220
  63. data/lib/origami/extensions/ppklite.rb +368 -435
  64. data/lib/origami/filespec.rb +197 -0
  65. data/lib/origami/filters.rb +301 -295
  66. data/lib/origami/filters/ascii.rb +177 -180
  67. data/lib/origami/filters/ccitt.rb +528 -535
  68. data/lib/origami/filters/crypt.rb +26 -35
  69. data/lib/origami/filters/dct.rb +46 -52
  70. data/lib/origami/filters/flate.rb +95 -94
  71. data/lib/origami/filters/jbig2.rb +49 -55
  72. data/lib/origami/filters/jpx.rb +38 -44
  73. data/lib/origami/filters/lzw.rb +189 -183
  74. data/lib/origami/filters/predictors.rb +221 -235
  75. data/lib/origami/filters/runlength.rb +103 -104
  76. data/lib/origami/font.rb +173 -186
  77. data/lib/origami/functions.rb +67 -81
  78. data/lib/origami/graphics.rb +25 -21
  79. data/lib/origami/graphics/colors.rb +178 -187
  80. data/lib/origami/graphics/instruction.rb +79 -85
  81. data/lib/origami/graphics/path.rb +142 -148
  82. data/lib/origami/graphics/patterns.rb +160 -167
  83. data/lib/origami/graphics/render.rb +43 -50
  84. data/lib/origami/graphics/state.rb +138 -153
  85. data/lib/origami/graphics/text.rb +188 -205
  86. data/lib/origami/graphics/xobject.rb +819 -815
  87. data/lib/origami/header.rb +63 -78
  88. data/lib/origami/javascript.rb +596 -597
  89. data/lib/origami/linearization.rb +285 -290
  90. data/lib/origami/metadata.rb +139 -148
  91. data/lib/origami/name.rb +112 -148
  92. data/lib/origami/null.rb +53 -62
  93. data/lib/origami/numeric.rb +162 -175
  94. data/lib/origami/obfuscation.rb +186 -174
  95. data/lib/origami/object.rb +593 -573
  96. data/lib/origami/outline.rb +42 -47
  97. data/lib/origami/outputintents.rb +73 -82
  98. data/lib/origami/page.rb +703 -592
  99. data/lib/origami/parser.rb +238 -290
  100. data/lib/origami/parsers/fdf.rb +41 -33
  101. data/lib/origami/parsers/pdf.rb +75 -95
  102. data/lib/origami/parsers/pdf/lazy.rb +137 -0
  103. data/lib/origami/parsers/pdf/linear.rb +64 -66
  104. data/lib/origami/parsers/ppklite.rb +34 -70
  105. data/lib/origami/pdf.rb +1030 -1005
  106. data/lib/origami/reference.rb +102 -102
  107. data/lib/origami/signature.rb +591 -609
  108. data/lib/origami/stream.rb +668 -551
  109. data/lib/origami/string.rb +397 -373
  110. data/lib/origami/template/patterns.rb +56 -0
  111. data/lib/origami/template/widgets.rb +151 -0
  112. data/lib/origami/trailer.rb +144 -158
  113. data/lib/origami/tree.rb +62 -0
  114. data/lib/origami/version.rb +23 -0
  115. data/lib/origami/webcapture.rb +88 -79
  116. data/lib/origami/xfa.rb +2863 -2882
  117. data/lib/origami/xreftable.rb +472 -384
  118. data/test/dataset/calc.pdf +85 -0
  119. data/test/dataset/crypto.pdf +82 -0
  120. data/test/dataset/empty.pdf +49 -0
  121. data/test/test_actions.rb +27 -0
  122. data/test/test_annotations.rb +90 -0
  123. data/test/test_pages.rb +31 -0
  124. data/test/test_pdf.rb +16 -0
  125. data/test/test_pdf_attachment.rb +34 -0
  126. data/test/test_pdf_create.rb +24 -0
  127. data/test/test_pdf_encrypt.rb +95 -0
  128. data/test/test_pdf_parse.rb +96 -0
  129. data/test/test_pdf_sign.rb +58 -0
  130. data/test/test_streams.rb +182 -0
  131. data/test/test_xrefs.rb +67 -0
  132. metadata +88 -58
  133. data/README +0 -67
  134. data/bin/pdf2graph +0 -121
  135. data/bin/pdfcocoon +0 -104
  136. data/lib/origami/file.rb +0 -233
  137. data/samples/README.txt +0 -45
  138. data/samples/actions/launch/calc.rb +0 -87
  139. data/samples/actions/launch/winparams.rb +0 -22
  140. data/samples/actions/loop/loopgoto.rb +0 -24
  141. data/samples/actions/loop/loopnamed.rb +0 -21
  142. data/samples/actions/named/named.rb +0 -31
  143. data/samples/actions/samba/smbrelay.rb +0 -26
  144. data/samples/actions/webbug/submitform.js +0 -26
  145. data/samples/actions/webbug/webbug-browser.rb +0 -68
  146. data/samples/actions/webbug/webbug-js.rb +0 -67
  147. data/samples/actions/webbug/webbug-reader.rb +0 -90
  148. data/samples/attachments/attach.rb +0 -40
  149. data/samples/attachments/attached.txt +0 -1
  150. data/samples/crypto/crypto.rb +0 -28
  151. data/samples/digsig/signed.rb +0 -46
  152. data/samples/exploits/cve-2008-2992-utilprintf.rb +0 -87
  153. data/samples/exploits/cve-2009-0927-geticon.rb +0 -65
  154. data/samples/exploits/exploit_customdictopen.rb +0 -55
  155. data/samples/exploits/getannots.rb +0 -69
  156. data/samples/flash/flash.rb +0 -31
  157. data/samples/javascript/attached.txt +0 -1
  158. data/samples/javascript/js.rb +0 -52
  159. data/templates/patterns.rb +0 -66
  160. data/templates/widgets.rb +0 -173
  161. data/templates/xdp.rb +0 -92
  162. data/test/ts_pdf.rb +0 -50
@@ -1,776 +1,751 @@
1
1
  =begin
2
2
 
3
- = File
4
- annotations.rb
5
-
6
- = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
8
- Copyright (C) 2010 Guillaume DelugrÈ <guillaume AT security-labs DOT org>
9
- All right reserved.
10
-
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
13
- the Free Software Foundation, either version 3 of the License, or
14
- (at your option) any later version.
15
-
16
- Origami is distributed in the hope that it will be useful,
17
- but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
20
-
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2016 Guillaume Delugré.
23
5
 
24
- =end
25
-
26
- module Origami
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
27
10
 
28
- #
29
- # Class representing an annotation.
30
- # Annotations are objects which user can interact with.
31
- #
32
- class Annotation < Dictionary
33
-
34
- include StandardObject
35
-
36
- field :Type, :Type => Name, :Default => :Annot
37
- field :Subtype, :Type => Name, :Required => true
38
- field :Rect, :Type => Array, :Default => [ 0 , 0 , 0 , 0 ], :Required => true
39
- field :Contents, :Type => String
40
- field :P, :Type => Dictionary, :Version => "1.3"
41
- field :NM, :Type => String, :Version => "1.4"
42
- field :M, :Type => ByteString, :Version => "1.1"
43
- field :F, :Type => Integer, :Default => 0, :Version => "1.1"
44
- field :AP, :Type => Dictionary, :Version => "1.2"
45
- field :AS, :Type => Name, :Version => "1.2"
46
- field :Border, :Type => Array, :Default => [ 0 , 0 , 1 ]
47
- field :C, :Type => Array, :Version => "1.1"
48
- field :StructParent, :Type => Integer, :Version => "1.3"
49
- field :OC, :Type => Dictionary, :Version => "1.5"
50
-
51
- def set_normal_appearance(apstm)
52
- self.AP ||= AppearanceDictionary.new
53
- self.AP[:N] = apstm
54
-
55
- self
56
- end
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
57
15
 
58
- def set_rollover_appearance(apstm)
59
- self.AP ||= AppearanceDictionary.new
60
- self.AP[:R] = apstm
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
61
18
 
62
- self
63
- end
19
+ =end
64
20
 
65
- def set_down_appearance(apstm)
66
- self.AP ||= AppearanceStream.new
67
- self.AP[:D] = apstm
21
+ module Origami
68
22
 
69
- self
70
- end
23
+ # Forward declaration.
24
+ class Action < Dictionary; end
71
25
 
72
- module Triggerable
73
-
74
- def onMouseOver(action)
75
- unless action.is_a?(Action) or action.is_a?(Reference)
76
- raise TypeError, "An Action object must be passed."
77
- end
78
-
79
- self.AA ||= AdditionalActions.new
80
- self.AA.E = action
81
- end
82
-
83
- def onMouseOut(action)
84
- unless action.is_a?(Action) or action.is_a?(Reference)
85
- raise TypeError, "An Action object must be passed."
86
- end
87
-
88
- self.AA ||= AdditionalActions.new
89
- self.AA.X = action
90
- end
91
-
92
- def onMouseDown(action)
93
- unless action.is_a?(Action) or action.is_a?(Reference)
94
- raise TypeError, "An Action object must be passed."
95
- end
96
-
97
- self.AA ||= AdditionalActions.new
98
- self.AA.D = action
99
- end
100
-
101
- def onMouseUp(action)
102
- unless action.is_a?(Action) or action.is_a?(Reference)
103
- raise TypeError, "An Action object must be passed."
104
- end
105
-
106
- self.AA ||= AdditionalActions.new
107
- self.AA.U = action
108
- end
109
-
110
- def onFocus(action)
111
- unless action.is_a?(Action) or action.is_a?(Reference)
112
- raise TypeError, "An Action object must be passed."
113
- end
114
-
115
- self.AA ||= AdditionalActions.new
116
- self.AA.Fo = action
117
- end
118
-
119
- def onBlur(action)
120
- unless action.is_a?(Action) or action.is_a?(Reference)
121
- raise TypeError, "An Action object must be passed."
122
- end
123
-
124
- self.AA ||= AdditionalActions.new
125
- self.AA.Bl = action
126
- end
127
-
128
- def onPageOpen(action)
129
- unless action.is_a?(Action) or action.is_a?(Reference)
130
- raise TypeError, "An Action object must be passed."
131
- end
26
+ #
27
+ # Class representing an annotation.
28
+ # Annotations are objects which user can interact with.
29
+ #
30
+ class Annotation < Dictionary
31
+ include StandardObject
132
32
 
133
- self.AA ||= AdditionalActions.new
134
- self.AA.PO = action
135
- end
136
-
137
- def onPageClose(action)
138
- unless action.is_a?(Action) or action.is_a?(Reference)
139
- raise TypeError, "An Action object must be passed."
33
+ #
34
+ # An AppearanceStream is a FormXObject.
35
+ #
36
+ class AppearanceStream < Graphics::FormXObject ; end
37
+
38
+ #
39
+ # Appearance Dictionary of an Annotation.
40
+ #
41
+ class AppearanceDictionary < Dictionary
42
+ include StandardObject
43
+
44
+ field :N, :Type => [ AppearanceStream, Dictionary ], :Required => true
45
+ field :R, :Type => [ AppearanceStream, Dictionary ]
46
+ field :D, :Type => [ AppearanceStream, Dictionary ]
140
47
  end
141
-
142
- self.AA ||= AdditionalActions.new
143
- self.AA.PC = action
144
- end
145
48
 
146
- def onPageVisible(action)
147
- unless action.is_a?(Action) or action.is_a?(Reference)
148
- raise TypeError, "An Action object must be passed."
149
- end
150
-
151
- self.AA ||= AdditionalActions.new
152
- self.AA.PV = action
153
- end
154
-
155
- def onPageInvisible(action)
156
- unless action.is_a?(Action) or action.is_a?(Reference)
157
- raise TypeError, "An Action object must be passed."
49
+ #
50
+ # Class representing additional actions which can be associated with an annotation having an AA field.
51
+ #
52
+ class AdditionalActions < Dictionary
53
+ include StandardObject
54
+
55
+ field :E, :Type => Action, :Version => "1.2" # Mouse Enter
56
+ field :X, :Type => Action, :Version => "1.2" # Mouse Exit
57
+ field :D, :Type => Action, :Version => "1.2" # Mouse Down
58
+ field :U, :Type => Action, :Version => "1.2" # Mouse Up
59
+ field :Fo, :Type => Action, :Version => "1.2" # Focus
60
+ field :Bl, :Type => Action, :Version => "1.2" # Blur
61
+ field :PO, :Type => Action, :Version => "1.2" # Page Open
62
+ field :PC, :Type => Action, :Version => "1.2" # Page Close
63
+ field :PV, :Type => Action, :Version => "1.2" # Page Visible
64
+ field :PI, :Type => Action, :Version => "1.2" # Page Invisible
158
65
  end
159
-
160
- self.AA ||= AdditionalActions.new
161
- self.AA.PI = action
162
- end
163
-
164
- end
165
-
166
- #
167
- # Annotation flags
168
- #
169
- module Flags
170
- INVISIBLE = 1 << 0
171
- HIDDEN = 1 << 1
172
- PRINT = 1 << 2
173
- NOZOOM = 1 << 3
174
- NOROTATE = 1 << 4
175
- NOVIEW = 1 << 5
176
- READONLY = 1 << 6
177
- LOCKED = 1 << 7
178
- TOGGLENOVIEW = 1 << 8
179
- LOCKEDCONTENTS = 1 << 9
180
- end
181
-
182
- module Markup
183
-
184
- def self.included(receiver)
185
- receiver.field :T, :Type => String, :Version => "1.1"
186
- receiver.field :Popup, :Type => Dictionary, :Version => "1.3"
187
- receiver.field :CA, :Type => Number, :Default => 1.0, :Version => "1.4"
188
- receiver.field :RC, :Type => [String, Stream], :Version => "1.5"
189
- receiver.field :CreationDate, :Type => String, :Version => "1.5"
190
- receiver.field :IRT, :Type => Dictionary, :Version => "1.5"
191
- receiver.field :Subj, :Type => String, :Version => "1.5"
192
- receiver.field :RT, :Type => Name, :Default => :R, :Version => "1.6"
193
- receiver.field :IT, :Type => Name, :Version => "1.6"
194
- receiver.field :ExData, :Type => Dictionary, :Version => "1.7"
195
- end
196
-
197
- end
198
-
199
- class AppearanceDictionary < Dictionary
200
66
 
201
- include StandardObject
67
+ #
68
+ # Annotation fields.
69
+ #
70
+ field :Type, :Type => Name, :Default => :Annot
71
+ field :Subtype, :Type => Name, :Required => true
72
+ field :Rect, :Type => Rectangle, :Default => [ 0, 0, 0, 0 ], :Required => true
73
+ field :Contents, :Type => String
74
+ field :P, :Type => Page, :Version => "1.3"
75
+ field :NM, :Type => String, :Version => "1.4"
76
+ field :M, :Type => String, :Version => "1.1"
77
+ field :F, :Type => Integer, :Default => 0, :Version => "1.1"
78
+ field :AP, :Type => AppearanceDictionary, :Version => "1.2"
79
+ field :AS, :Type => Name, :Version => "1.2"
80
+ field :Border, :Type => Array, :Default => [ 0 , 0 , 1 ]
81
+ field :C, :Type => Array.of(Number), :Version => "1.1"
82
+ field :StructParent, :Type => Integer, :Version => "1.3"
83
+ field :OC, :Type => Dictionary, :Version => "1.5"
84
+
85
+ def set_normal_appearance(apstm)
86
+ self.AP ||= AppearanceDictionary.new
87
+ self.AP[:N] = apstm
88
+
89
+ self
90
+ end
202
91
 
203
- field :N, :Type => [ Stream, Dictionary ], :Required => true
204
- field :R, :Type => [ Stream, Dictionary ]
205
- field :D, :Type => [ Stream, Dictionary ]
92
+ def set_rollover_appearance(apstm)
93
+ self.AP ||= AppearanceDictionary.new
94
+ self.AP[:R] = apstm
206
95
 
207
- end
96
+ self
97
+ end
208
98
 
209
- class AppearanceStream < Graphics::FormXObject ; end
210
-
211
- class BorderStyle < Dictionary
212
-
213
- include StandardObject
214
-
215
- SOLID = :S
216
- DASHED = :D
217
- BEVELED = :B
218
- INSET = :I
219
- UNDERLINE = :U
99
+ def set_down_appearance(apstm)
100
+ self.AP ||= AppearanceStream.new
101
+ self.AP[:D] = apstm
220
102
 
221
- field :Type, :Type => Name, :Default => :Border
222
- field :W, :Type => Number, :Default => 1
223
- field :S, :Type => Name, :Default => SOLID
224
- field :D, :Type => Array, :Default => [ 3 ]
103
+ self
104
+ end
225
105
 
226
- end
227
-
228
- class AppearanceCharacteristics < Dictionary
229
-
230
- include StandardObject
231
-
232
- module CaptionStyle
233
- CAPTIONONLY = 0
234
- ICONONLY = 1
235
- CAPTIONBELOW = 2
236
- CAPTIONABOVE = 3
237
- CAPTIONRIGHT = 4
238
- CAPTIONLEFT = 5
239
- CAPTIONOVERLAID = 6
240
- end
241
-
242
- field :R, :Type => Integer, :Default => 0
243
- field :BC, :Type => Array
244
- field :BG, :Type => Array
245
- field :CA, :Type => String
246
- field :RC, :Type => String
247
- field :AC, :Type => String
248
- field :I, :Type => Stream
249
- field :RI, :Type => Stream
250
- field :IX, :Type => Stream
251
- field :IF, :Type => Dictionary
252
- field :TP, :Type => Integer, :Default => CaptionStyle::CAPTIONONLY
253
-
254
- end
106
+ module Triggerable
107
+
108
+ def onMouseOver(action)
109
+ unless action.is_a?(Action) or action.is_a?(Reference)
110
+ raise TypeError, "An Action object must be passed."
111
+ end
112
+
113
+ self.AA ||= AdditionalActions.new
114
+ self.AA.E = action
115
+ end
116
+
117
+ def onMouseOut(action)
118
+ unless action.is_a?(Action) or action.is_a?(Reference)
119
+ raise TypeError, "An Action object must be passed."
120
+ end
121
+
122
+ self.AA ||= AdditionalActions.new
123
+ self.AA.X = action
124
+ end
125
+
126
+ def onMouseDown(action)
127
+ unless action.is_a?(Action) or action.is_a?(Reference)
128
+ raise TypeError, "An Action object must be passed."
129
+ end
130
+
131
+ self.AA ||= AdditionalActions.new
132
+ self.AA.D = action
133
+ end
134
+
135
+ def onMouseUp(action)
136
+ unless action.is_a?(Action) or action.is_a?(Reference)
137
+ raise TypeError, "An Action object must be passed."
138
+ end
139
+
140
+ self.AA ||= AdditionalActions.new
141
+ self.AA.U = action
142
+ end
143
+
144
+ def onFocus(action)
145
+ unless action.is_a?(Action) or action.is_a?(Reference)
146
+ raise TypeError, "An Action object must be passed."
147
+ end
148
+
149
+ self.AA ||= AdditionalActions.new
150
+ self.AA.Fo = action
151
+ end
152
+
153
+ def onBlur(action)
154
+ unless action.is_a?(Action) or action.is_a?(Reference)
155
+ raise TypeError, "An Action object must be passed."
156
+ end
157
+
158
+ self.AA ||= AdditionalActions.new
159
+ self.AA.Bl = action
160
+ end
161
+
162
+ def onPageOpen(action)
163
+ unless action.is_a?(Action) or action.is_a?(Reference)
164
+ raise TypeError, "An Action object must be passed."
165
+ end
166
+
167
+ self.AA ||= AdditionalActions.new
168
+ self.AA.PO = action
169
+ end
170
+
171
+ def onPageClose(action)
172
+ unless action.is_a?(Action) or action.is_a?(Reference)
173
+ raise TypeError, "An Action object must be passed."
174
+ end
175
+
176
+ self.AA ||= AdditionalActions.new
177
+ self.AA.PC = action
178
+ end
179
+
180
+ def onPageVisible(action)
181
+ unless action.is_a?(Action) or action.is_a?(Reference)
182
+ raise TypeError, "An Action object must be passed."
183
+ end
184
+
185
+ self.AA ||= AdditionalActions.new
186
+ self.AA.PV = action
187
+ end
188
+
189
+ def onPageInvisible(action)
190
+ unless action.is_a?(Action) or action.is_a?(Reference)
191
+ raise TypeError, "An Action object must be passed."
192
+ end
193
+
194
+ self.AA ||= AdditionalActions.new
195
+ self.AA.PI = action
196
+ end
197
+ end
255
198
 
256
- class Shape < Annotation
199
+ #
200
+ # Annotation flags
201
+ #
202
+ module Flags
203
+ INVISIBLE = 1 << 0
204
+ HIDDEN = 1 << 1
205
+ PRINT = 1 << 2
206
+ NOZOOM = 1 << 3
207
+ NOROTATE = 1 << 4
208
+ NOVIEW = 1 << 5
209
+ READONLY = 1 << 6
210
+ LOCKED = 1 << 7
211
+ TOGGLENOVIEW = 1 << 8
212
+ LOCKEDCONTENTS = 1 << 9
213
+ end
257
214
 
258
- include Markup
215
+ module Markup
216
+ def self.included(receiver)
217
+ receiver.field :T, :Type => String, :Version => "1.1"
218
+ receiver.field :Popup, :Type => Dictionary, :Version => "1.3"
219
+ receiver.field :CA, :Type => Number, :Default => 1.0, :Version => "1.4"
220
+ receiver.field :RC, :Type => [String, Stream], :Version => "1.5"
221
+ receiver.field :CreationDate, :Type => String, :Version => "1.5"
222
+ receiver.field :IRT, :Type => Dictionary, :Version => "1.5"
223
+ receiver.field :Subj, :Type => String, :Version => "1.5"
224
+ receiver.field :RT, :Type => Name, :Default => :R, :Version => "1.6"
225
+ receiver.field :IT, :Type => Name, :Version => "1.6"
226
+ receiver.field :ExData, :Type => Dictionary, :Version => "1.7"
227
+ end
228
+ end
259
229
 
260
- field :Subtype, :Type => Name, :Required => true
261
- field :BS, :Type => Dictionary
262
- field :IC, :Type => Array
263
- field :BE, :Type => Dictionary, :Version => "1.5"
264
- field :RD, :Type => Array, :Version => "1.5"
265
-
266
- end
267
-
268
- class Square < Shape
269
- field :Subtype, :Type => Name, :Default => :Square, :Required => true
270
- end
271
-
272
- class Circle < Shape
273
-
274
- field :Subtype, :Type => Name, :Default => :Circle, :Required => true
230
+ class BorderStyle < Dictionary
231
+ include StandardObject
275
232
 
276
- end
233
+ SOLID = :S
234
+ DASHED = :D
235
+ BEVELED = :B
236
+ INSET = :I
237
+ UNDERLINE = :U
277
238
 
278
- #
279
- # Text annotation
280
- #
281
- class Text < Annotation
282
-
283
- include Markup
284
-
285
- module TextName
286
- COMMENT = :C
287
- KEY = :K
288
- NOTE = :N
289
- HELP = :H
290
- NEWPARAGRAPH = :NP
291
- PARAGRAPH = :P
292
- INSERT = :I
293
- end
294
-
295
- field :Subtype, :Type => Name, :Default => :Text, :Required => true
296
- field :Open, :Type => Boolean, :Default => false
297
- field :Name, :Type => Name, :Default => TextName::NOTE
298
- field :State, :Type => String, :Version => "1.5"
299
- field :StateModel, :Type => String, :Version => "1.5"
300
-
301
- def pre_build
302
-
303
- model = self.StateModel
304
- state = self.State
305
-
306
- case model
307
- when "Marked"
308
- state = "Unmarked" if state.nil?
309
- when "Review"
310
- state = "None" if state.nil?
239
+ field :Type, :Type => Name, :Default => :Border
240
+ field :W, :Type => Number, :Default => 1
241
+ field :S, :Type => Name, :Default => SOLID
242
+ field :D, :Type => Array, :Default => [ 3 ]
311
243
  end
312
244
 
313
- super
314
- end
245
+ class BorderEffect < Dictionary
246
+ include StandardObject
315
247
 
316
- end
248
+ NONE = :S
249
+ CLOUDY = :C
317
250
 
318
- #
319
- # FreeText Annotation
320
- #
321
- class FreeText < Annotation
322
-
323
- include Markup
324
-
325
- module Intent
326
- FREETEXT = :FreeText
327
- FREETEXTCALLOUT = :FreeTextCallout
328
- FREETEXTTYPEWRITER = :FreeTextTypeWriter
329
- end
330
-
331
- field :Subtype, :Type => Name, :Default => :FreeText, :Required => true
332
- field :DA, :Type => String, :Default => "/F1 10 Tf 0 g", :Required => true
333
- field :Q, :Type => Integer, :Default => Field::TextAlign::LEFT, :Version => "1.4"
334
- field :RC, :Type => [String, Stream], :Version => "1.5"
335
- field :DS, :Type => String, :Version => "1.5"
336
- field :CL, :Type => Array, :Version => "1.6"
337
- field :IT, :Type => Name, :Default => Intent::FREETEXT, :Version => "1.6"
338
- field :BE, :Type => Dictionary, :Version => "1.6"
339
- field :RD, :Type => Array, :Version => "1.6"
340
- field :BS, :Type => Dictionary, :Version => "1.6"
341
- field :LE, :Type => Name, :Default => :None, :Version => "1.6"
342
-
343
- end
251
+ field :S, :Type => Name, :Default => NONE
252
+ field :I, :Type => Integer, :Default => 0
253
+ end
344
254
 
345
- #
346
- # Class representing an link annotation.
347
- #
348
- class Link < Annotation
349
-
350
- #
351
- # The annotation’s highlighting mode, the visual effect to be used when the mouse button is pressed or held down inside its active area.
352
- #
353
- module Highlight
354
- # No highlighting
355
- NONE = :N
356
-
357
- # Invert the contents of the annotation rectangle.
358
- INVERT = :I
359
-
360
- # Invert the annotation’s border.
361
- OUTLINE = :O
362
-
363
- # Display the annotation as if it were being pushed below the surface of the page
364
- PUSH = :P
365
- end
366
-
367
- field :Subtype, :Type => Name, :Default => :Link, :Required => true
368
- field :A, :Type => Dictionary, :Version => "1.1"
369
- field :Dest, :Type => [ Array, Name, ByteString ]
370
- field :H, :Type => Name, :Default => Highlight::INVERT, :Version => "1.2"
371
- field :AP, :Type => Dictionary, :Version => "1.3"
372
- field :QuadPoints, :Type => Array, :Version => "1.6"
373
-
374
- end
255
+ class AppearanceCharacteristics < Dictionary
256
+ include StandardObject
257
+
258
+ module CaptionStyle
259
+ CAPTION_ONLY = 0
260
+ ICON_ONLY = 1
261
+ CAPTION_BELOW = 2
262
+ CAPTION_ABOVE = 3
263
+ CAPTION_RIGHT = 4
264
+ CAPTION_LEFT = 5
265
+ CAPTION_OVERLAID = 6
266
+ end
267
+
268
+ field :R, :Type => Integer, :Default => 0
269
+ field :BC, :Type => Array.of(Number)
270
+ field :BG, :Type => Array.of(Number)
271
+ field :CA, :Type => String
272
+ field :RC, :Type => String
273
+ field :AC, :Type => String
274
+ field :I, :Type => Stream
275
+ field :RI, :Type => Stream
276
+ field :IX, :Type => Stream
277
+ field :IF, :Type => Dictionary
278
+ field :TP, :Type => Integer, :Default => CaptionStyle::CAPTION_ONLY
279
+ end
375
280
 
376
- #
377
- # Class representing a file attachment annotation.
378
- #
379
- class FileAttachment < Annotation
380
-
381
- include Markup
382
-
383
- # Icons to be displayed for file attachment.
384
- module Icons
385
- GRAPH = :Graph
386
- PAPERCLIP = :Paperclip
387
- PUSHPIN = :PushPin
388
- TAG = :Tag
389
- end
390
-
391
- field :Subtype, :Type => Name, :Default => :FileAttachment, :Required => true
392
- field :FS, :Type => Dictionary, :Required => true
393
- field :Name, :Type => Name, :Default => Icons::PUSHPIN
394
-
395
- end
281
+ class Shape < Annotation
282
+ include Markup
283
+
284
+ field :Subtype, :Type => Name, :Required => true
285
+ field :BS, :Type => BorderStyle
286
+ field :IC, :Type => Array.of(Number)
287
+ field :BE, :Type => BorderEffect, :Version => "1.5"
288
+ field :RD, :Type => Rectangle, :Version => "1.5"
289
+ end
396
290
 
397
- #
398
- # Class representing a screen Annotation.
399
- # A screen annotation specifies a region of a page upon which media clips may be played. It also serves as an object from which actions can be triggered.
400
- #
401
- class Screen < Annotation
402
-
403
- include Triggerable
404
-
405
- field :Subtype, :Type => Name, :Default => :Screen, :Required => true
406
- field :T, :Type => String
407
- field :MK, :Type => Dictionary
408
- field :A, :Type => Dictionary, :Version => "1.1"
409
- field :AA, :Type => Dictionary, :Version => "1.2"
410
-
411
- end
412
-
413
-
414
- class Sound < Annotation
415
-
416
- include Markup
417
-
418
- module Icons
419
- SPEAKER = :Speaker
420
- MIC = :Mic
421
- end
422
-
423
- field :Subtype, :Type => Name, :Default => :Sound, :Required => true
424
- field :Sound, :Type => Stream, :Required => true
425
- field :Name, :Type => Name, :Default => Icons::SPEAKER
426
-
427
- end
428
-
429
- class RichMedia < Annotation
430
-
431
- field :Subtype, :Type => Name, :Default => :RichMedia, :Version => "1.7", :ExtensionLevel => 3, :Required => true
432
- field :RichMediaSettings, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
433
- field :RichMediaContent, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3, :Required => true
434
-
435
- class Settings < Dictionary
436
- include StandardObject
437
-
438
- field :Type, :Type => Name, :Default => :RichMediaSettings, :Version => "1.7", :ExtensionLevel => 3
439
- field :Activation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
440
- field :Deactivation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
441
- end
442
-
443
- class Activation < Dictionary
444
- include StandardObject
445
-
446
- USER_ACTION = :XA
447
- PAGE_OPEN = :PO
448
- PAGE_VISIBLE = :PV
449
-
450
- field :Type, :Type => Name, :Default => :RichMediaActivation, :Version => "1.7", :ExtensionLevel => 3
451
- field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
452
- field :Animation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
453
- field :View, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
454
- field :Configuration, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
455
- field :Presentation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
456
- field :Scripts, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
457
- end
458
-
459
- class Deactivation < Dictionary
460
- include StandardObject
461
-
462
- USER_ACTION = :XD
463
- PAGE_CLOSE = :PC
464
- PAGE_INVISIBLE = :PV
465
-
466
- field :Type, :Type => Name, :Default => :RichMediaDeactivation, :Version => "1.7", :ExtensionLevel => 3
467
- field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
468
- end
469
-
470
- class Animation < Dictionary
471
- include StandardObject
472
-
473
- NONE = :None
474
- LINEAR = :Linear
475
- OSCILLATING = :Oscillating
476
-
477
- field :Type, :Type => Name, :Default => :RichMediaAnimation, :Version => "1.7", :ExtensionLevel => 3
478
- field :Subtype, :Type => Name, :Default => NONE, :Version => "1.7", :ExtensionLevel => 3
479
- field :PlayCount, :Type => Integer, :Default => -1, :Version => "1.7", :ExtensionLevel => 3
480
- field :Speed, :Type => Number, :Default => 1, :Version => "1.7", :ExtensionLevel => 3
481
- end
482
-
483
- class Presentation < Dictionary
484
- include StandardObject
485
-
486
- WINDOWED = :Windowed
487
- EMBEDDED = :Embedded
488
-
489
- field :Type, :Type => Name, :Default => :RichMediaPresentation, :Version => "1.7", :ExtensionLevel => 3
490
- field :Style, :Type => Name, :Default => EMBEDDED, :Version => "1.7", :ExtensionLevel => 3
491
- field :Window, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
492
- field :Transparent, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
493
- field :NavigationPane, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
494
- field :Toolbar, :Type => Boolean, :Version => "1.7", :ExtensionLevel => 3
495
- field :PassContextClick, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
496
- end
497
-
498
- class Window < Dictionary
499
- include StandardObject
500
-
501
- field :Type, :Type => Name, :Default => :RichMediaWindow, :Version => "1.7", :ExtensionLevel => 3
502
- field :Width, :Type => Dictionary, :Default => {:Default => 288, :Max => 576, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
503
- field :Height, :Type => Dictionary, :Default => {:Default => 216, :Max => 432, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
504
- field :Position, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
505
- end
506
-
507
- class Position < Dictionary
508
- include StandardObject
509
-
510
- NEAR = :Near
511
- CENTER = :Center
512
- FAR = :Far
513
-
514
- field :Type, :Type => Name, :Default => :RichMediaPosition, :Version => "1.7", :ExtensionLevel => 3
515
- field :HAlign, :Type => Name, :Default => FAR, :Version => "1.7", :ExtensionLevel => 3
516
- field :VAlign, :Type => Name, :Default => NEAR, :Version => "1.7", :ExtensionLevel => 3
517
- field :HOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
518
- field :VOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
519
- end
520
-
521
- class Content < Dictionary
522
- include StandardObject
523
-
524
- field :Type, :Type => Name, :Default => :RichMediaContent, :Version => "1.7", :ExtensionLevel => 3
525
- field :Assets, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
526
- field :Configurations, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
527
- field :Views, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
528
- end
529
-
530
- class Configuration < Dictionary
531
- include StandardObject
532
-
533
- U3D = :"3D"
534
- FLASH = :Flash
535
- SOUND = :Sound
536
- VIDEO = :Video
537
-
538
- field :Type, :Type => Name, :Default => :RichMediaConfiguration, :Version => "1.7", :ExtensionLevel => 3
539
- field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
540
- field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3
541
- field :Instances, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
542
- end
543
-
544
- class Instance < Dictionary
545
- include StandardObject
546
-
547
- U3D = :"3D"
548
- FLASH = :Flash
549
- SOUND = :Sound
550
- VIDEO = :Video
551
-
552
- field :Type, :Type => Name, :Default => :RichMediaInstance, :Version => "1.7", :ExtensionLevel => 3
553
- field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
554
- field :Params, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
555
- field :Asset, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
556
- end
557
-
558
- class Parameters < Dictionary
559
- include StandardObject
560
-
561
- module Binding
562
- NONE = :None
563
- FOREGROUND = :Foreground
564
- BACKGROUND = :Background
565
- MATERIAL = :Material
291
+ class Square < Shape
292
+ field :Subtype, :Type => Name, :Default => :Square, :Required => true
293
+ end
294
+
295
+ class Circle < Shape
296
+ field :Subtype, :Type => Name, :Default => :Circle, :Required => true
566
297
  end
567
298
 
568
- field :Type, :Type => Name, :Default => :RichMediaParams, :Version => "1.7", :ExtensionLevel => 3
569
- field :FlashVars, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
570
- field :Binding, :Type => Name, :Default => Binding::NONE, :Version => "1.7", :ExtensionLevel => 3
571
- field :BindingMaterialName, :Type => String, :Version => "1.7", :ExtensionLevel => 3
572
- field :CuePoints, :Type => Array, :Default => [], :Version => "1.7", :ExtensionLevel => 3
573
- field :Settings, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
574
- end
575
-
576
- class CuePoint < Dictionary
577
- include StandardObject
578
-
579
- NAVIGATION = :Navigation
580
- EVENT = :Event
299
+ #
300
+ # Text annotation
301
+ #
302
+ class Text < Annotation
303
+ include Markup
304
+
305
+ module TextName
306
+ COMMENT = :C
307
+ KEY = :K
308
+ NOTE = :N
309
+ HELP = :H
310
+ NEWPARAGRAPH = :NP
311
+ PARAGRAPH = :P
312
+ INSERT = :I
313
+ end
314
+
315
+ field :Subtype, :Type => Name, :Default => :Text, :Required => true
316
+ field :Open, :Type => Boolean, :Default => false
317
+ field :Name, :Type => Name, :Default => TextName::NOTE
318
+ field :State, :Type => String, :Version => "1.5"
319
+ field :StateModel, :Type => String, :Version => "1.5"
320
+
321
+ def pre_build
322
+ model = self.StateModel
323
+ state = self.State
324
+
325
+ case model
326
+ when "Marked"
327
+ self.State = "Unmarked" if state.nil?
328
+ when "Review"
329
+ self.State = "None" if state.nil?
330
+ end
331
+
332
+ super
333
+ end
334
+ end
581
335
 
582
- field :Type, :Type => Name, :Default => :CuePoint, :Version => "1.7", :ExtensionLevel => 3
583
- field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
584
- field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3, :Required => true
585
- field :Time, :Type => Number, :Version => "1.7", :ExtensionLevel => 3, :Required => true
586
- field :A, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3, :Required => true
587
- end
588
- end
336
+ #
337
+ # FreeText Annotation
338
+ #
339
+ class FreeText < Annotation
340
+ include Markup
341
+
342
+ module Intent
343
+ FREETEXT = :FreeText
344
+ FREETEXTCALLOUT = :FreeTextCallout
345
+ FREETEXTTYPEWRITER = :FreeTextTypeWriter
346
+ end
347
+
348
+ field :Subtype, :Type => Name, :Default => :FreeText, :Required => true
349
+ field :DA, :Type => String, :Default => "/F1 10 Tf 0 g", :Required => true
350
+ field :Q, :Type => Integer, :Default => Field::TextAlign::LEFT, :Version => "1.4"
351
+ field :RC, :Type => [String, Stream], :Version => "1.5"
352
+ field :DS, :Type => String, :Version => "1.5"
353
+ field :CL, :Type => Array.of(Number), :Version => "1.6"
354
+ field :IT, :Type => Name, :Default => Intent::FREETEXT, :Version => "1.6"
355
+ field :BE, :Type => BorderEffect, :Version => "1.6"
356
+ field :RD, :Type => Rectangle, :Version => "1.6"
357
+ field :BS, :Type => BorderStyle, :Version => "1.6"
358
+ field :LE, :Type => Name, :Default => :None, :Version => "1.6"
359
+ end
589
360
 
590
- #
591
- # Class representing a widget Annotation.
592
- # Interactive forms use widget annotations to represent the appearance of fields and to manage user interactions.
593
- #
594
- class Widget < Annotation
595
-
596
- include Field
597
- include Triggerable
598
-
599
- module Highlight
600
- # No highlighting
601
- NONE = :N
602
-
603
- # Invert the contents of the annotation rectangle.
604
- INVERT = :I
605
-
606
- # Invert the annotation’s border.
607
- OUTLINE = :O
608
-
609
- # Display the annotation as if it were being pushed below the surface of the page
610
- PUSH = :P
611
-
612
- # Same as P.
613
- TOGGLE = :T
614
-
615
- end
616
-
617
- field :Subtype, :Type => Name, :Default => :Widget, :Required => true
618
- field :H, :Type => Name, :Default => Highlight::INVERT
619
- field :MK, :Type => Dictionary
620
- field :A, :Type => Dictionary, :Version => "1.1"
621
- field :AA, :Type => Dictionary, :Version => "1.2"
622
- field :BS, :Type => Dictionary, :Version => "1.2"
623
-
624
- def onActivate(action)
625
-
626
- unless action.is_a?(Action)
627
- raise TypeError, "An Action object must be passed."
361
+ #
362
+ # Class representing an link annotation.
363
+ #
364
+ class Link < Annotation
365
+
366
+ #
367
+ # The annotations highlighting mode.
368
+ # The visual effect to be used when the mouse button is pressed or held down inside its active area.
369
+ #
370
+ module Highlight
371
+ # No highlighting
372
+ NONE = :N
373
+
374
+ # Invert the contents of the annotation rectangle.
375
+ INVERT = :I
376
+
377
+ # Invert the annotations border.
378
+ OUTLINE = :O
379
+
380
+ # Display the annotation as if it were being pushed below the surface of the page
381
+ PUSH = :P
382
+ end
383
+
384
+ field :Subtype, :Type => Name, :Default => :Link, :Required => true
385
+ field :A, :Type => Action, :Version => "1.1"
386
+ field :Dest, :Type => [ Destination, Name, String ]
387
+ field :H, :Type => Name, :Default => Highlight::INVERT, :Version => "1.2"
388
+ field :PA, :Type => Dictionary, :Version => "1.3"
389
+ field :QuadPoints, :Type => Array.of(Number), :Version => "1.6"
390
+ field :BS, :Type => BorderStyle, :Version => "1.6"
628
391
  end
629
-
630
- self.A = action
631
- end
632
392
 
633
- class Button < Widget
634
-
635
- module Flags
636
- NOTOGGLETOOFF = 1 << 14
637
- RADIO = 1 << 15
638
- PUSHBUTTON = 1 << 16
639
- RADIOSINUNISON = 1 << 26
393
+ #
394
+ # Class representing a file attachment annotation.
395
+ #
396
+ class FileAttachment < Annotation
397
+ include Markup
398
+
399
+ # Icons to be displayed for file attachment.
400
+ module Icons
401
+ GRAPH = :Graph
402
+ PAPERCLIP = :Paperclip
403
+ PUSHPIN = :PushPin
404
+ TAG = :Tag
405
+ end
406
+
407
+ field :Subtype, :Type => Name, :Default => :FileAttachment, :Required => true
408
+ field :FS, :Type => FileSpec, :Required => true
409
+ field :Name, :Type => Name, :Default => Icons::PUSHPIN
640
410
  end
641
-
642
- field :FT, :Type => Name, :Default => Field::Type::BUTTON, :Required => true
643
-
644
- end
645
-
646
- class PushButton < Button
647
-
648
- def pre_build
649
-
650
- self.Ff ||= 0
651
- self.Ff |= Button::Flags::PUSHBUTTON
652
-
653
- super
411
+
412
+ #
413
+ # Class representing a screen Annotation.
414
+ # A screen annotation specifies a region of a page upon which media clips may be played. It also serves as an object from which actions can be triggered.
415
+ #
416
+ class Screen < Annotation
417
+ include Triggerable
418
+
419
+ field :Subtype, :Type => Name, :Default => :Screen, :Required => true
420
+ field :T, :Type => String
421
+ field :MK, :Type => AppearanceCharacteristics
422
+ field :A, :Type => Action, :Version => "1.1"
423
+ field :AA, :Type => AdditionalActions, :Version => "1.2"
654
424
  end
655
-
656
- end
657
-
658
- class CheckBox < Button
659
-
660
- def pre_build
425
+
426
+ class Sound < Annotation
427
+ include Markup
661
428
 
662
- self.Ff ||= 0
429
+ module Icons
430
+ SPEAKER = :Speaker
431
+ MIC = :Mic
432
+ end
433
+
434
+ field :Subtype, :Type => Name, :Default => :Sound, :Required => true
435
+ field :Sound, :Type => Stream, :Required => true
436
+ field :Name, :Type => Name, :Default => Icons::SPEAKER
437
+ end
438
+
439
+ class RichMedia < Annotation
663
440
 
664
- self.Ff &= ~Button::Flags::RADIO
665
- self.Ff &= ~Button::Flags::PUSHBUTTON
441
+ class Position < Dictionary
442
+ include StandardObject
443
+
444
+ NEAR = :Near
445
+ CENTER = :Center
446
+ FAR = :Far
447
+
448
+ field :Type, :Type => Name, :Default => :RichMediaPosition, :Version => "1.7", :ExtensionLevel => 3
449
+ field :HAlign, :Type => Name, :Default => FAR, :Version => "1.7", :ExtensionLevel => 3
450
+ field :VAlign, :Type => Name, :Default => NEAR, :Version => "1.7", :ExtensionLevel => 3
451
+ field :HOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
452
+ field :VOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
453
+ end
454
+
455
+ class Window < Dictionary
456
+ include StandardObject
457
+
458
+ field :Type, :Type => Name, :Default => :RichMediaWindow, :Version => "1.7", :ExtensionLevel => 3
459
+ field :Width, :Type => Dictionary, :Default => {:Default => 288, :Max => 576, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
460
+ field :Height, :Type => Dictionary, :Default => {:Default => 216, :Max => 432, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
461
+ field :Position, :Type => Position, :Version => "1.7", :ExtensionLevel => 3
462
+ end
463
+
464
+ class Presentation < Dictionary
465
+ include StandardObject
466
+
467
+ WINDOWED = :Windowed
468
+ EMBEDDED = :Embedded
469
+
470
+ field :Type, :Type => Name, :Default => :RichMediaPresentation, :Version => "1.7", :ExtensionLevel => 3
471
+ field :Style, :Type => Name, :Default => EMBEDDED, :Version => "1.7", :ExtensionLevel => 3
472
+ field :Window, :Type => Window, :Version => "1.7", :ExtensionLevel => 3
473
+ field :Transparent, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
474
+ field :NavigationPane, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
475
+ field :Toolbar, :Type => Boolean, :Version => "1.7", :ExtensionLevel => 3
476
+ field :PassContextClick, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
477
+ end
478
+
479
+ class Animation < Dictionary
480
+ include StandardObject
481
+
482
+ NONE = :None
483
+ LINEAR = :Linear
484
+ OSCILLATING = :Oscillating
485
+
486
+ field :Type, :Type => Name, :Default => :RichMediaAnimation, :Version => "1.7", :ExtensionLevel => 3
487
+ field :Subtype, :Type => Name, :Default => NONE, :Version => "1.7", :ExtensionLevel => 3
488
+ field :PlayCount, :Type => Integer, :Default => -1, :Version => "1.7", :ExtensionLevel => 3
489
+ field :Speed, :Type => Number, :Default => 1, :Version => "1.7", :ExtensionLevel => 3
490
+ end
491
+
492
+ class Activation < Dictionary
493
+ include StandardObject
494
+
495
+ USER_ACTION = :XA
496
+ PAGE_OPEN = :PO
497
+ PAGE_VISIBLE = :PV
498
+
499
+ field :Type, :Type => Name, :Default => :RichMediaActivation, :Version => "1.7", :ExtensionLevel => 3
500
+ field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
501
+ field :Animation, :Type => Animation, :Version => "1.7", :ExtensionLevel => 3
502
+ field :View, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
503
+ field :Configuration, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
504
+ field :Presentation, :Type => Presentation, :Version => "1.7", :ExtensionLevel => 3
505
+ field :Scripts, :Type => Array.of(FileSpec), :Version => "1.7", :ExtensionLevel => 3
506
+ end
507
+
508
+ class Deactivation < Dictionary
509
+ include StandardObject
510
+
511
+ USER_ACTION = :XD
512
+ PAGE_CLOSE = :PC
513
+ PAGE_INVISIBLE = :PV
514
+
515
+ field :Type, :Type => Name, :Default => :RichMediaDeactivation, :Version => "1.7", :ExtensionLevel => 3
516
+ field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
517
+ end
518
+
519
+ class Settings < Dictionary
520
+ include StandardObject
521
+
522
+ field :Type, :Type => Name, :Default => :RichMediaSettings, :Version => "1.7", :ExtensionLevel => 3
523
+ field :Activation, :Type => Activation, :Version => "1.7", :ExtensionLevel => 3
524
+ field :Deactivation, :Type => Deactivation, :Version => "1.7", :ExtensionLevel => 3
525
+ end
666
526
 
667
- super
527
+ class CuePoint < Dictionary
528
+ include StandardObject
529
+
530
+ NAVIGATION = :Navigation
531
+ EVENT = :Event
532
+
533
+ field :Type, :Type => Name, :Default => :CuePoint, :Version => "1.7", :ExtensionLevel => 3
534
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
535
+ field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3, :Required => true
536
+ field :Time, :Type => Number, :Version => "1.7", :ExtensionLevel => 3, :Required => true
537
+ field :A, :Type => Action, :Version => "1.7", :ExtensionLevel => 3, :Required => true
538
+ end
539
+
540
+ class Parameters < Dictionary
541
+ include StandardObject
542
+
543
+ module Binding
544
+ NONE = :None
545
+ FOREGROUND = :Foreground
546
+ BACKGROUND = :Background
547
+ MATERIAL = :Material
548
+ end
549
+
550
+ field :Type, :Type => Name, :Default => :RichMediaParams, :Version => "1.7", :ExtensionLevel => 3
551
+ field :FlashVars, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
552
+ field :Binding, :Type => Name, :Default => Binding::NONE, :Version => "1.7", :ExtensionLevel => 3
553
+ field :BindingMaterialName, :Type => String, :Version => "1.7", :ExtensionLevel => 3
554
+ field :CuePoints, :Type => Array.of(CuePoint), :Default => [], :Version => "1.7", :ExtensionLevel => 3
555
+ field :Settings, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
556
+ end
557
+
558
+ class Instance < Dictionary
559
+ include StandardObject
560
+
561
+ U3D = :"3D"
562
+ FLASH = :Flash
563
+ SOUND = :Sound
564
+ VIDEO = :Video
565
+
566
+ field :Type, :Type => Name, :Default => :RichMediaInstance, :Version => "1.7", :ExtensionLevel => 3
567
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
568
+ field :Params, :Type => Parameters, :Version => "1.7", :ExtensionLevel => 3
569
+ field :Asset, :Type => FileSpec, :Version => "1.7", :ExtensionLevel => 3
570
+ end
571
+
572
+ class Configuration < Dictionary
573
+ include StandardObject
574
+
575
+ U3D = :"3D"
576
+ FLASH = :Flash
577
+ SOUND = :Sound
578
+ VIDEO = :Video
579
+
580
+ field :Type, :Type => Name, :Default => :RichMediaConfiguration, :Version => "1.7", :ExtensionLevel => 3
581
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
582
+ field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3
583
+ field :Instances, :Type => Array.of(Instance), :Version => "1.7", :ExtensionLevel => 3
584
+ end
585
+
586
+ class Content < Dictionary
587
+ include StandardObject
588
+
589
+ field :Type, :Type => Name, :Default => :RichMediaContent, :Version => "1.7", :ExtensionLevel => 3
590
+ field :Assets, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
591
+ field :Configurations, :Type => Array.of(Configuration), :Version => "1.7", :ExtensionLevel => 3
592
+ field :Views, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
593
+ end
594
+
595
+ #
596
+ # Fields of the RichMedia Annotation.
597
+ #
598
+ field :Subtype, :Type => Name, :Default => :RichMedia, :Version => "1.7", :ExtensionLevel => 3, :Required => true
599
+ field :RichMediaSettings, :Type => Settings, :Version => "1.7", :ExtensionLevel => 3
600
+ field :RichMediaContent, :Type => Content, :Version => "1.7", :ExtensionLevel => 3, :Required => true
668
601
  end
669
-
670
- end
671
-
672
- class Radio < Button
673
-
674
- def pre_build
602
+
603
+ # Added in ExtensionLevel 3.
604
+ class Projection < Annotation; end
605
+
606
+ #
607
+ # Class representing a widget Annotation.
608
+ # Interactive forms use widget annotations to represent the appearance of fields and to manage user interactions.
609
+ #
610
+ class Widget < Annotation
611
+ include Field
612
+ include Triggerable
613
+
614
+ module Highlight
615
+ # No highlighting
616
+ NONE = :N
617
+
618
+ # Invert the contents of the annotation rectangle.
619
+ INVERT = :I
620
+
621
+ # Invert the annotations border.
622
+ OUTLINE = :O
623
+
624
+ # Display the annotation as if it were being pushed below the surface of the page
625
+ PUSH = :P
626
+
627
+ # Same as P.
628
+ TOGGLE = :T
629
+ end
630
+
631
+ field :Subtype, :Type => Name, :Default => :Widget, :Required => true
632
+ field :H, :Type => Name, :Default => Highlight::INVERT
633
+ field :MK, :Type => AppearanceCharacteristics
634
+ field :A, :Type => Action, :Version => "1.1"
635
+ field :AA, :Type => AdditionalActions, :Version => "1.2"
636
+ field :BS, :Type => BorderStyle, :Version => "1.2"
675
637
 
676
- self.Ff ||= 0
638
+ def onActivate(action)
639
+ unless action.is_a?(Action)
640
+ raise TypeError, "An Action object must be passed."
641
+ end
642
+
643
+ self.A = action
644
+ end
645
+
646
+ class Button < Widget
647
+
648
+ module Flags
649
+ NOTOGGLETOOFF = 1 << 14
650
+ RADIO = 1 << 15
651
+ PUSHBUTTON = 1 << 16
652
+ RADIOSINUNISON = 1 << 26
653
+ end
654
+
655
+ field :FT, :Type => Name, :Default => Field::Type::BUTTON, :Required => true
656
+ end
677
657
 
678
- self.Ff &= ~Button::Flags::PUSHBUTTON
679
- self.Ff |= Button::Flags::RADIO
658
+ class PushButton < Button
659
+
660
+ def pre_build
661
+ self.Ff ||= 0
662
+ self.Ff |= Button::Flags::PUSHBUTTON
663
+
664
+ super
665
+ end
666
+ end
680
667
 
681
- super
682
- end
683
-
684
- end
685
-
686
- class Text < Widget
687
-
688
- module Flags
689
- MULTILINE = 1 << 12
690
- PASSWORD = 1 << 13
691
- FILESELECT = 1 << 20
692
- DONOTSPELLCHECK = 1 << 22
693
- DONOTSCROLL = 1 << 23
694
- COMB = 1 << 24
695
- RICHTEXT = 1 << 25
696
- end
697
-
698
- field :FT, :Type => Name, :Default => Field::Type::TEXT, :Required => true
699
- field :MaxLen, :Type => Integer
700
-
701
- end
702
-
703
- class Choice < Widget
704
-
705
- module Flags
706
- COMBO = 1 << 17
707
- EDIT = 1 << 18
708
- SORT = 1 << 19
709
- MULTISELECT = 1 << 21
710
- DONOTSPELLCHECK = 1 << 22
711
- COMMITONSELCHANGE = 1 << 26
712
- end
713
-
714
- field :FT, :Type => Name, :Default => Field::Type::CHOICE, :Required => true
715
- field :Opt, :Type => Array
716
- field :TI, :Type => Integer, :Default => 0
717
- field :I, :Type => Array, :Version => "1.4"
718
-
719
- end
720
-
721
- class ComboBox < Choice
722
-
723
- def pre_build
668
+ class CheckBox < Button
669
+
670
+ def pre_build
671
+ self.Ff ||= 0
672
+
673
+ self.Ff &= ~Button::Flags::RADIO
674
+ self.Ff &= ~Button::Flags::PUSHBUTTON
675
+
676
+ super
677
+ end
678
+ end
724
679
 
725
- self.Ff ||= 0
726
- self.Ff |= Choice::Flags::COMBO
680
+ class Radio < Button
681
+
682
+ def pre_build
683
+ self.Ff ||= 0
684
+
685
+ self.Ff &= ~Button::Flags::PUSHBUTTON
686
+ self.Ff |= Button::Flags::RADIO
687
+
688
+ super
689
+ end
690
+ end
727
691
 
728
- super
729
- end
730
-
731
- end
732
-
733
- class ListBox < Choice
734
-
735
- def pre_build
692
+ class Text < Widget
693
+ module Flags
694
+ MULTILINE = 1 << 12
695
+ PASSWORD = 1 << 13
696
+ FILESELECT = 1 << 20
697
+ DONOTSPELLCHECK = 1 << 22
698
+ DONOTSCROLL = 1 << 23
699
+ COMB = 1 << 24
700
+ RICHTEXT = 1 << 25
701
+ end
702
+
703
+ field :FT, :Type => Name, :Default => Field::Type::TEXT, :Required => true
704
+ field :MaxLen, :Type => Integer
705
+ end
706
+
707
+ class Choice < Widget
708
+ module Flags
709
+ COMBO = 1 << 17
710
+ EDIT = 1 << 18
711
+ SORT = 1 << 19
712
+ MULTISELECT = 1 << 21
713
+ DONOTSPELLCHECK = 1 << 22
714
+ COMMITONSELCHANGE = 1 << 26
715
+ end
716
+
717
+ field :FT, :Type => Name, :Default => Field::Type::CHOICE, :Required => true
718
+ field :Opt, :Type => Array
719
+ field :TI, :Type => Integer, :Default => 0
720
+ field :I, :Type => Array, :Version => "1.4"
721
+ end
736
722
 
737
- self.Ff ||= 0
738
- self.Ff &= ~Choice::Flags::COMBO
723
+ class ComboBox < Choice
724
+
725
+ def pre_build
726
+ self.Ff ||= 0
727
+ self.Ff |= Choice::Flags::COMBO
728
+
729
+ super
730
+ end
731
+ end
739
732
 
733
+ class ListBox < Choice
734
+
735
+ def pre_build
736
+ self.Ff ||= 0
737
+ self.Ff &= ~Choice::Flags::COMBO
738
+
739
+ super
740
+ end
741
+ end
742
+
743
+ class Signature < Widget
744
+ field :FT, :Type => Name, :Default => Field::Type::SIGNATURE
745
+ field :Lock, :Type => SignatureLock, :Version => "1.5"
746
+ field :SV, :Type => SignatureSeedValue, :Version => "1.5"
747
+ end
740
748
  end
741
-
742
- end
743
-
744
- class Signature < Widget
745
-
746
- field :FT, :Type => Name, :Default => Field::Type::SIGNATURE
747
- field :Lock, :Type => Dictionary, :Version => "1.5"
748
- field :SV, :Type => Dictionary, :Version => "1.5"
749
-
750
- end
751
-
752
- end
753
-
754
- #
755
- # Class representing additional actions which can be associated with an annotation having an AA field.
756
- #
757
- class AdditionalActions < Dictionary
758
-
759
- include StandardObject
760
-
761
- field :E, :Type => Dictionary, :Version => "1.2" # Mouse Enter
762
- field :X, :Type => Dictionary, :Version => "1.2" # Mouse Exit
763
- field :D, :Type => Dictionary, :Version => "1.2" # Mouse Down
764
- field :U, :Type => Dictionary, :Version => "1.2" # Mouse Up
765
- field :Fo, :Type => Dictionary, :Version => "1.2" # Focus
766
- field :Bl, :Type => Dictionary, :Version => "1.2" # Blur
767
- field :PO, :Type => Dictionary, :Version => "1.2" # Page Open
768
- field :PC, :Type => Dictionary, :Version => "1.2" # Page Close
769
- field :PV, :Type => Dictionary, :Version => "1.2" # Page Visible
770
- field :PI, :Type => Dictionary, :Version => "1.2" # Page Invisible
771
-
772
749
  end
773
750
 
774
- end
775
-
776
751
  end