openxml-docx 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/Gemfile.lock +1 -1
  2. data/examples/booklet-printing +55 -0
  3. data/lib/openxml/docx/attribute_builder.rb +11 -5
  4. data/lib/openxml/docx/elements/absolute_position_tab.rb +1 -1
  5. data/lib/openxml/docx/elements/background.rb +16 -0
  6. data/lib/openxml/docx/elements/book_fold_printing.rb +1 -1
  7. data/lib/openxml/docx/elements/book_fold_reverse_printing.rb +1 -1
  8. data/lib/openxml/docx/elements/compatibility_setting.rb +10 -0
  9. data/lib/openxml/docx/elements/compatibility_settings.rb +15 -0
  10. data/lib/openxml/docx/elements/embed_bold.rb +2 -10
  11. data/lib/openxml/docx/elements/embed_bold_italic.rb +2 -10
  12. data/lib/openxml/docx/elements/embed_italic.rb +2 -10
  13. data/lib/openxml/docx/elements/embed_regular.rb +3 -3
  14. data/lib/openxml/docx/elements/embed_system_fonts.rb +1 -1
  15. data/lib/openxml/docx/elements/embed_true_type_fonts.rb +1 -1
  16. data/lib/openxml/docx/elements/even_and_odd_headers.rb +11 -0
  17. data/lib/openxml/docx/elements/family.rb +1 -1
  18. data/lib/openxml/docx/elements/markup_compatibility_choice.rb +1 -1
  19. data/lib/openxml/docx/elements/paragraph.rb +1 -0
  20. data/lib/openxml/docx/elements/save_subset_fonts.rb +1 -1
  21. data/lib/openxml/docx/elements/table_cell.rb +1 -0
  22. data/lib/openxml/docx/elements/textbox_content.rb +9 -0
  23. data/lib/openxml/docx/elements/word_processing_drawing_anchor.rb +6 -6
  24. data/lib/openxml/docx/elements/word_processing_drawing_inline.rb +16 -0
  25. data/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb +1 -1
  26. data/lib/openxml/docx/elements/word_processing_drawing_wrap_polygon.rb +1 -1
  27. data/lib/openxml/docx/elements/word_processing_shapes_body_properties.rb +12 -12
  28. data/lib/openxml/docx/elements/word_processing_shapes_nv_drawing_properties.rb +1 -1
  29. data/lib/openxml/docx/elements/word_processing_shapes_shape.rb +1 -2
  30. data/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb +1 -11
  31. data/lib/openxml/docx/elements/word_processing_shapes_textual_contents.rb +13 -0
  32. data/lib/openxml/{drawingml → docx}/elements/wordprocessing_shape_group.rb +1 -1
  33. data/lib/openxml/docx/package.rb +4 -3
  34. data/lib/openxml/docx/parts/document.rb +5 -0
  35. data/lib/openxml/docx/parts/header.rb +1 -1
  36. data/lib/openxml/docx/properties.rb +1 -0
  37. data/lib/openxml/docx/properties/border.rb +2 -2
  38. data/lib/openxml/docx/properties/columns.rb +8 -2
  39. data/lib/openxml/docx/properties/conditional_formatting.rb +12 -12
  40. data/lib/openxml/docx/properties/container_property.rb +10 -10
  41. data/lib/openxml/docx/properties/footer_references.rb +12 -0
  42. data/lib/openxml/docx/properties/frame.rb +1 -1
  43. data/lib/openxml/docx/properties/header_references.rb +12 -0
  44. data/lib/openxml/docx/properties/indentation.rb +5 -1
  45. data/lib/openxml/docx/properties/latent_styles.rb +4 -4
  46. data/lib/openxml/docx/properties/latent_styles_exception.rb +4 -4
  47. data/lib/openxml/docx/properties/section.rb +15 -0
  48. data/lib/openxml/docx/properties/table_border.rb +2 -2
  49. data/lib/openxml/docx/properties/table_cell_border.rb +2 -2
  50. data/lib/openxml/docx/properties/table_look.rb +7 -6
  51. data/lib/openxml/docx/properties/text_direction.rb +1 -1
  52. data/lib/openxml/docx/properties/transparent_container_property.rb +14 -0
  53. data/lib/openxml/docx/properties/vertical_merge.rb +14 -0
  54. data/lib/openxml/docx/section.rb +2 -0
  55. data/lib/openxml/docx/style.rb +18 -6
  56. data/lib/openxml/docx/version.rb +1 -1
  57. data/lib/openxml/drawingml/elements/blip_fill.rb +1 -1
  58. data/lib/openxml/drawingml/elements/children_extents.rb +14 -0
  59. data/lib/openxml/drawingml/elements/children_offset.rb +14 -0
  60. data/lib/openxml/drawingml/elements/graphic_frame_locks.rb +6 -6
  61. data/lib/openxml/drawingml/elements/no_autofit.rb +10 -0
  62. data/lib/openxml/drawingml/elements/no_fill.rb +1 -1
  63. data/lib/openxml/drawingml/elements/non_visual_drawing_properties.rb +1 -1
  64. data/lib/openxml/drawingml/elements/non_visual_picture_drawing_properties.rb +1 -1
  65. data/lib/openxml/drawingml/elements/non_visual_shape_drawing_properties.rb +12 -0
  66. data/lib/openxml/drawingml/elements/picture_locks.rb +11 -11
  67. data/lib/openxml/drawingml/elements/preset_text_warp.rb +25 -0
  68. data/lib/openxml/vml/elements/group.rb +17 -37
  69. data/lib/openxml/vml/elements/rectangle.rb +29 -62
  70. data/lib/openxml/vml/elements/rounded_rectangle.rb +29 -61
  71. data/spec/elements/absolute_position_tab_spec.rb +21 -15
  72. data/spec/elements/background_spec.rb +52 -0
  73. data/spec/elements/bidi_embed_spec.rb +12 -4
  74. data/spec/elements/bidi_override_spec.rb +12 -4
  75. data/spec/elements/break_spec.rb +12 -10
  76. data/spec/elements/compatibility_setting_spec.rb +41 -0
  77. data/spec/elements/compatibility_settings_spec.rb +8 -0
  78. data/spec/elements/content_part_spec.rb +2 -2
  79. data/spec/elements/control_spec.rb +5 -5
  80. data/spec/elements/deleted_text_spec.rb +2 -2
  81. data/spec/elements/drawingml/blip_fill_spec.rb +8 -3
  82. data/spec/elements/drawingml/extents_spec.rb +4 -4
  83. data/spec/elements/drawingml/head_end_spec.rb +16 -13
  84. data/spec/elements/drawingml/no_autofit_spec.rb +8 -0
  85. data/spec/elements/drawingml/non_visual_drawing_properties_spec.rb +6 -6
  86. data/spec/elements/drawingml/non_visual_shape_drawing_properties_spec.rb +24 -0
  87. data/spec/elements/drawingml/offset_spec.rb +14 -4
  88. data/spec/elements/drawingml/outline_spec.rb +20 -14
  89. data/spec/elements/drawingml/preset_geometry_spec.rb +1 -1
  90. data/spec/elements/drawingml/preset_text_warp_spec.rb +36 -0
  91. data/spec/elements/drawingml/shape_guide_spec.rb +7 -3
  92. data/spec/elements/drawingml/srgb_color_spec.rb +3 -4
  93. data/spec/elements/drawingml/tail_end_spec.rb +17 -14
  94. data/spec/elements/drawingml/transform_effect_spec.rb +48 -26
  95. data/spec/elements/markup_compatibility_choice_spec.rb +2 -2
  96. data/spec/elements/paragraph_spec.rb +25 -0
  97. data/spec/elements/symbol_spec.rb +4 -4
  98. data/spec/elements/text_spec.rb +1 -1
  99. data/spec/elements/textbox_content_spec.rb +8 -0
  100. data/spec/elements/vml/group_spec.rb +367 -375
  101. data/spec/elements/vml/rectangle_spec.rb +503 -513
  102. data/spec/elements/vml/rounded_rectangle_spec.rb +591 -463
  103. data/spec/elements/word_processing_drawing_effect_extent_spec.rb +32 -12
  104. data/spec/elements/word_processing_drawing_extent_spec.rb +4 -4
  105. data/spec/elements/word_processing_drawing_object_nv_properties_spec.rb +6 -6
  106. data/spec/elements/word_processing_drawing_simple_position_spec.rb +16 -6
  107. data/spec/elements/word_processing_shapes_body_properties_spec.rb +53 -44
  108. data/spec/elements/word_processing_shapes_shape_properties_spec.rb +6 -5
  109. data/spec/elements/word_processing_shapes_shape_spec.rb +2 -2
  110. data/spec/elements/word_processing_shapes_textual_content_spec.rb +23 -0
  111. data/spec/elements/{drawingml/wordprocessing_shape_group_spec.rb → wordprocessing_shape_group_spec.rb} +1 -1
  112. data/spec/properties/indentation_spec.rb +28 -0
  113. data/spec/properties/table_look_spec.rb +5 -0
  114. data/spec/properties/text_direction_spec.rb +5 -0
  115. data/spec/properties/vertical_merge_spec.rb +22 -0
  116. data/spec/support/data/elements/paragraph_with_section_properties_element.xml +12 -0
  117. data/spec/support/data/parts/empty_header_part.xml +1 -1
  118. data/spec/support/data/parts/header_with_children_part.xml +1 -1
  119. metadata +76 -27
  120. checksums.yaml +0 -7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openxml-docx (0.10.1)
4
+ openxml-docx (0.10.2)
5
5
  nokogiri
6
6
  openxml-package (>= 0.2.2)
7
7
 
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # require "rails" # workaround: openxml-package uses `extract_options!`
4
+ $:.push Dir.pwd + "/lib"
5
+ require "ox"
6
+ require "openxml/docx"
7
+
8
+ package = OpenXml::Docx::Package.new
9
+
10
+ include OpenXml::Docx::Elements
11
+
12
+ lorem_ipsum = [
13
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper arcu nunc, eget maximus mi elementum ut. Nulla facilisi. Morbi eget augue tristique, aliquet purus quis, mollis eros. Maecenas massa purus, vehicula vel tellus eget, feugiat cursus metus. Vivamus consequat leo leo. Quisque interdum gravida placerat. Praesent auctor vestibulum nisi, quis viverra diam luctus interdum. Vivamus eu massa non tortor gravida ultrices. Nulla dapibus porta ipsum, et dignissim metus ultricies accumsan. In hac habitasse platea dictumst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
14
+ "Integer dapibus ac velit finibus elementum. Curabitur vel lacus mauris. Quisque diam diam, commodo at consectetur at, consectetur ut orci. Suspendisse nec nulla eu quam ullamcorper dignissim. Morbi et ligula non dolor scelerisque commodo vel nec tortor. Integer molestie lobortis elementum. Aenean vehicula turpis nulla, in viverra ex lacinia ac. Nam consectetur ante id velit vehicula, a tincidunt ex auctor. Nunc sodales tempus tristique. Aliquam nunc risus, pretium at lorem in, varius accumsan est. Mauris vel dolor eget lectus auctor malesuada. Aenean interdum dignissim hendrerit. Nullam vulputate mi nec massa pretium, at maximus arcu sodales. Mauris vitae neque sit amet urna facilisis rutrum id et lacus. Aliquam pretium orci nec auctor interdum. Nulla egestas mauris turpis, vel accumsan sem volutpat quis.",
15
+ "Integer tristique magna eu tellus cursus gravida. Fusce scelerisque ipsum eu odio malesuada faucibus. Proin malesuada, purus id eleifend facilisis, massa diam pellentesque libero, ac semper nisl turpis vel eros. Donec faucibus faucibus lectus sed vehicula. Vivamus sed tempus dui. Aliquam volutpat risus bibendum blandit sollicitudin. Mauris vitae rhoncus ipsum. Morbi id tempus ex, et consectetur nibh. Curabitur massa leo, fringilla vel pulvinar non, convallis ac justo. Ut non lobortis ante, ut rutrum arcu. Duis laoreet varius orci non gravida. Phasellus luctus elementum nunc, malesuada congue lorem viverra maximus. Donec ornare rhoncus nibh faucibus congue. Nulla placerat eros eu elit auctor ultricies. Phasellus pretium accumsan bibendum.",
16
+ "Nulla hendrerit augue a felis placerat, id luctus enim sagittis. Proin id arcu et sem dignissim elementum eu at nibh. Quisque enim augue, porttitor et auctor a, mollis in ante. Donec tempus volutpat volutpat. Donec ipsum magna, pellentesque vitae libero id, vestibulum ullamcorper lacus. Maecenas elit velit, scelerisque ut suscipit vitae, gravida ac neque. Phasellus nisl dui, feugiat et dapibus vel, feugiat quis nunc. Maecenas non bibendum augue, eget sagittis dolor.",
17
+ "Donec malesuada est enim, sed finibus massa sollicitudin a. Mauris leo eros, euismod eget nisi sed, bibendum egestas magna. Proin vel nulla in dolor dictum suscipit. Praesent tincidunt dictum metus ac ornare. Sed quis arcu nibh. Vestibulum faucibus lobortis condimentum. Cras id elementum risus, id faucibus ipsum. Suspendisse sed ante eu lacus ornare ultrices. Nullam erat nunc, volutpat eu odio quis, facilisis congue justo. Nulla facilisis sagittis mauris at imperdiet. Nulla facilisi. Morbi ornare aliquet tempus. Suspendisse eu tincidunt mauris. In hac habitasse platea dictumst.",
18
+ "Vestibulum elementum velit quis consequat cursus. Donec sagittis vitae massa eget accumsan. Donec pellentesque elementum risus at pulvinar. Proin dignissim aliquet purus in viverra. Ut ut quam sed leo porttitor sagittis sed quis arcu. Etiam feugiat leo ex. Nullam volutpat sapien nisi, vitae tristique metus sodales et. Duis eu ligula in turpis fermentum finibus eget sed est. In blandit, lectus non pharetra consectetur, neque augue rhoncus lorem, at convallis justo neque vel purus. Vestibulum purus erat, pretium vel ex sit amet, eleifend accumsan massa. Aliquam vel augue maximus, pharetra leo a, commodo ante. Integer efficitur dapibus nibh, at mattis tellus molestie sit amet.",
19
+ "Nunc aliquam ultricies libero, non egestas nisl ultricies ut. Nulla augue ante, interdum non suscipit vitae, ullamcorper nec mauris. Praesent feugiat interdum mauris, ut ornare nibh lacinia sed. Mauris eget porta ipsum. Aliquam vitae pretium augue. Sed molestie est sit amet ex tempus, vitae facilisis eros malesuada. Curabitur mollis sagittis mauris, id iaculis ex sodales a. Nunc in nunc vitae tortor rhoncus ultrices. Vivamus aliquet purus at lacus sodales maximus.",
20
+ "Quisque ullamcorper dolor nunc, nec accumsan massa dignissim ac. Maecenas porta eros vel venenatis consequat. Vestibulum nec erat eget ipsum interdum blandit quis non justo. Integer condimentum, neque non molestie laoreet, augue purus porta risus, dapibus bibendum tellus mauris ac arcu. Mauris a elementum nibh. Praesent ullamcorper ligula et justo viverra rhoncus. Nullam eget convallis velit. Nulla ullamcorper id tellus interdum mollis. Fusce ac aliquet ipsum. Quisque luctus cursus massa, tincidunt pharetra ante porta pellentesque. Praesent in diam quam. Nullam hendrerit quam malesuada venenatis finibus. Curabitur diam purus, luctus sed dictum sit amet, tristique sit amet est. Aenean pulvinar pulvinar velit, vitae vehicula est luctus ac. Morbi libero urna, tempor sed urna id, interdum ultrices orci.",
21
+ "Cras id nisi sagittis, tincidunt purus quis, porta est. Integer cursus leo risus, in pellentesque dui consectetur at. Sed convallis nulla id magna laoreet pretium. Suspendisse lacus metus, efficitur quis convallis nec, maximus dictum mi. Duis quis sodales velit. Integer ornare tincidunt condimentum. Proin dignissim mauris sed tortor maximus, vitae vestibulum urna volutpat. Morbi ornare velit at lacinia porttitor. In posuere volutpat ex non mollis. Phasellus diam est, lacinia quis consectetur eu, semper in justo. Quisque quis elementum tortor.",
22
+ "Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque id lacus consequat, viverra augue vitae, tristique ex. Vivamus convallis metus odio, in cursus sem semper quis. Fusce blandit eget dolor sit amet tempus. Sed lobortis ipsum sit amet elementum dapibus. Ut orci leo, porta maximus nisi eu, efficitur viverra odio. Nunc sed posuere felis."
23
+ ]
24
+
25
+ lorem_ipsum.each do |lorem|
26
+ text = Text.new(lorem)
27
+ run = Run.new
28
+ run << text
29
+ paragraph = Paragraph.new
30
+ paragraph << run
31
+ package.document << paragraph
32
+ end
33
+
34
+ section_properties = SectionProperties.new
35
+
36
+ page_size = OpenXml::Docx::Properties::PageSize.new
37
+ page_size.height = 12240
38
+ page_size.width = 7920
39
+ page_size.orientation = :landscape
40
+ section_properties << page_size
41
+
42
+ package.document << section_properties
43
+
44
+ booklet_print = BookFoldPrinting.new
45
+ booklet_print.value = true
46
+ package.settings << booklet_print
47
+
48
+ booklet_print_page_count = BookFoldPrintingSheets.new
49
+ booklet_print_page_count.value = 4
50
+ package.settings << booklet_print_page_count
51
+
52
+ filename = "docx_booklet_test.docx"
53
+ system "rm -f ~/Desktop/#{filename}" # -f so that we don't have an error if the file doesn't exist
54
+ package.save File.expand_path("~/Desktop/#{filename}")
55
+ exec "open ~/Desktop/#{filename}"
@@ -203,7 +203,7 @@ module OpenXml
203
203
  end
204
204
 
205
205
  module ClassMethods
206
- def attribute(name, expects: nil, one_of: nil, displays_as: nil, namespace: nil)
206
+ def attribute(name, expects: nil, one_of: nil, displays_as: nil, namespace: nil, matches: nil, deprecated: false)
207
207
  bad_names = %w(tag name namespace properties_tag)
208
208
  raise ArgumentError if bad_names.member? name
209
209
 
@@ -212,6 +212,7 @@ module OpenXml
212
212
  define_method "#{name}=" do |value|
213
213
  valid_in?(value, one_of) unless one_of.nil?
214
214
  send(expects, value) unless expects.nil?
215
+ matches?(value, matches) unless matches.nil?
215
216
  instance_variable_set "@#{name}", value
216
217
  end
217
218
 
@@ -249,24 +250,24 @@ module OpenXml
249
250
  end
250
251
  end
251
252
 
252
- def true_or_false(value)
253
+ def boolean(value)
253
254
  message = "Invalid #{name}: frame must be true or false"
254
255
  raise ArgumentError, message unless [true, false].member? value
255
256
  end
256
257
 
257
258
  def hex_color(value)
258
259
  message = "Invalid #{name}: must be :auto or a hex color, e.g. 4F1B8C"
259
- raise ArgumentError, message unless value == :auto || value =~ /[0-9A-F]{6}/
260
+ raise ArgumentError, message unless value == :auto || value =~ /^[0-9A-F]{6}$/
260
261
  end
261
262
 
262
263
  def hex_digit(value)
263
264
  message = "Invalid #{name}: must be a two-digit hex number, e.g. BF"
264
- raise ArgumentError, message unless value =~ /[0-9A-F]{2}/
265
+ raise ArgumentError, message unless value =~ /^[0-9A-F]{2}$/
265
266
  end
266
267
 
267
268
  def hex_digit_4(value)
268
269
  message = "Invalid #{name}: must be a four-digit hex number, e.g. BF12"
269
- raise ArgumentError, message unless value =~ /[0-9A-F]{4}/
270
+ raise ArgumentError, message unless value =~ /^[0-9A-F]{4}$/
270
271
  end
271
272
 
272
273
  def long_hex_number(value)
@@ -316,6 +317,11 @@ module OpenXml
316
317
  raise ArgumentError, message unless list.member?(value)
317
318
  end
318
319
 
320
+ def matches?(value, regexp)
321
+ message = "Value does not match #{regexp}"
322
+ raise ArgumentError, message unless value =~ regexp
323
+ end
324
+
319
325
  end
320
326
  end
321
327
  end
@@ -7,7 +7,7 @@ module OpenXml
7
7
  with_namespace :w do
8
8
  attribute :alignment, one_of: %i(center left right)
9
9
  attribute :leader, one_of: %i(dot hyphen middleDot none underscore)
10
- attribute :relativeTo, one_of: %i(indent margin)
10
+ attribute :relative_to, one_of: %i(indent margin), displays_as: :relativeTo
11
11
  end
12
12
 
13
13
  end
@@ -0,0 +1,16 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class Background < Container
5
+
6
+ with_namespace :w do
7
+ attribute :color, expects: :hex_color
8
+ attribute :theme_color, expects: :valid_theme_color, displays_as: :themeColor
9
+ attribute :theme_shade, expects: :hex_digit, displays_as: :themeShade
10
+ attribute :theme_tint, expects: :hex_digit, displays_as: :themeTint
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -4,7 +4,7 @@ module OpenXml
4
4
  class BookFoldPrinting < Element
5
5
  tag :bookFoldPrinting
6
6
 
7
- attribute :value, expects: :true_or_false, displays_as: :val, namespace: :w
7
+ attribute :value, expects: :boolean, displays_as: :val, namespace: :w
8
8
 
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module OpenXml
4
4
  class BookFoldReversePrinting < Element
5
5
  tag :bookFoldRevPrinting
6
6
 
7
- attribute :value, expects: :true_or_false, displays_as: :val, namespace: :w
7
+ attribute :value, expects: :boolean, displays_as: :val, namespace: :w
8
8
 
9
9
  end
10
10
  end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class CompatibilitySettings < Container
5
+ tag :compat
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class CompatibilitySetting < Container
5
+ tag :compatSetting
6
+
7
+ with_namespace :w do
8
+ attribute :setting_name, expects: :string, displays_as: :name
9
+ attribute :uri, expects: :string
10
+ attribute :value, expects: :string, displays_as: :val
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -5,20 +5,12 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :font_key, expects: :bracketed_guid, displays_as: :fontKey
9
- attribute :subsetted, expects: :true_or_false
8
+ attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9
+ attribute :subsetted, expects: :boolean
10
10
  end
11
11
 
12
12
  attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13
13
 
14
-
15
- private
16
-
17
- def bracketed_guid(value)
18
- guid_regex = /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
19
- raise ArgumentError, "Not a validly-formatted GUID" unless value =~ guid_regex
20
- end
21
-
22
14
  end
23
15
  end
24
16
  end
@@ -5,20 +5,12 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :font_key, expects: :bracketed_guid, displays_as: :fontKey
9
- attribute :subsetted, expects: :true_or_false
8
+ attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9
+ attribute :subsetted, expects: :boolean
10
10
  end
11
11
 
12
12
  attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13
13
 
14
-
15
- private
16
-
17
- def bracketed_guid(value)
18
- guid_regex = /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
19
- raise ArgumentError, "Not a validly-formatted GUID" unless value =~ guid_regex
20
- end
21
-
22
14
  end
23
15
  end
24
16
  end
@@ -5,20 +5,12 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :font_key, expects: :bracketed_guid, displays_as: :fontKey
9
- attribute :subsetted, expects: :true_or_false
8
+ attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9
+ attribute :subsetted, expects: :boolean
10
10
  end
11
11
 
12
12
  attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13
13
 
14
-
15
- private
16
-
17
- def bracketed_guid(value)
18
- guid_regex = /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
19
- raise ArgumentError, "Not a validly-formatted GUID" unless value =~ guid_regex
20
- end
21
-
22
14
  end
23
15
  end
24
16
  end
@@ -5,8 +5,8 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :font_key, expects: :bracketed_guid, displays_as: :fontKey
9
- attribute :subsetted, expects: :true_or_false
8
+ attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9
+ attribute :subsetted, expects: :boolean
10
10
  end
11
11
 
12
12
  attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
@@ -15,7 +15,7 @@ module OpenXml
15
15
  private
16
16
 
17
17
  def bracketed_guid(value)
18
- guid_regex = /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
18
+ guid_regex =
19
19
  raise ArgumentError, "Not a validly-formatted GUID (#{value})" unless value =~ guid_regex
20
20
  end
21
21
 
@@ -5,7 +5,7 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :value, expects: :true_or_false, displays_as: :val
8
+ attribute :value, expects: :boolean, displays_as: :val
9
9
  end
10
10
 
11
11
  end
@@ -5,7 +5,7 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :value, expects: :true_or_false, displays_as: :val
8
+ attribute :value, expects: :boolean, displays_as: :val
9
9
  end
10
10
 
11
11
  end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class EvenAndOddHeaders < Element
5
+
6
+ attribute :value, expects: :boolean, displays_as: :val, namespace: :w
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -13,7 +13,7 @@ module OpenXml
13
13
  def valid_font_family(value)
14
14
  ok_values = %i(auto decorative modern roman script swiss) # From the spec section 17.18.30
15
15
  message = "Invalid font family type (#{value}). Valid options are: #{ok_values.join(", ")}."
16
- raise ArgumentError, message unless ok_values.inculde? value
16
+ raise ArgumentError, message unless ok_values.include? value
17
17
  end
18
18
 
19
19
  end
@@ -5,7 +5,7 @@ module OpenXml
5
5
  tag :Choice
6
6
  namespace :mc
7
7
 
8
- attribute :Required, expects: :string
8
+ attribute :requires, expects: :string, displays_as: :Requires
9
9
 
10
10
  end
11
11
  end
@@ -38,6 +38,7 @@ module OpenXml
38
38
  property :shading
39
39
  property :spacing
40
40
  property :tabs
41
+ property :section
41
42
 
42
43
  def section_properties=(section)
43
44
  raise ArgumentError, "Section properties must be an instance of OpenXml::Docx::Section" unless section.is_a?(OpenXml::Docx::Section)
@@ -5,7 +5,7 @@ module OpenXml
5
5
  namespace :w
6
6
 
7
7
  with_namespace :w do
8
- attribute :value, expects: :true_or_false, displays_as: :val
8
+ attribute :value, expects: :boolean, displays_as: :val
9
9
  end
10
10
 
11
11
  end
@@ -13,6 +13,7 @@ module OpenXml
13
13
  value_property :table_cell_fit_text
14
14
  value_property :text_direction
15
15
  value_property :v_align
16
+ value_property :vertical_merge
16
17
 
17
18
  property :conditional_formatting
18
19
  property :headers
@@ -0,0 +1,9 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class TextboxContent < Container
5
+ tag :txbxContent
6
+ end
7
+ end
8
+ end
9
+ end
@@ -5,17 +5,17 @@ module OpenXml
5
5
  tag :anchor
6
6
  namespace :wp
7
7
 
8
- attribute :allow_overlap, expects: :true_or_false, displays_as: :allowOverlap # Required
9
- attribute :behind_document, expects: :true_or_false, displays_as: :behindDoc # Required
8
+ attribute :allow_overlap, expects: :boolean, displays_as: :allowOverlap # Required
9
+ attribute :behind_document, expects: :boolean, displays_as: :behindDoc # Required
10
10
  attribute :distance_from_bottom, expects: :positive_integer, displays_as: :distB # Optional
11
11
  attribute :distance_from_left, expects: :positive_integer, displays_as: :distL # Optional
12
12
  attribute :distance_from_right, expects: :positive_integer, displays_as: :distR # Optional
13
13
  attribute :distance_from_top, expects: :positive_integer, displays_as: :distT # Optional
14
- attribute :hidden, expects: :true_or_false # Optional
15
- attribute :layout_in_cell, expects: :true_or_false, displays_as: :layoutInCell # Required
16
- attribute :locked, expects: :true_or_false # Required
14
+ attribute :hidden, expects: :boolean # Optional
15
+ attribute :layout_in_cell, expects: :boolean, displays_as: :layoutInCell # Required
16
+ attribute :locked, expects: :boolean # Required
17
17
  attribute :z_index, expects: :positive_integer, displays_as: :relativeHeight # Required
18
- attribute :simple_position, expects: :true_or_false, displays_as: :simplePos # Optional
18
+ attribute :simple_position, expects: :boolean, displays_as: :simplePos # Optional
19
19
 
20
20
  # Children elements required by spec: <docPr>, <a:graphic>, <wp:simplePos>, <wp:positionH>, <wp:positionV>, <wp:extent>, and one of the wp: wrap type tags
21
21
 
@@ -0,0 +1,16 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class WordProcessingDrawingInline < Container
5
+ tag :inline
6
+ namespace :wp
7
+
8
+ attribute :distance_from_bottom, expects: :positive_integer, displays_as: :distB
9
+ attribute :distance_from_left, expects: :positive_integer, displays_as: :distL
10
+ attribute :distance_from_right, expects: :positive_integer, displays_as: :distR
11
+ attribute :distance_from_top, expects: :positive_integer, displays_as: :distT
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -6,7 +6,7 @@ module OpenXml
6
6
  namespace :wp
7
7
 
8
8
  attribute :description, expects: :string, displays_as: :descr
9
- attribute :hidden, expects: :true_or_false
9
+ attribute :hidden, expects: :boolean
10
10
  attribute :id, expects: :positive_integer
11
11
  attribute :object_name, expects: :string, displays_as: :name
12
12
  attribute :title, expects: :string
@@ -5,7 +5,7 @@ module OpenXml
5
5
  tag :wrapPolygon
6
6
  namespace :wp
7
7
 
8
- attribute :edited, expects: :true_or_false
8
+ attribute :edited, expects: :boolean
9
9
 
10
10
  end
11
11
  end
@@ -6,23 +6,23 @@ module OpenXml
6
6
  namespace :wps
7
7
 
8
8
  attribute :anchor, expects: :anchor_value
9
- attribute :anchorCtr, expects: :true_or_false
9
+ attribute :anchor_center, expects: :boolean, displays_as: :anchorCtr
10
10
  attribute :bottom_inset, expects: :positive_integer, displays_as: :bIns
11
- attribute :compatible_line_spacing, expects: :true_or_false, displays_as: :compatLnSpc
12
- attribute :force_anti_alias, expects: :true_or_false, displays_as: :forceAA
13
- attribute :fromWordArt, expects: :true_or_false
14
- attribute :horzOverflow, expects: :horizontal_overflow_value
11
+ attribute :compatible_line_spacing, expects: :boolean, displays_as: :compatLnSpc
12
+ attribute :force_anti_alias, expects: :boolean, displays_as: :forceAA
13
+ attribute :from_word_art, expects: :boolean, displays_as: :fromWordArt
14
+ attribute :horizontal_overflow, expects: :horizontal_overflow_value, displays_as: :horzOverflow
15
15
  attribute :left_inset, expects: :positive_integer, displays_as: :lIns
16
- attribute :numCol, expects: :number_of_columns
16
+ attribute :number_of_columns, expects: :valid_number_of_columns, displays_as: :numCol
17
17
  attribute :right_inset, expects: :positive_integer, displays_as: :rIns
18
18
  attribute :rotation, expects: :integer, displays_as: :rot
19
- attribute :right_to_left_columns, expects: :true_or_false, displays_as: :rtlCol
19
+ attribute :right_to_left_columns, expects: :boolean, displays_as: :rtlCol
20
20
  attribute :space_between_columns, expects: :positive_integer, displays_as: :spcCol
21
- attribute :paragraph_spacing, expects: :true_or_false, displays_as: :spcFirstLastPara
21
+ attribute :paragraph_spacing, expects: :boolean, displays_as: :spcFirstLastPara
22
22
  attribute :top_inset, expects: :positive_integer, displays_as: :tIns
23
- attribute :upright, expects: :true_or_false
24
- attribute :vert, expects: :vertical_value
25
- attribute :vertOverflow, expects: :vertical_overflow_value
23
+ attribute :upright, expects: :boolean
24
+ attribute :vertical, expects: :vertical_value, displays_as: :vert
25
+ attribute :vertical_overflow, expects: :vertical_overflow_value, displays_as: :vertOverflow
26
26
  attribute :wrap, expects: :wrap_value
27
27
 
28
28
  private
@@ -35,7 +35,7 @@ module OpenXml
35
35
  raise ArgumentError unless %i(clip overflow).include? value
36
36
  end
37
37
 
38
- def number_of_columns(value)
38
+ def valid_number_of_columns(value)
39
39
  raise ArgumentError unless (1..16).to_a.include? value
40
40
  end
41
41