openxml-docx 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/examples/drawing-ml +134 -0
  4. data/examples/table +28 -0
  5. data/lib/openxml/docx.rb +9 -0
  6. data/lib/openxml/docx/attribute_builder.rb +17 -4
  7. data/lib/openxml/docx/elements/absolute_position_tab.rb +4 -19
  8. data/lib/openxml/docx/elements/bidi_embed.rb +1 -10
  9. data/lib/openxml/docx/elements/bidi_override.rb +1 -9
  10. data/lib/openxml/docx/elements/break.rb +3 -14
  11. data/lib/openxml/docx/elements/control.rb +5 -2
  12. data/lib/openxml/docx/elements/deleted_text.rb +1 -1
  13. data/lib/openxml/docx/elements/drawing.rb +9 -0
  14. data/lib/openxml/docx/elements/element.rb +2 -1
  15. data/lib/openxml/docx/elements/embed_bold.rb +25 -0
  16. data/lib/openxml/docx/elements/embed_bold_italic.rb +25 -0
  17. data/lib/openxml/docx/elements/embed_italic.rb +25 -0
  18. data/lib/openxml/docx/elements/embed_regular.rb +25 -0
  19. data/lib/openxml/docx/elements/family.rb +22 -0
  20. data/lib/openxml/docx/elements/font.rb +14 -0
  21. data/lib/openxml/docx/elements/grid_column.rb +2 -2
  22. data/lib/openxml/docx/elements/group_shape.rb +10 -0
  23. data/lib/openxml/docx/elements/markup_compatibility_alternate_content.rb +10 -0
  24. data/lib/openxml/docx/elements/markup_compatibility_choice.rb +13 -0
  25. data/lib/openxml/docx/elements/markup_compatibility_fallback.rb +10 -0
  26. data/lib/openxml/docx/elements/paper_source.rb +4 -2
  27. data/lib/openxml/docx/elements/section_properties.rb +9 -0
  28. data/lib/openxml/docx/elements/symbol.rb +4 -2
  29. data/lib/openxml/docx/elements/table.rb +1 -1
  30. data/lib/openxml/docx/elements/table_cell.rb +2 -1
  31. data/lib/openxml/docx/elements/table_row.rb +7 -5
  32. data/lib/openxml/docx/elements/text.rb +1 -10
  33. data/lib/openxml/docx/elements/vml_container.rb +10 -0
  34. data/lib/openxml/docx/elements/word_processing_drawing_anchor.rb +23 -0
  35. data/lib/openxml/docx/elements/word_processing_drawing_effect_extent.rb +16 -0
  36. data/lib/openxml/docx/elements/word_processing_drawing_extent.rb +14 -0
  37. data/lib/openxml/docx/elements/word_processing_drawing_nv_graphic_frame_properties.rb +11 -0
  38. data/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb +17 -0
  39. data/lib/openxml/docx/elements/word_processing_drawing_position_h.rb +23 -0
  40. data/lib/openxml/docx/elements/word_processing_drawing_position_offset.rb +10 -0
  41. data/lib/openxml/docx/elements/word_processing_drawing_position_v.rb +23 -0
  42. data/lib/openxml/docx/elements/word_processing_drawing_simple_position.rb +13 -0
  43. data/lib/openxml/docx/elements/word_processing_drawing_wrap_none.rb +10 -0
  44. data/lib/openxml/docx/elements/word_processing_shapes_body_properties.rb +58 -0
  45. data/lib/openxml/docx/elements/word_processing_shapes_shape.rb +12 -0
  46. data/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb +23 -0
  47. data/lib/openxml/docx/package.rb +73 -1
  48. data/lib/openxml/docx/parts/document.rb +6 -24
  49. data/lib/openxml/docx/parts/fonts.rb +35 -0
  50. data/lib/openxml/docx/parts/footer.rb +32 -0
  51. data/lib/openxml/docx/parts/header.rb +32 -0
  52. data/lib/openxml/docx/parts/settings.rb +6 -2
  53. data/lib/openxml/docx/parts/styles.rb +5 -6
  54. data/lib/openxml/docx/properties.rb +0 -1
  55. data/lib/openxml/docx/properties/alignment.rb +1 -1
  56. data/lib/openxml/docx/properties/base_property.rb +13 -0
  57. data/lib/openxml/docx/properties/border.rb +11 -9
  58. data/lib/openxml/docx/properties/color.rb +6 -4
  59. data/lib/openxml/docx/properties/column.rb +4 -2
  60. data/lib/openxml/docx/properties/columns.rb +6 -4
  61. data/lib/openxml/docx/properties/complex_property.rb +1 -1
  62. data/lib/openxml/docx/properties/conditional_formatting.rb +14 -12
  63. data/lib/openxml/docx/properties/document_grid.rb +4 -10
  64. data/lib/openxml/docx/properties/east_asian_layout.rb +6 -11
  65. data/lib/openxml/docx/properties/font.rb +18 -22
  66. data/lib/openxml/docx/properties/footer_reference.rb +21 -0
  67. data/lib/openxml/docx/properties/frame.rb +16 -47
  68. data/lib/openxml/docx/properties/header_reference.rb +21 -0
  69. data/lib/openxml/docx/properties/indentation.rb +11 -8
  70. data/lib/openxml/docx/properties/language.rb +5 -3
  71. data/lib/openxml/docx/properties/latent_styles.rb +9 -6
  72. data/lib/openxml/docx/properties/latent_styles_exception.rb +9 -6
  73. data/lib/openxml/docx/properties/line_numbering.rb +5 -11
  74. data/lib/openxml/docx/properties/manual_width.rb +4 -2
  75. data/lib/openxml/docx/properties/numbering.rb +4 -2
  76. data/lib/openxml/docx/properties/page_borders.rb +6 -19
  77. data/lib/openxml/docx/properties/page_margins.rb +10 -7
  78. data/lib/openxml/docx/properties/page_numbering.rb +66 -74
  79. data/lib/openxml/docx/properties/page_size.rb +5 -12
  80. data/lib/openxml/docx/properties/shading.rb +46 -52
  81. data/lib/openxml/docx/properties/spacing.rb +9 -14
  82. data/lib/openxml/docx/properties/table_border.rb +12 -10
  83. data/lib/openxml/docx/properties/table_cell_border.rb +12 -10
  84. data/lib/openxml/docx/properties/table_cell_margin.rb +6 -4
  85. data/lib/openxml/docx/properties/table_cell_spacing.rb +5 -3
  86. data/lib/openxml/docx/properties/table_cell_width.rb +5 -3
  87. data/lib/openxml/docx/properties/table_indent.rb +5 -3
  88. data/lib/openxml/docx/properties/table_layout.rb +2 -4
  89. data/lib/openxml/docx/properties/table_look.rb +8 -6
  90. data/lib/openxml/docx/properties/table_p_pr.rb +11 -30
  91. data/lib/openxml/docx/properties/table_row_height.rb +13 -0
  92. data/lib/openxml/docx/properties/table_width.rb +5 -3
  93. data/lib/openxml/docx/properties/underline.rb +13 -12
  94. data/lib/openxml/docx/properties/wafter.rb +5 -3
  95. data/lib/openxml/docx/properties/wbefore.rb +5 -3
  96. data/lib/openxml/docx/root_namespaces.rb +74 -0
  97. data/lib/openxml/docx/section.rb +2 -0
  98. data/lib/openxml/docx/style.rb +4 -4
  99. data/lib/openxml/docx/version.rb +1 -1
  100. data/lib/openxml/drawingml.rb +17 -0
  101. data/lib/openxml/drawingml/elements.rb +13 -0
  102. data/lib/openxml/drawingml/elements/adjust_values_list.rb +11 -0
  103. data/lib/openxml/drawingml/elements/blip_fill.rb +14 -0
  104. data/lib/openxml/drawingml/elements/extension.rb +13 -0
  105. data/lib/openxml/drawingml/elements/extension_list.rb +11 -0
  106. data/lib/openxml/drawingml/elements/extents.rb +14 -0
  107. data/lib/openxml/drawingml/elements/graphic.rb +10 -0
  108. data/lib/openxml/drawingml/elements/graphic_data.rb +12 -0
  109. data/lib/openxml/drawingml/elements/graphic_frame_locks.rb +17 -0
  110. data/lib/openxml/drawingml/elements/head_end.rb +28 -0
  111. data/lib/openxml/drawingml/elements/no_fill.rb +10 -0
  112. data/lib/openxml/drawingml/elements/non_visual_drawing_properties.rb +17 -0
  113. data/lib/openxml/drawingml/elements/non_visual_picture_drawing_properties.rb +12 -0
  114. data/lib/openxml/drawingml/elements/non_visual_picture_properties.rb +10 -0
  115. data/lib/openxml/drawingml/elements/offset.rb +14 -0
  116. data/lib/openxml/drawingml/elements/outline.rb +36 -0
  117. data/lib/openxml/drawingml/elements/picture.rb +10 -0
  118. data/lib/openxml/drawingml/elements/preset_geometry.rb +210 -0
  119. data/lib/openxml/drawingml/elements/round.rb +10 -0
  120. data/lib/openxml/drawingml/elements/shape_guide.rb +40 -0
  121. data/lib/openxml/drawingml/elements/solid_fill.rb +10 -0
  122. data/lib/openxml/drawingml/elements/srgb_color.rb +14 -0
  123. data/lib/openxml/drawingml/elements/tail_end.rb +28 -0
  124. data/lib/openxml/drawingml/elements/transform_effect.rb +18 -0
  125. data/lib/openxml/drawingml/elements/wordprocessing_shape_group.rb +11 -0
  126. data/lib/openxml/vml.rb +17 -0
  127. data/lib/openxml/vml/elements.rb +13 -0
  128. data/lib/openxml/vml/elements/group.rb +88 -0
  129. data/lib/openxml/vml/elements/rectangle.rb +115 -0
  130. data/lib/openxml/vml/elements/rounded_rectangle.rb +121 -0
  131. data/openxml-docx.gemspec +1 -1
  132. data/spec/elements/absolute_position_tab_spec.rb +15 -47
  133. data/spec/elements/bidi_embed_spec.rb +4 -8
  134. data/spec/elements/bidi_override_spec.rb +4 -8
  135. data/spec/elements/break_spec.rb +8 -31
  136. data/spec/elements/content_part_spec.rb +2 -2
  137. data/spec/elements/control_spec.rb +6 -6
  138. data/spec/elements/deleted_text_spec.rb +2 -2
  139. data/spec/elements/drawing_spec.rb +11 -0
  140. data/spec/elements/drawingml/adjust_values_list_spec.rb +8 -0
  141. data/spec/elements/drawingml/blip_fill_spec.rb +34 -0
  142. data/spec/elements/drawingml/extension_list_spec.rb +8 -0
  143. data/spec/elements/drawingml/extension_spec.rb +19 -0
  144. data/spec/elements/drawingml/extents_spec.rb +33 -0
  145. data/spec/elements/drawingml/graphic_data_spec.rb +19 -0
  146. data/spec/elements/drawingml/graphic_frame_locks_spec.rb +78 -0
  147. data/spec/elements/drawingml/graphic_spec.rb +8 -0
  148. data/spec/elements/drawingml/head_end_spec.rb +45 -0
  149. data/spec/elements/drawingml/no_fill_spec.rb +8 -0
  150. data/spec/elements/drawingml/non_visual_drawing_properties_spec.rb +63 -0
  151. data/spec/elements/drawingml/non_visual_picture_drawing_properties_spec.rb +18 -0
  152. data/spec/elements/drawingml/non_visual_picture_properties_spec.rb +8 -0
  153. data/spec/elements/drawingml/offset_spec.rb +32 -0
  154. data/spec/elements/drawingml/outline_spec.rb +58 -0
  155. data/spec/elements/drawingml/picture_spec.rb +8 -0
  156. data/spec/elements/drawingml/preset_geometry_spec.rb +19 -0
  157. data/spec/elements/drawingml/round_spec.rb +8 -0
  158. data/spec/elements/drawingml/shape_guide_spec.rb +49 -0
  159. data/spec/elements/drawingml/solid_fill_spec.rb +8 -0
  160. data/spec/elements/drawingml/srgb_color_spec.rb +20 -0
  161. data/spec/elements/drawingml/tail_end_spec.rb +44 -0
  162. data/spec/elements/drawingml/transform_effect_spec.rb +80 -0
  163. data/spec/elements/drawingml/wordprocessing_shape_group_spec.rb +12 -0
  164. data/spec/elements/group_shape_spec.rb +11 -0
  165. data/spec/elements/markup_compatibility_alternate_content_spec.rb +11 -0
  166. data/spec/elements/markup_compatibility_choice_spec.rb +22 -0
  167. data/spec/elements/markup_compatibility_fallback_spec.rb +11 -0
  168. data/spec/elements/section_properties_spec.rb +12 -0
  169. data/spec/elements/symbol_spec.rb +4 -7
  170. data/spec/elements/text_spec.rb +2 -2
  171. data/spec/elements/vml/group_spec.rb +542 -0
  172. data/spec/elements/vml/rectangle_spec.rb +739 -0
  173. data/spec/elements/vml/rounded_rectangle_spec.rb +656 -0
  174. data/spec/elements/vml_container_spec.rb +11 -0
  175. data/spec/elements/word_processing_drawing_anchor_spec.rb +40 -0
  176. data/spec/elements/word_processing_drawing_effect_extent_spec.rb +57 -0
  177. data/spec/elements/word_processing_drawing_extent_spec.rb +34 -0
  178. data/spec/elements/word_processing_drawing_nv_graphic_frame_properties_spec.rb +11 -0
  179. data/spec/elements/word_processing_drawing_object_nv_properties_spec.rb +67 -0
  180. data/spec/elements/word_processing_drawing_position_h_spec.rb +21 -0
  181. data/spec/elements/word_processing_drawing_position_v_spec.rb +21 -0
  182. data/spec/elements/word_processing_drawing_simple_position_spec.rb +34 -0
  183. data/spec/elements/word_processing_drawing_wrap_none_spec.rb +12 -0
  184. data/spec/elements/word_processing_shapes_body_properties_spec.rb +223 -0
  185. data/spec/elements/word_processing_shapes_shape_properties_spec.rb +21 -0
  186. data/spec/elements/word_processing_shapes_shape_spec.rb +23 -0
  187. data/spec/parts/footer_spec.rb +33 -0
  188. data/spec/parts/header_spec.rb +33 -0
  189. data/spec/properties/footer_reference_spec.rb +32 -0
  190. data/spec/properties/header_reference_spec.rb +32 -0
  191. data/spec/properties/page_numbering_spec.rb +1 -1
  192. data/spec/properties/{table_cell_fit_text.rb → table_cell_fit_text_spec.rb} +0 -0
  193. data/spec/properties/{table_cell_width.rb → table_cell_width_spec.rb} +0 -0
  194. data/spec/properties/table_layout_spec.rb +14 -12
  195. data/spec/properties/{table_row_height.rb → table_row_height_spec.rb} +0 -0
  196. data/spec/section_spec.rb +2 -0
  197. data/spec/spec_helper.rb +2 -0
  198. data/spec/support/data/elements/grid_column_element.xml +1 -1
  199. data/spec/support/data/elements/table_grid_element.xml +1 -1
  200. data/spec/support/data/parts/document_with_children_part.xml +2 -1
  201. data/spec/support/data/parts/document_with_multiple_sections_part.xml +1 -1
  202. data/spec/support/data/parts/document_with_one_section_part.xml +1 -1
  203. data/spec/support/data/parts/empty_document_part.xml +1 -1
  204. data/spec/support/data/parts/empty_footer_part.xml +1 -0
  205. data/spec/support/data/parts/empty_header_part.xml +1 -0
  206. data/spec/support/data/parts/footer_with_children_part.xml +1 -0
  207. data/spec/support/data/parts/header_with_children_part.xml +1 -0
  208. data/spec/support/element_test_macros.rb +58 -9
  209. metadata +126 -9
  210. data/lib/openxml/docx/properties/tr_height.rb +0 -19
  211. data/lib/openxml/docx/properties/width_property.rb +0 -17
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::WordprocessingShapeGroup do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :wgp, name: "wordprocessing_shape_group"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<wpg:wgp/>", assign: false
10
+ end
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::GroupShape do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :grpSp, name: "group_shape"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<w:grpSp/>", assign: false
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::MarkupCompatibilityAlternateContent do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :AlternateContent, name: "markup_compatibility_alternate_content"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<mc:AlternateContent/>", assign: false
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::MarkupCompatibilityChoice do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :Choice, name: "markup_compatibility_choice"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<mc:Choice/>", assign: false
10
+ end
11
+
12
+ for_attribute(:Required) do
13
+ with_value("wps") do
14
+ it_should_assign_successfully
15
+ it_should_output_regular_xml
16
+ end
17
+
18
+ with_value(1234) do
19
+ it_should_raise_an_exception
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::MarkupCompatibilityFallback do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :Fallback, name: "markup_compatibility_fallback"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<mc:Fallback/>", assign: false
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::SectionProperties do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :sectPr, name: "section_properties"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<w:sectPr/>", assign: false
10
+ end
11
+
12
+ end
@@ -5,10 +5,10 @@ describe OpenXml::Docx::Elements::Symbol do
5
5
 
6
6
  it_should_use tag: :sym, name: "symbol"
7
7
 
8
- for_attribute(:font) do
8
+ for_attribute(:font, with_namespace: :w) do
9
9
  with_value("Wingdings") do
10
10
  it_should_assign_successfully
11
- it_should_output "<w:sym w:font=\"Wingdings\"/>"
11
+ it_should_output_regular_xml
12
12
  end
13
13
 
14
14
  with_value(123) do
@@ -16,19 +16,16 @@ describe OpenXml::Docx::Elements::Symbol do
16
16
  end
17
17
  end
18
18
 
19
- for_attribute(:character) do
19
+ for_attribute(:character, with_namespace: :w, displays_as: :char) do
20
20
  with_value("43FD") do
21
21
  it_should_assign_successfully
22
- it_should_output "<w:sym w:char=\"43FD\"/>"
22
+ it_should_output_regular_xml
23
23
  end
24
24
 
25
25
  with_value("43gg") do
26
26
  it_should_raise_an_exception
27
27
  end
28
28
 
29
- with_value("abcdef") do
30
- it_should_raise_an_exception
31
- end
32
29
  end
33
30
 
34
31
  end
@@ -5,7 +5,7 @@ describe OpenXml::Docx::Elements::Text do
5
5
 
6
6
  it_should_use tag: :t, name: "text"
7
7
 
8
- for_attribute(:space) do
8
+ for_attribute(:space, with_namespace: :xml) do
9
9
  with_value(nil) do
10
10
  it_should_assign_successfully
11
11
  it_should_output "<w:t/>"
@@ -13,7 +13,7 @@ describe OpenXml::Docx::Elements::Text do
13
13
 
14
14
  with_value(:preserve) do
15
15
  it_should_assign_successfully
16
- it_should_output "<w:t xml:space=\"preserve\"/>"
16
+ it_should_output_regular_xml
17
17
  end
18
18
 
19
19
  with_value(:the_final_frontier) do
@@ -0,0 +1,542 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Vml::Elements::Group do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :group, name: "group"
7
+
8
+
9
+ # HR Align Attribute
10
+
11
+ for_attribute(:hr_align, displays_as: :hralign, with_namespace: :o) do
12
+ %i(center left right).each do |value|
13
+ with_value(value) do
14
+ it_should_assign_successfully
15
+ it_should_output "<v:group o:hralign=\"#{value}\"/>"
16
+ end
17
+ end
18
+
19
+ with_values([:justified, 4, "overThere"]) do
20
+ it_should_raise_an_exception
21
+ end
22
+ end
23
+
24
+
25
+ # Inset Mode Attribute
26
+
27
+ for_attribute(:inset_mode, displays_as: :insetmode, with_namespace: :o) do
28
+ with_value(:auto) do
29
+ it_should_assign_successfully
30
+ it_should_output "<v:group o:insetmode=\"auto\"/>"
31
+ end
32
+
33
+ with_value(:custom) do
34
+ it_should_assign_successfully
35
+ it_should_output "<v:group o:insetmode=\"custom\"/>"
36
+ end
37
+
38
+ with_values([:left, "right", 0]) do
39
+ it_should_raise_an_exception
40
+ end
41
+ end
42
+
43
+
44
+ # Edit As Attribute
45
+
46
+ for_attribute(:edit_as, displays_as: :editas) do
47
+ %i(bullseye canvas cycle orgchart radial stacked venn).each do |value|
48
+ with_value(value) do
49
+ it_should_assign_successfully
50
+ it_should_output "<v:group editas=\"#{value}\"/>"
51
+ end
52
+ end
53
+
54
+ with_values([:piechart, 4, "amazingGraph"]) do
55
+ it_should_raise_an_exception
56
+ end
57
+ end
58
+
59
+
60
+ # Coordinate-based Attributes
61
+
62
+ good_coord_values = [ "100,100", "-100,-100", "100,-100", "100, 100", "-100, -100", "100, -100" ]
63
+ bad_coord_values = [ "100 100", "x:10,y:10", :over_there ]
64
+
65
+ for_attribute(:coordinate_origin, displays_as: :coordorigin) do
66
+ good_coord_values.each do |good_value|
67
+ with_value(good_value) do
68
+ it_should_assign_successfully
69
+ it_should_output "<v:group coordorigin=\"#{good_value}\"/>"
70
+ end
71
+ end
72
+
73
+ with_values(bad_coord_values) do
74
+ it_should_raise_an_exception
75
+ end
76
+ end
77
+
78
+ for_attribute(:coordinate_size, displays_as: :coordsize) do
79
+ good_coord_values.each do |good_value|
80
+ with_value(good_value) do
81
+ it_should_assign_successfully
82
+ it_should_output "<v:group coordsize=\"#{good_value}\"/>"
83
+ end
84
+ end
85
+
86
+ with_values(bad_coord_values) do
87
+ it_should_raise_an_exception
88
+ end
89
+ end
90
+
91
+
92
+ # Color-based Attributes
93
+
94
+ good_color_values = [ "#FFFFFF", :red, "palateEntry [0]", "palateEntry" ]
95
+ bad_color_values = [ 54, 0 ]
96
+
97
+ for_attribute(:fill_color, displays_as: :fillcolor) do
98
+ good_color_values.each do |good_value|
99
+ with_value(good_value) do
100
+ it_should_assign_successfully
101
+ it_should_output "<v:group fillcolor=\"#{good_value}\"/>"
102
+ end
103
+ end
104
+
105
+ with_values(bad_color_values) do
106
+ it_should_raise_an_exception
107
+ end
108
+ end
109
+
110
+
111
+ # Diagram Layout-based Attributes
112
+
113
+ good_diagram_layout_values = (0..3)
114
+ bad_diagram_layout_values = [ -1, 4, "Five is Right Out" ]
115
+
116
+ for_attribute(:diagram_node_layout, displays_as: :dgmlayout, with_namespace: :o) do
117
+ good_diagram_layout_values.each do |good_value|
118
+ with_value(good_value) do
119
+ it_should_assign_successfully
120
+ it_should_output "<v:group o:dgmlayout=\"#{good_value}\"/>"
121
+ end
122
+ end
123
+
124
+ with_values(bad_diagram_layout_values) do
125
+ it_should_raise_an_exception
126
+ end
127
+ end
128
+
129
+ for_attribute(:diagram_node_recent_layout, displays_as: :dgmlayoutmru, with_namespace: :o) do
130
+ good_diagram_layout_values.each do |good_value|
131
+ with_value(good_value) do
132
+ it_should_assign_successfully
133
+ it_should_output "<v:group o:dgmlayoutmru=\"#{good_value}\"/>"
134
+ end
135
+ end
136
+
137
+ with_values(bad_diagram_layout_values) do
138
+ it_should_raise_an_exception
139
+ end
140
+ end
141
+
142
+
143
+ # Integer-based Attributes
144
+
145
+ good_integer_values = [1, -1, 0]
146
+ bad_integer_values = [2.5, :five, "five"]
147
+
148
+ for_attribute(:diagram_node_kind, displays_as: :dgmnodekind, with_namespace: :o) do
149
+ good_integer_values.each do |good_value|
150
+ with_value(good_value) do
151
+ it_should_assign_successfully
152
+ it_should_output "<v:group o:dgmnodekind=\"#{good_value}\"/>"
153
+ end
154
+ end
155
+
156
+ with_values(bad_integer_values) do
157
+ it_should_raise_an_exception
158
+ end
159
+ end
160
+
161
+ for_attribute(:hr_percent, displays_as: :hrpct, with_namespace: :o) do
162
+ good_integer_values.each do |good_value|
163
+ with_value(good_value) do
164
+ it_should_assign_successfully
165
+ it_should_output "<v:group o:hrpct=\"#{good_value}\"/>"
166
+ end
167
+ end
168
+
169
+ with_values(bad_integer_values) do
170
+ it_should_raise_an_exception
171
+ end
172
+ end
173
+
174
+ for_attribute(:regroup_id, displays_as: :regroupid, with_namespace: :o) do
175
+ good_integer_values.each do |good_value|
176
+ with_value(good_value) do
177
+ it_should_assign_successfully
178
+ it_should_output "<v:group o:regroupid=\"#{good_value}\"/>"
179
+ end
180
+ end
181
+
182
+ with_values(bad_integer_values) do
183
+ it_should_raise_an_exception
184
+ end
185
+ end
186
+
187
+
188
+ # String-based Attributes
189
+
190
+ bad_string_values = [0, :nope, false]
191
+
192
+ for_attribute(:alt) do
193
+ with_value("String") do
194
+ it_should_assign_successfully
195
+ it_should_output "<v:group alt=\"String\"/>"
196
+ end
197
+
198
+ with_value("000001f") do
199
+ it_should_assign_successfully
200
+ it_should_output "<v:group alt=\"000001f\"/>"
201
+ end
202
+
203
+
204
+ with_values(bad_string_values) do
205
+ it_should_raise_an_exception
206
+ end
207
+ end
208
+
209
+ for_attribute(:css_class, displays_as: :class) do
210
+ with_value("String") do
211
+ it_should_assign_successfully
212
+ it_should_output "<v:group class=\"String\"/>"
213
+ end
214
+
215
+ with_values(bad_string_values) do
216
+ it_should_raise_an_exception
217
+ end
218
+ end
219
+
220
+ for_attribute(:href) do
221
+ with_value("http://something.com") do
222
+ it_should_assign_successfully
223
+ it_should_output "<v:group href=\"http://something.com\"/>"
224
+ end
225
+
226
+ with_values(bad_string_values) do
227
+ it_should_raise_an_exception
228
+ end
229
+ end
230
+
231
+ for_attribute(:id) do
232
+ with_value("String") do
233
+ it_should_assign_successfully
234
+ it_should_output "<v:group id=\"String\"/>"
235
+ end
236
+
237
+ with_values(bad_string_values) do
238
+ it_should_raise_an_exception
239
+ end
240
+ end
241
+
242
+ for_attribute(:style) do
243
+ with_value("String") do
244
+ it_should_assign_successfully
245
+ it_should_output "<v:group style=\"String\"/>"
246
+ end
247
+
248
+ with_values(bad_string_values) do
249
+ it_should_raise_an_exception
250
+ end
251
+ end
252
+
253
+ for_attribute(:target) do
254
+ with_value("String") do
255
+ it_should_assign_successfully
256
+ it_should_output "<v:group target=\"String\"/>"
257
+ end
258
+
259
+ with_values(bad_string_values) do
260
+ it_should_raise_an_exception
261
+ end
262
+ end
263
+
264
+ for_attribute(:title) do
265
+ with_value("String") do
266
+ it_should_assign_successfully
267
+ it_should_output "<v:group title=\"String\"/>"
268
+ end
269
+
270
+ with_values(bad_string_values) do
271
+ it_should_raise_an_exception
272
+ end
273
+ end
274
+
275
+ for_attribute(:wrap_coordinates, displays_as: :wrapcoords) do
276
+ with_value("String") do
277
+ it_should_assign_successfully
278
+ it_should_output "<v:group wrapcoords=\"String\"/>"
279
+ end
280
+
281
+ with_value("0,0,100,100") do
282
+ it_should_assign_successfully
283
+ it_should_output "<v:group wrapcoords=\"0,0,100,100\"/>"
284
+ end
285
+
286
+ with_values(bad_string_values) do
287
+ it_should_raise_an_exception
288
+ end
289
+ end
290
+
291
+ for_attribute(:border_bottom_color, displays_as: :borderbottomcolor, with_namespace: :o) do
292
+ with_value("String") do
293
+ it_should_assign_successfully
294
+ it_should_output "<v:group o:borderbottomcolor=\"String\"/>"
295
+ end
296
+
297
+ with_values(bad_string_values) do
298
+ it_should_raise_an_exception
299
+ end
300
+ end
301
+
302
+ for_attribute(:border_left_color, displays_as: :borderleftcolor, with_namespace: :o) do
303
+ with_value("String") do
304
+ it_should_assign_successfully
305
+ it_should_output "<v:group o:borderleftcolor=\"String\"/>"
306
+ end
307
+
308
+ with_values(bad_string_values) do
309
+ it_should_raise_an_exception
310
+ end
311
+ end
312
+
313
+ for_attribute(:border_right_color, displays_as: :borderrightcolor, with_namespace: :o) do
314
+ with_value("String") do
315
+ it_should_assign_successfully
316
+ it_should_output "<v:group o:borderrightcolor=\"String\"/>"
317
+ end
318
+
319
+ with_values(bad_string_values) do
320
+ it_should_raise_an_exception
321
+ end
322
+ end
323
+
324
+ for_attribute(:border_top_color, displays_as: :bordertopcolor, with_namespace: :o) do
325
+ with_value("String") do
326
+ it_should_assign_successfully
327
+ it_should_output "<v:group o:bordertopcolor=\"String\"/>"
328
+ end
329
+
330
+ with_values(bad_string_values) do
331
+ it_should_raise_an_exception
332
+ end
333
+ end
334
+
335
+ for_attribute(:optional_string, displays_as: :spid, with_namespace: :o) do
336
+ with_value("String") do
337
+ it_should_assign_successfully
338
+ it_should_output "<v:group o:spid=\"String\"/>"
339
+ end
340
+
341
+ with_values(bad_string_values) do
342
+ it_should_raise_an_exception
343
+ end
344
+ end
345
+
346
+ for_attribute(:table_limits, displays_as: :tablelimits, with_namespace: :o) do
347
+ with_value("String") do
348
+ it_should_assign_successfully
349
+ it_should_output "<v:group o:tablelimits=\"String\"/>"
350
+ end
351
+
352
+ with_values(bad_string_values) do
353
+ it_should_raise_an_exception
354
+ end
355
+ end
356
+
357
+ for_attribute(:table_properties, displays_as: :tableproperties, with_namespace: :o) do
358
+ with_value("String") do
359
+ it_should_assign_successfully
360
+ it_should_output "<v:group o:tableproperties=\"String\"/>"
361
+ end
362
+
363
+ with_values(bad_string_values) do
364
+ it_should_raise_an_exception
365
+ end
366
+ end
367
+
368
+ # (Explicitly) True/False-based Attributes
369
+
370
+ good_tf_values = %w(0 1 t f true false)
371
+ bad_tf_values = ["yes", "no", "on", "off", 5]
372
+
373
+ for_attribute(:filled) do
374
+ good_tf_values.each do |good_value|
375
+ with_value(good_value) do
376
+ it_should_assign_successfully
377
+ it_should_output "<v:group filled=\"#{good_value}\"/>"
378
+ end
379
+ end
380
+
381
+ with_values(bad_tf_values) do
382
+ it_should_raise_an_exception
383
+ end
384
+ end
385
+
386
+ for_attribute(:print) do
387
+ good_tf_values.each do |good_value|
388
+ with_value(good_value) do
389
+ it_should_assign_successfully
390
+ it_should_output "<v:group print=\"#{good_value}\"/>"
391
+ end
392
+ end
393
+
394
+ with_values(bad_tf_values) do
395
+ it_should_raise_an_exception
396
+ end
397
+ end
398
+
399
+ for_attribute(:allow_in_cell, displays_as: :allowincell, with_namespace: :o) do
400
+ good_tf_values.each do |good_value|
401
+ with_value(good_value) do
402
+ it_should_assign_successfully
403
+ it_should_output "<v:group o:allowincell=\"#{good_value}\"/>"
404
+ end
405
+ end
406
+ with_values(bad_tf_values) do
407
+ it_should_raise_an_exception
408
+ end
409
+ end
410
+
411
+ for_attribute(:allow_overlap, displays_as: :allowoverlap, with_namespace: :o) do
412
+ good_tf_values.each do |good_value|
413
+ with_value(good_value) do
414
+ it_should_assign_successfully
415
+ it_should_output "<v:group o:allowoverlap=\"#{good_value}\"/>"
416
+ end
417
+ end
418
+
419
+ with_values(bad_tf_values) do
420
+ it_should_raise_an_exception
421
+ end
422
+ end
423
+
424
+ for_attribute(:bullet, with_namespace: :o) do
425
+ good_tf_values.each do |good_value|
426
+ with_value(good_value) do
427
+ it_should_assign_successfully
428
+ it_should_output "<v:group o:bullet=\"#{good_value}\"/>"
429
+ end
430
+ end
431
+
432
+ with_values(bad_tf_values) do
433
+ it_should_raise_an_exception
434
+ end
435
+ end
436
+
437
+ for_attribute(:button, with_namespace: :o) do
438
+ good_tf_values.each do |good_value|
439
+ with_value(good_value) do
440
+ it_should_assign_successfully
441
+ it_should_output "<v:group o:button=\"#{good_value}\"/>"
442
+ end
443
+ end
444
+
445
+ with_values(bad_tf_values) do
446
+ it_should_raise_an_exception
447
+ end
448
+ end
449
+
450
+ for_attribute(:double_click_notify, displays_as: :doubleclicknotify, with_namespace: :o) do
451
+ good_tf_values.each do |good_value|
452
+ with_value(good_value) do
453
+ it_should_assign_successfully
454
+ it_should_output "<v:group o:doubleclicknotify=\"#{good_value}\"/>"
455
+ end
456
+ end
457
+
458
+ with_values(bad_tf_values) do
459
+ it_should_raise_an_exception
460
+ end
461
+ end
462
+
463
+ for_attribute(:hr, with_namespace: :o) do
464
+ good_tf_values.each do |good_value|
465
+ with_value(good_value) do
466
+ it_should_assign_successfully
467
+ it_should_output "<v:group o:hr=\"#{good_value}\"/>"
468
+ end
469
+ end
470
+
471
+ with_values(bad_tf_values) do
472
+ it_should_raise_an_exception
473
+ end
474
+ end
475
+
476
+ for_attribute(:hr_no_shade, displays_as: :hrnoshade, with_namespace: :o) do
477
+ good_tf_values.each do |good_value|
478
+ with_value(good_value) do
479
+ it_should_assign_successfully
480
+ it_should_output "<v:group o:hrnoshade=\"#{good_value}\"/>"
481
+ end
482
+ end
483
+
484
+ with_values(bad_tf_values) do
485
+ it_should_raise_an_exception
486
+ end
487
+ end
488
+
489
+ for_attribute(:hr_standard, displays_as: :hrstd, with_namespace: :o) do
490
+ good_tf_values.each do |good_value|
491
+ with_value(good_value) do
492
+ it_should_assign_successfully
493
+ it_should_output "<v:group o:hrstd=\"#{good_value}\"/>"
494
+ end
495
+ end
496
+
497
+ with_values(bad_tf_values) do
498
+ it_should_raise_an_exception
499
+ end
500
+ end
501
+
502
+ for_attribute(:hide_extra_handles, displays_as: :oned, with_namespace: :o) do
503
+ good_tf_values.each do |good_value|
504
+ with_value(good_value) do
505
+ it_should_assign_successfully
506
+ it_should_output "<v:group o:oned=\"#{good_value}\"/>"
507
+ end
508
+ end
509
+
510
+ with_values(bad_tf_values) do
511
+ it_should_raise_an_exception
512
+ end
513
+ end
514
+
515
+ for_attribute(:user_drawn, displays_as: :userdrawn, with_namespace: :o) do
516
+ good_tf_values.each do |good_value|
517
+ with_value(good_value) do
518
+ it_should_assign_successfully
519
+ it_should_output "<v:group o:userdrawn=\"#{good_value}\"/>"
520
+ end
521
+ end
522
+
523
+ with_values(bad_tf_values) do
524
+ it_should_raise_an_exception
525
+ end
526
+ end
527
+
528
+ for_attribute(:user_hidden, displays_as: :userhidden, with_namespace: :o) do
529
+ good_tf_values.each do |good_value|
530
+ with_value(good_value) do
531
+ it_should_assign_successfully
532
+ it_should_output "<v:group o:userhidden=\"#{good_value}\"/>"
533
+ end
534
+ end
535
+
536
+ with_values(bad_tf_values) do
537
+ it_should_raise_an_exception
538
+ end
539
+ end
540
+
541
+
542
+ end