origami 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/COPYING.LESSER +165 -0
  2. data/README +77 -0
  3. data/VERSION +1 -0
  4. data/bin/config/pdfcop.conf.yml +237 -0
  5. data/bin/gui/about.rb +46 -0
  6. data/bin/gui/config.rb +132 -0
  7. data/bin/gui/file.rb +385 -0
  8. data/bin/gui/hexdump.rb +74 -0
  9. data/bin/gui/hexview.rb +91 -0
  10. data/bin/gui/imgview.rb +72 -0
  11. data/bin/gui/menu.rb +392 -0
  12. data/bin/gui/properties.rb +132 -0
  13. data/bin/gui/signing.rb +635 -0
  14. data/bin/gui/textview.rb +107 -0
  15. data/bin/gui/treeview.rb +409 -0
  16. data/bin/gui/walker.rb +282 -0
  17. data/bin/gui/xrefs.rb +79 -0
  18. data/bin/pdf2graph +121 -0
  19. data/bin/pdf2ruby +353 -0
  20. data/bin/pdfcocoon +104 -0
  21. data/bin/pdfcop +455 -0
  22. data/bin/pdfdecompress +104 -0
  23. data/bin/pdfdecrypt +95 -0
  24. data/bin/pdfencrypt +112 -0
  25. data/bin/pdfextract +221 -0
  26. data/bin/pdfmetadata +123 -0
  27. data/bin/pdfsh +13 -0
  28. data/bin/pdfwalker +7 -0
  29. data/bin/shell/.irbrc +104 -0
  30. data/bin/shell/console.rb +136 -0
  31. data/bin/shell/hexdump.rb +83 -0
  32. data/origami.rb +36 -0
  33. data/origami/3d.rb +239 -0
  34. data/origami/acroform.rb +321 -0
  35. data/origami/actions.rb +299 -0
  36. data/origami/adobe/fdf.rb +259 -0
  37. data/origami/adobe/ppklite.rb +489 -0
  38. data/origami/annotations.rb +775 -0
  39. data/origami/array.rb +187 -0
  40. data/origami/boolean.rb +101 -0
  41. data/origami/catalog.rb +486 -0
  42. data/origami/destinations.rb +213 -0
  43. data/origami/dictionary.rb +188 -0
  44. data/origami/docmdp.rb +96 -0
  45. data/origami/encryption.rb +1293 -0
  46. data/origami/export.rb +283 -0
  47. data/origami/file.rb +222 -0
  48. data/origami/filters.rb +250 -0
  49. data/origami/filters/ascii.rb +189 -0
  50. data/origami/filters/ccitt.rb +515 -0
  51. data/origami/filters/crypt.rb +47 -0
  52. data/origami/filters/dct.rb +61 -0
  53. data/origami/filters/flate.rb +112 -0
  54. data/origami/filters/jbig2.rb +63 -0
  55. data/origami/filters/jpx.rb +53 -0
  56. data/origami/filters/lzw.rb +195 -0
  57. data/origami/filters/predictors.rb +276 -0
  58. data/origami/filters/runlength.rb +117 -0
  59. data/origami/font.rb +209 -0
  60. data/origami/functions.rb +93 -0
  61. data/origami/graphics.rb +33 -0
  62. data/origami/graphics/colors.rb +191 -0
  63. data/origami/graphics/instruction.rb +126 -0
  64. data/origami/graphics/path.rb +154 -0
  65. data/origami/graphics/patterns.rb +180 -0
  66. data/origami/graphics/state.rb +164 -0
  67. data/origami/graphics/text.rb +224 -0
  68. data/origami/graphics/xobject.rb +493 -0
  69. data/origami/header.rb +90 -0
  70. data/origami/linearization.rb +318 -0
  71. data/origami/metadata.rb +114 -0
  72. data/origami/name.rb +170 -0
  73. data/origami/null.rb +75 -0
  74. data/origami/numeric.rb +188 -0
  75. data/origami/obfuscation.rb +233 -0
  76. data/origami/object.rb +527 -0
  77. data/origami/outline.rb +59 -0
  78. data/origami/page.rb +559 -0
  79. data/origami/parser.rb +268 -0
  80. data/origami/parsers/fdf.rb +45 -0
  81. data/origami/parsers/pdf.rb +27 -0
  82. data/origami/parsers/pdf/linear.rb +113 -0
  83. data/origami/parsers/ppklite.rb +86 -0
  84. data/origami/pdf.rb +1144 -0
  85. data/origami/reference.rb +113 -0
  86. data/origami/signature.rb +474 -0
  87. data/origami/stream.rb +575 -0
  88. data/origami/string.rb +416 -0
  89. data/origami/trailer.rb +173 -0
  90. data/origami/webcapture.rb +87 -0
  91. data/origami/xfa.rb +3027 -0
  92. data/origami/xreftable.rb +447 -0
  93. data/templates/patterns.rb +66 -0
  94. data/templates/widgets.rb +173 -0
  95. data/templates/xdp.rb +92 -0
  96. data/tests/dataset/test.dummycrt +28 -0
  97. data/tests/dataset/test.dummykey +27 -0
  98. data/tests/tc_actions.rb +32 -0
  99. data/tests/tc_annotations.rb +85 -0
  100. data/tests/tc_pages.rb +37 -0
  101. data/tests/tc_pdfattach.rb +24 -0
  102. data/tests/tc_pdfencrypt.rb +110 -0
  103. data/tests/tc_pdfnew.rb +32 -0
  104. data/tests/tc_pdfparse.rb +98 -0
  105. data/tests/tc_pdfsig.rb +37 -0
  106. data/tests/tc_streams.rb +129 -0
  107. data/tests/ts_pdf.rb +45 -0
  108. metadata +193 -0
@@ -0,0 +1,775 @@
1
+ =begin
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@security-labs.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/>.
23
+
24
+ =end
25
+
26
+ module Origami
27
+
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, :Default => :Text, :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
57
+
58
+ def set_rollover_appearance(apstm)
59
+ self.AP ||= AppearanceDictionary.new
60
+ self.AP[:R] = apstm
61
+
62
+ self
63
+ end
64
+
65
+ def set_down_appearance(apstm)
66
+ self.AP ||= AppearanceStream.new
67
+ self.AP[:D] = apstm
68
+
69
+ self
70
+ end
71
+
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
132
+
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."
140
+ end
141
+
142
+ self.AA ||= AdditionalActions.new
143
+ self.AA.PC = action
144
+ end
145
+
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."
158
+ 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
+
201
+ include StandardObject
202
+
203
+ field :N, :Type => [ Stream, Dictionary ], :Required => true
204
+ field :R, :Type => [ Stream, Dictionary ]
205
+ field :D, :Type => [ Stream, Dictionary ]
206
+
207
+ end
208
+
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
220
+
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 ]
225
+
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
255
+
256
+ class Shape < Annotation
257
+
258
+ include Markup
259
+
260
+ field :Subtype, :Type => Name, :Default => :Square, :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
+ end
270
+
271
+ class Circle < Shape
272
+
273
+ field :Subtype, :Type => Name, :Default => :Circle, :Required => true
274
+
275
+ end
276
+
277
+ #
278
+ # Text annotation
279
+ #
280
+ class Text < Annotation
281
+
282
+ include Markup
283
+
284
+ module TextName
285
+ COMMENT = :C
286
+ KEY = :K
287
+ NOTE = :N
288
+ HELP = :H
289
+ NEWPARAGRAPH = :NP
290
+ PARAGRAPH = :P
291
+ INSERT = :I
292
+ end
293
+
294
+ field :Subtype, :Type => Name, :Default => :Text, :Required => true
295
+ field :Open, :Type => Boolean, :Default => false
296
+ field :Name, :Type => Name, :Default => TextName::NOTE
297
+ field :State, :Type => String, :Version => "1.5"
298
+ field :StateModel, :Type => String, :Version => "1.5"
299
+
300
+ def pre_build
301
+
302
+ model = self.StateModel
303
+ state = self.State
304
+
305
+ case model
306
+ when "Marked"
307
+ state = "Unmarked" if state.nil?
308
+ when "Review"
309
+ state = "None" if state.nil?
310
+ end
311
+
312
+ super
313
+ end
314
+
315
+ end
316
+
317
+ #
318
+ # FreeText Annotation
319
+ #
320
+ class FreeText < Annotation
321
+
322
+ include Markup
323
+
324
+ module Intent
325
+ FREETEXT = :FreeText
326
+ FREETEXTCALLOUT = :FreeTextCallout
327
+ FREETEXTTYPEWRITER = :FreeTextTypeWriter
328
+ end
329
+
330
+ field :Subtype, :Type => Name, :Default => :FreeText, :Required => true
331
+ field :DA, :Type => String, :Default => "/F1 10 Tf 0 g", :Required => true
332
+ field :Q, :Type => Integer, :Default => Field::TextAlign::LEFT, :Version => "1.4"
333
+ field :RC, :Type => [String, Stream], :Version => "1.5"
334
+ field :DS, :Type => String, :Version => "1.5"
335
+ field :CL, :Type => Array, :Version => "1.6"
336
+ field :IT, :Type => Name, :Default => Intent::FREETEXT, :Version => "1.6"
337
+ field :BE, :Type => Dictionary, :Version => "1.6"
338
+ field :RD, :Type => Array, :Version => "1.6"
339
+ field :BS, :Type => Dictionary, :Version => "1.6"
340
+ field :LE, :Type => Name, :Default => :None, :Version => "1.6"
341
+
342
+ end
343
+
344
+ #
345
+ # Class representing an link annotation.
346
+ #
347
+ class Link < Annotation
348
+
349
+ #
350
+ # The annotation�s highlighting mode, the visual effect to be used when the mouse button is pressed or held down inside its active area.
351
+ #
352
+ module Highlight
353
+ # No highlighting
354
+ NONE = :N
355
+
356
+ # Invert the contents of the annotation rectangle.
357
+ INVERT = :I
358
+
359
+ # Invert the annotation�s border.
360
+ OUTLINE = :O
361
+
362
+ # Display the annotation as if it were being pushed below the surface of the page
363
+ PUSH = :P
364
+ end
365
+
366
+ field :Subtype, :Type => Name, :Default => :Link, :Required => true
367
+ field :A, :Type => Dictionary, :Version => "1.1"
368
+ field :Dest, :Type => [ Array, Name, ByteString ]
369
+ field :H, :Type => Name, :Default => Highlight::INVERT, :Version => "1.2"
370
+ field :AP, :Type => Dictionary, :Version => "1.3"
371
+ field :QuadPoints, :Type => Array, :Version => "1.6"
372
+
373
+ end
374
+
375
+ #
376
+ # Class representing a file attachment annotation.
377
+ #
378
+ class FileAttachment < Annotation
379
+
380
+ include Markup
381
+
382
+ # Icons to be displayed for file attachment.
383
+ module Icons
384
+ GRAPH = :Graph
385
+ PAPERCLIP = :Paperclip
386
+ PUSHPIN = :PushPin
387
+ TAG = :Tag
388
+ end
389
+
390
+ field :Subtype, :Type => Name, :Default => :FileAttachment, :Required => true
391
+ field :FS, :Type => Dictionary, :Required => true
392
+ field :Name, :Type => Name, :Default => Icons::PUSHPIN
393
+
394
+ end
395
+
396
+ #
397
+ # Class representing a screen Annotation.
398
+ # 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.
399
+ #
400
+ class Screen < Annotation
401
+
402
+ include Triggerable
403
+
404
+ field :Subtype, :Type => Name, :Default => :Screen, :Required => true
405
+ field :T, :Type => String
406
+ field :MK, :Type => Dictionary
407
+ field :A, :Type => Dictionary, :Version => "1.1"
408
+ field :AA, :Type => Dictionary, :Version => "1.2"
409
+
410
+ end
411
+
412
+
413
+ class Sound < Annotation
414
+
415
+ include Markup
416
+
417
+ module Icons
418
+ SPEAKER = :Speaker
419
+ MIC = :Mic
420
+ end
421
+
422
+ field :Subtype, :Type => Name, :Default => :Sound, :Required => true
423
+ field :Sound, :Type => Stream, :Required => true
424
+ field :Name, :Type => Name, :Default => Icons::SPEAKER
425
+
426
+ end
427
+
428
+ class RichMedia < Annotation
429
+
430
+ field :Subtype, :Type => Name, :Default => :RichMedia, :Version => "1.7", :ExtensionLevel => 3, :Required => true
431
+ field :RichMediaSettings, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
432
+ field :RichMediaContent, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3, :Required => true
433
+
434
+ class Settings < Dictionary
435
+ include StandardObject
436
+
437
+ field :Type, :Type => Name, :Default => :RichMediaSettings, :Version => "1.7", :ExtensionLevel => 3
438
+ field :Activation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
439
+ field :Deactivation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
440
+ end
441
+
442
+ class Activation < Dictionary
443
+ include StandardObject
444
+
445
+ USER_ACTION = :XA
446
+ PAGE_OPEN = :PO
447
+ PAGE_VISIBLE = :PV
448
+
449
+ field :Type, :Type => Name, :Default => :RichMediaActivation, :Version => "1.7", :ExtensionLevel => 3
450
+ field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
451
+ field :Animation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
452
+ field :View, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
453
+ field :Configuration, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
454
+ field :Presentation, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
455
+ field :Scripts, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
456
+ end
457
+
458
+ class Deactivation < Dictionary
459
+ include StandardObject
460
+
461
+ USER_ACTION = :XD
462
+ PAGE_CLOSE = :PC
463
+ PAGE_INVISIBLE = :PV
464
+
465
+ field :Type, :Type => Name, :Default => :RichMediaDeactivation, :Version => "1.7", :ExtensionLevel => 3
466
+ field :Condition, :Type => Name, :Default => USER_ACTION, :Version => "1.7", :ExtensionLevel => 3
467
+ end
468
+
469
+ class Animation < Dictionary
470
+ include StandardObject
471
+
472
+ NONE = :None
473
+ LINEAR = :Linear
474
+ OSCILLATING = :Oscillating
475
+
476
+ field :Type, :Type => Name, :Default => :RichMediaAnimation, :Version => "1.7", :ExtensionLevel => 3
477
+ field :Subtype, :Type => Name, :Default => NONE, :Version => "1.7", :ExtensionLevel => 3
478
+ field :PlayCount, :Type => Integer, :Default => -1, :Version => "1.7", :ExtensionLevel => 3
479
+ field :Speed, :Type => Number, :Default => 1, :Version => "1.7", :ExtensionLevel => 3
480
+ end
481
+
482
+ class Presentation < Dictionary
483
+ include StandardObject
484
+
485
+ WINDOWED = :Windowed
486
+ EMBEDDED = :Embedded
487
+
488
+ field :Type, :Type => Name, :Default => :RichMediaPresentation, :Version => "1.7", :ExtensionLevel => 3
489
+ field :Style, :Type => Name, :Default => EMBEDDED, :Version => "1.7", :ExtensionLevel => 3
490
+ field :Window, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
491
+ field :Transparent, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
492
+ field :NavigationPane, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
493
+ field :Toolbar, :Type => Boolean, :Version => "1.7", :ExtensionLevel => 3
494
+ field :PassContextClick, :Type => Boolean, :Default => false, :Version => "1.7", :ExtensionLevel => 3
495
+ end
496
+
497
+ class Window < Dictionary
498
+ include StandardObject
499
+
500
+ field :Type, :Type => Name, :Default => :RichMediaWindow, :Version => "1.7", :ExtensionLevel => 3
501
+ field :Width, :Type => Dictionary, :Default => {:Default => 288, :Max => 576, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
502
+ field :Height, :Type => Dictionary, :Default => {:Default => 216, :Max => 432, :Min => 72}, :Version => "1.7", :ExtensionLevel => 3
503
+ field :Position, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
504
+ end
505
+
506
+ class Position < Dictionary
507
+ include StandardObject
508
+
509
+ NEAR = :Near
510
+ CENTER = :Center
511
+ FAR = :Far
512
+
513
+ field :Type, :Type => Name, :Default => :RichMediaPosition, :Version => "1.7", :ExtensionLevel => 3
514
+ field :HAlign, :Type => Name, :Default => FAR, :Version => "1.7", :ExtensionLevel => 3
515
+ field :VAlign, :Type => Name, :Default => NEAR, :Version => "1.7", :ExtensionLevel => 3
516
+ field :HOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
517
+ field :VOffset, :Type => Number, :Default => 18, :Version => "1.7", :ExtensionLevel => 3
518
+ end
519
+
520
+ class Content < Dictionary
521
+ include StandardObject
522
+
523
+ field :Type, :Type => Name, :Default => :RichMediaContent, :Version => "1.7", :ExtensionLevel => 3
524
+ field :Assets, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
525
+ field :Configurations, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
526
+ field :Views, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
527
+ end
528
+
529
+ class Configuration < Dictionary
530
+ include StandardObject
531
+
532
+ U3D = :"3D"
533
+ FLASH = :Flash
534
+ SOUND = :Sound
535
+ VIDEO = :Video
536
+
537
+ field :Type, :Type => Name, :Default => :RichMediaConfiguration, :Version => "1.7", :ExtensionLevel => 3
538
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
539
+ field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3
540
+ field :Instances, :Type => Array, :Version => "1.7", :ExtensionLevel => 3
541
+ end
542
+
543
+ class Instance < Dictionary
544
+ include StandardObject
545
+
546
+ U3D = :"3D"
547
+ FLASH = :Flash
548
+ SOUND = :Sound
549
+ VIDEO = :Video
550
+
551
+ field :Type, :Type => Name, :Default => :RichMediaInstance, :Version => "1.7", :ExtensionLevel => 3
552
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
553
+ field :Params, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
554
+ field :Asset, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3
555
+ end
556
+
557
+ class Parameters < Dictionary
558
+ include StandardObject
559
+
560
+ module Binding
561
+ NONE = :None
562
+ FOREGROUND = :Foreground
563
+ BACKGROUND = :Background
564
+ MATERIAL = :Material
565
+ end
566
+
567
+ field :Type, :Type => Name, :Default => :RichMediaParams, :Version => "1.7", :ExtensionLevel => 3
568
+ field :FlashVars, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
569
+ field :Binding, :Type => Name, :Default => Binding::NONE, :Version => "1.7", :ExtensionLevel => 3
570
+ field :BindingMaterialName, :Type => String, :Version => "1.7", :ExtensionLevel => 3
571
+ field :CuePoints, :Type => Array, :Default => [], :Version => "1.7", :ExtensionLevel => 3
572
+ field :Settings, :Type => [String, Stream], :Version => "1.7", :ExtensionLevel => 3
573
+ end
574
+
575
+ class CuePoint < Dictionary
576
+ include StandardObject
577
+
578
+ NAVIGATION = :Navigation
579
+ EVENT = :Event
580
+
581
+ field :Type, :Type => Name, :Default => :CuePoint, :Version => "1.7", :ExtensionLevel => 3
582
+ field :Subtype, :Type => Name, :Version => "1.7", :ExtensionLevel => 3
583
+ field :Name, :Type => String, :Version => "1.7", :ExtensionLevel => 3, :Required => true
584
+ field :Time, :Type => Number, :Version => "1.7", :ExtensionLevel => 3, :Required => true
585
+ field :A, :Type => Dictionary, :Version => "1.7", :ExtensionLevel => 3, :Required => true
586
+ end
587
+ end
588
+
589
+ #
590
+ # Class representing a widget Annotation.
591
+ # Interactive forms use widget annotations to represent the appearance of fields and to manage user interactions.
592
+ #
593
+ class Widget < Annotation
594
+
595
+ include Field
596
+ include Triggerable
597
+
598
+ module Highlight
599
+ # No highlighting
600
+ NONE = :N
601
+
602
+ # Invert the contents of the annotation rectangle.
603
+ INVERT = :I
604
+
605
+ # Invert the annotation�s border.
606
+ OUTLINE = :O
607
+
608
+ # Display the annotation as if it were being pushed below the surface of the page
609
+ PUSH = :P
610
+
611
+ # Same as P.
612
+ TOGGLE = :T
613
+
614
+ end
615
+
616
+ field :Subtype, :Type => Name, :Default => :Widget, :Required => true
617
+ field :H, :Type => Name, :Default => Highlight::INVERT
618
+ field :MK, :Type => Dictionary
619
+ field :A, :Type => Dictionary, :Version => "1.1"
620
+ field :AA, :Type => Dictionary, :Version => "1.2"
621
+ field :BS, :Type => Dictionary, :Version => "1.2"
622
+
623
+ def onActivate(action)
624
+
625
+ unless action.is_a?(Action)
626
+ raise TypeError, "An Action object must be passed."
627
+ end
628
+
629
+ self.A = action
630
+ end
631
+
632
+ class Button < Widget
633
+
634
+ module Flags
635
+ NOTOGGLETOOFF = 1 << 14
636
+ RADIO = 1 << 15
637
+ PUSHBUTTON = 1 << 16
638
+ RADIOSINUNISON = 1 << 26
639
+ end
640
+
641
+ field :FT, :Type => Name, :Default => Field::Type::BUTTON, :Required => true
642
+
643
+ end
644
+
645
+ class PushButton < Button
646
+
647
+ def pre_build
648
+
649
+ self.Ff ||= 0
650
+ self.Ff |= Button::Flags::PUSHBUTTON
651
+
652
+ super
653
+ end
654
+
655
+ end
656
+
657
+ class CheckBox < Button
658
+
659
+ def pre_build
660
+
661
+ self.Ff ||= 0
662
+
663
+ self.Ff &= ~Button::Flags::RADIO
664
+ self.Ff &= ~Button::Flags::PUSHBUTTON
665
+
666
+ super
667
+ end
668
+
669
+ end
670
+
671
+ class Radio < Button
672
+
673
+ def pre_build
674
+
675
+ self.Ff ||= 0
676
+
677
+ self.Ff &= ~Button::Flags::PUSHBUTTON
678
+ self.Ff |= Button::Flags::RADIO
679
+
680
+ super
681
+ end
682
+
683
+ end
684
+
685
+ class Text < Widget
686
+
687
+ module Flags
688
+ MULTILINE = 1 << 12
689
+ PASSWORD = 1 << 13
690
+ FILESELECT = 1 << 20
691
+ DONOTSPELLCHECK = 1 << 22
692
+ DONOTSCROLL = 1 << 23
693
+ COMB = 1 << 24
694
+ RICHTEXT = 1 << 25
695
+ end
696
+
697
+ field :FT, :Type => Name, :Default => Field::Type::TEXT, :Required => true
698
+ field :MaxLen, :Type => Integer
699
+
700
+ end
701
+
702
+ class Choice < Widget
703
+
704
+ module Flags
705
+ COMBO = 1 << 17
706
+ EDIT = 1 << 18
707
+ SORT = 1 << 19
708
+ MULTISELECT = 1 << 21
709
+ DONOTSPELLCHECK = 1 << 22
710
+ COMMITONSELCHANGE = 1 << 26
711
+ end
712
+
713
+ field :FT, :Type => Name, :Default => Field::Type::CHOICE, :Required => true
714
+ field :Opt, :Type => Array
715
+ field :TI, :Type => Integer, :Default => 0
716
+ field :I, :Type => Array, :Version => "1.4"
717
+
718
+ end
719
+
720
+ class ComboBox < Choice
721
+
722
+ def pre_build
723
+
724
+ self.Ff ||= 0
725
+ self.Ff |= Choice::Flags::COMBO
726
+
727
+ super
728
+ end
729
+
730
+ end
731
+
732
+ class ListBox < Choice
733
+
734
+ def pre_build
735
+
736
+ self.Ff ||= 0
737
+ self.Ff &= ~Choice::Flags::COMBO
738
+
739
+ end
740
+
741
+ end
742
+
743
+ class Signature < Widget
744
+
745
+ field :FT, :Type => Name, :Default => Field::Type::SIGNATURE
746
+ field :Lock, :Type => Dictionary, :Version => "1.5"
747
+ field :SV, :Type => Dictionary, :Version => "1.5"
748
+
749
+ end
750
+
751
+ end
752
+
753
+ #
754
+ # Class representing additional actions which can be associated with an annotation having an AA field.
755
+ #
756
+ class AdditionalActions < Dictionary
757
+
758
+ include StandardObject
759
+
760
+ field :E, :Type => Dictionary, :Version => "1.2" # Mouse Enter
761
+ field :X, :Type => Dictionary, :Version => "1.2" # Mouse Exit
762
+ field :D, :Type => Dictionary, :Version => "1.2" # Mouse Down
763
+ field :U, :Type => Dictionary, :Version => "1.2" # Mouse Up
764
+ field :Fo, :Type => Dictionary, :Version => "1.2" # Focus
765
+ field :Bl, :Type => Dictionary, :Version => "1.2" # Blur
766
+ field :PO, :Type => Dictionary, :Version => "1.2" # Page Open
767
+ field :PC, :Type => Dictionary, :Version => "1.2" # Page Close
768
+ field :PV, :Type => Dictionary, :Version => "1.2" # Page Visible
769
+ field :PI, :Type => Dictionary, :Version => "1.2" # Page Invisible
770
+
771
+ end
772
+
773
+ end
774
+
775
+ end