openxml-docx 0.9.0 → 0.10.0

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 (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
data/openxml-docx.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.required_ruby_version = "~> 2.0"
22
22
 
23
23
  gem.add_dependency "nokogiri"
24
- gem.add_dependency "openxml-package", ">= 0.2.1"
24
+ gem.add_dependency "openxml-package", ">= 0.2.2"
25
25
 
26
26
  gem.add_development_dependency "pry"
27
27
  gem.add_development_dependency "rspec"
@@ -5,20 +5,15 @@ describe OpenXml::Docx::Elements::AbsolutePositionTab do
5
5
 
6
6
  it_should_use tag: :ptab, name: "absolute_position_tab"
7
7
 
8
- for_attribute(:alignment) do
9
- with_value(:center) do
10
- it_should_assign_successfully
11
- it_should_output "<w:ptab w:alignment=\"center\"/>"
12
- end
13
-
14
- with_value(:left) do
15
- it_should_assign_successfully
16
- it_should_output "<w:ptab w:alignment=\"left\"/>"
17
- end
8
+ with_no_attributes_set do
9
+ it_should_output "<w:ptab/>", assign: false
10
+ end
18
11
 
19
- with_value(:right) do
12
+ for_attribute(:alignment, with_namespace: :w) do
13
+ allowed = %i(center left right)
14
+ with_values(allowed) do
20
15
  it_should_assign_successfully
21
- it_should_output "<w:ptab w:alignment=\"right\"/>"
16
+ it_should_output_regular_xml
22
17
  end
23
18
 
24
19
  with_value(:somethingElse) do
@@ -26,30 +21,11 @@ describe OpenXml::Docx::Elements::AbsolutePositionTab do
26
21
  end
27
22
  end
28
23
 
29
- for_attribute(:leader) do
30
- with_value(:dot) do
31
- it_should_assign_successfully
32
- it_should_output "<w:ptab w:leader=\"dot\"/>"
33
- end
34
-
35
- with_value(:hyphen) do
36
- it_should_assign_successfully
37
- it_should_output "<w:ptab w:leader=\"hyphen\"/>"
38
- end
39
-
40
- with_value(:middleDot) do
24
+ for_attribute(:leader, with_namespace: :w) do
25
+ allowed = %i(dot hyphen middleDot none underscore)
26
+ with_values(allowed) do
41
27
  it_should_assign_successfully
42
- it_should_output "<w:ptab w:leader=\"middleDot\"/>"
43
- end
44
-
45
- with_value(:none) do
46
- it_should_assign_successfully
47
- it_should_output "<w:ptab w:leader=\"none\"/>"
48
- end
49
-
50
- with_value(:underscore) do
51
- it_should_assign_successfully
52
- it_should_output "<w:ptab w:leader=\"underscore\"/>"
28
+ it_should_output_regular_xml
53
29
  end
54
30
 
55
31
  with_value(:somethingElse) do
@@ -57,15 +33,11 @@ describe OpenXml::Docx::Elements::AbsolutePositionTab do
57
33
  end
58
34
  end
59
35
 
60
- for_attribute(:relativeTo) do
61
- with_value(:indent) do
36
+ for_attribute(:relativeTo, with_namespace: :w) do
37
+ allowed = %i(indent margin)
38
+ with_values(allowed) do
62
39
  it_should_assign_successfully
63
- it_should_output "<w:ptab w:relativeTo=\"indent\"/>"
64
- end
65
-
66
- with_value(:margin) do
67
- it_should_assign_successfully
68
- it_should_output "<w:ptab w:relativeTo=\"margin\"/>"
40
+ it_should_output_regular_xml
69
41
  end
70
42
 
71
43
  with_value(:somethingElse) do
@@ -73,10 +45,6 @@ describe OpenXml::Docx::Elements::AbsolutePositionTab do
73
45
  end
74
46
  end
75
47
 
76
- with_no_attributes_set do
77
- it_should_output "<w:ptab/>", assign: false
78
- end
79
-
80
48
  with_these_attributes_set(alignment: :center, relativeTo: :margin) do
81
49
  it_should_output "<w:ptab w:alignment=\"center\" w:relativeTo=\"margin\"/>", assign: false
82
50
  end
@@ -5,15 +5,11 @@ describe OpenXml::Docx::Elements::BidiEmbed do
5
5
 
6
6
  it_should_use tag: :dir, name: "bidi_embed"
7
7
 
8
- for_attribute(:direction) do
9
- with_value(:rtl) do
8
+ for_attribute(:direction, displays_as: :val, with_namespace: :w) do
9
+ allowed = %i(rtl ltr)
10
+ with_values(allowed) do
10
11
  it_should_assign_successfully
11
- it_should_output "<w:dir w:val=\"rtl\"/>"
12
- end
13
-
14
- with_value(:ltr) do
15
- it_should_assign_successfully
16
- it_should_output "<w:dir w:val=\"ltr\"/>"
12
+ it_should_output_regular_xml
17
13
  end
18
14
  end
19
15
 
@@ -5,15 +5,11 @@ describe OpenXml::Docx::Elements::BidiOverride do
5
5
 
6
6
  it_should_use tag: :bdo, name: "bidi_override"
7
7
 
8
- for_attribute(:direction) do
9
- with_value(:rtl) do
8
+ for_attribute(:direction, displays_as: :val, with_namespace: :w) do
9
+ allowed = %i(rtl ltr)
10
+ with_values(allowed) do
10
11
  it_should_assign_successfully
11
- it_should_output "<w:bdo w:val=\"rtl\"/>"
12
- end
13
-
14
- with_value(:ltr) do
15
- it_should_assign_successfully
16
- it_should_output "<w:bdo w:val=\"ltr\"/>"
12
+ it_should_output_regular_xml
17
13
  end
18
14
  end
19
15
 
@@ -5,25 +5,11 @@ describe OpenXml::Docx::Elements::Break do
5
5
 
6
6
  it_should_use tag: :br, name: "break"
7
7
 
8
- for_attribute(:clear) do
9
- with_value(:all) do
8
+ for_attribute(:clear, with_namespace: :w) do
9
+ allowed = %i(all left none right)
10
+ with_values(allowed) do
10
11
  it_should_assign_successfully
11
- it_should_output "<w:br w:clear=\"all\"/>"
12
- end
13
-
14
- with_value(:left) do
15
- it_should_assign_successfully
16
- it_should_output "<w:br w:clear=\"left\"/>"
17
- end
18
-
19
- with_value(:none) do
20
- it_should_assign_successfully
21
- it_should_output "<w:br w:clear=\"none\"/>"
22
- end
23
-
24
- with_value(:right) do
25
- it_should_assign_successfully
26
- it_should_output "<w:br w:clear=\"right\"/>"
12
+ it_should_output_regular_xml
27
13
  end
28
14
 
29
15
  with_value(:somethingElse) do
@@ -31,20 +17,11 @@ describe OpenXml::Docx::Elements::Break do
31
17
  end
32
18
  end
33
19
 
34
- for_attribute(:type) do
35
- with_value(:column) do
36
- it_should_assign_successfully
37
- it_should_output "<w:br w:type=\"column\"/>"
38
- end
39
-
40
- with_value(:page) do
41
- it_should_assign_successfully
42
- it_should_output "<w:br w:type=\"page\"/>"
43
- end
44
-
45
- with_value(:textWrapping) do
20
+ for_attribute(:type, with_namespace: :w) do
21
+ allowed = %i(column page textWrapping)
22
+ with_values(allowed) do
46
23
  it_should_assign_successfully
47
- it_should_output "<w:br w:type=\"textWrapping\"/>"
24
+ it_should_output_regular_xml
48
25
  end
49
26
 
50
27
  with_value(:somethingElse) do
@@ -5,10 +5,10 @@ describe OpenXml::Docx::Elements::ContentPart do
5
5
 
6
6
  it_should_use tag: :contentPart, name: "content_part"
7
7
 
8
- for_attribute(:id) do
8
+ for_attribute(:id, with_namespace: :r) do
9
9
  with_value("rId8") do
10
10
  it_should_assign_successfully
11
- it_should_output "<w:contentPart r:id=\"rId8\"/>"
11
+ it_should_output_regular_xml
12
12
  end
13
13
 
14
14
  with_value("") do
@@ -5,10 +5,10 @@ describe OpenXml::Docx::Elements::Control do
5
5
 
6
6
  it_should_use tag: :control, name: "control"
7
7
 
8
- for_attribute(:id) do
8
+ for_attribute(:id, with_namespace: :r) do
9
9
  with_value("rId5") do
10
10
  it_should_assign_successfully
11
- it_should_output "<w:control r:id=\"rId5\"/>"
11
+ it_should_output_regular_xml
12
12
  end
13
13
 
14
14
  with_value("") do
@@ -16,10 +16,10 @@ describe OpenXml::Docx::Elements::Control do
16
16
  end
17
17
  end
18
18
 
19
- for_attribute(:unique_name) do
19
+ for_attribute(:unique_name, displays_as: :name, with_namespace: :w) do
20
20
  with_value("CheckBox1") do
21
21
  it_should_assign_successfully
22
- it_should_output "<w:control w:name=\"CheckBox1\"/>"
22
+ it_should_output_regular_xml
23
23
  end
24
24
 
25
25
  with_value("") do
@@ -27,10 +27,10 @@ describe OpenXml::Docx::Elements::Control do
27
27
  end
28
28
  end
29
29
 
30
- for_attribute(:shape_id) do
30
+ for_attribute(:shape_id, displays_as: :shapeid, with_namespace: :w) do
31
31
  with_value("_x0000_s1027") do
32
32
  it_should_assign_successfully
33
- it_should_output "<w:control w:shapeid=\"_x0000_s1027\"/>"
33
+ it_should_output_regular_xml
34
34
  end
35
35
 
36
36
  with_value("") do
@@ -5,7 +5,7 @@ describe OpenXml::Docx::Elements::DeletedText do
5
5
 
6
6
  it_should_use tag: :del, name: "deleted_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:del/>"
@@ -13,7 +13,7 @@ describe OpenXml::Docx::Elements::DeletedText do
13
13
 
14
14
  with_value(:preserve) do
15
15
  it_should_assign_successfully
16
- it_should_output "<w:del 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,11 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::Docx::Elements::Drawing do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :drawing, name: "drawing"
7
+
8
+ with_no_attributes_set do
9
+ it_should_output "<w:drawing/>", assign: false
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::AdjustValuesList do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :avLst, name: "adjust_values_list"
7
+
8
+ end
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::BlipFill do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :blipFill, name: "blip_fill"
7
+
8
+ for_attribute(:dpi) do
9
+ with_values([1, -1]) do
10
+ it_should_assign_successfully
11
+ it_should_output_regular_xml
12
+ end
13
+
14
+ with_value(:not_a_number) do
15
+ it_should_raise_an_exception
16
+ end
17
+ end
18
+
19
+ for_attribute(:rotWithShape) do
20
+ with_values([true, false]) do
21
+ it_should_assign_successfully
22
+ it_should_output_regular_xml
23
+ end
24
+
25
+ with_value(:not_a_boolean) do
26
+ it_should_raise_an_exception
27
+ end
28
+ end
29
+
30
+ with_no_attributes_set do
31
+ it_should_output "<pic:blipFill/>", assign: false
32
+ end
33
+
34
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::ExtensionList do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :extLst, name: "extension_list"
7
+
8
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::Extension do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :ext, name: "extension"
7
+
8
+ for_attribute(:uri) do
9
+ with_value("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") do
10
+ it_should_assign_successfully
11
+ it_should_output "<a:ext uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"/>"
12
+ end
13
+
14
+ with_value(:not_a_string) do
15
+ it_should_raise_an_exception
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::Extents do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :ext, name: "extents"
7
+
8
+ attributes = { extent_length: :cx, extent_width: :cy }
9
+
10
+ for_attribute(:extent_length, displays_as: :cx) do
11
+ with_value(1) do
12
+ it_should_assign_successfully
13
+ it_should_output_regular_xml
14
+ end
15
+
16
+ with_values([-1, 1.1, :not_a_number]) do
17
+ it_should_raise_an_exception
18
+ end
19
+ end
20
+
21
+ for_attribute(:extent_width, displays_as: :cy) do
22
+ with_value(1) do
23
+ it_should_assign_successfully
24
+ it_should_output_regular_xml
25
+ end
26
+
27
+ with_values([-1, 1.1, :not_a_number]) do
28
+ it_should_raise_an_exception
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::GraphicData do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :graphicData, name: "graphic_data"
7
+
8
+ for_attribute(:uri) do
9
+ with_value("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") do
10
+ it_should_assign_successfully
11
+ it_should_output "<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"/>"
12
+ end
13
+
14
+ with_value(:not_a_string) do
15
+ it_should_raise_an_exception
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,78 @@
1
+ require "spec_helper"
2
+
3
+ describe OpenXml::DrawingML::Elements::GraphicFrameLocks do
4
+ include ElementTestMacros
5
+
6
+ it_should_use tag: :graphicFrameLocks, name: "graphic_frame_locks"
7
+
8
+ for_attribute(:noChangeAspect) do
9
+ with_values([true, false]) do
10
+ it_should_assign_successfully
11
+ it_should_output_regular_xml
12
+ end
13
+
14
+ with_value(:neither) do
15
+ it_should_raise_an_exception
16
+ end
17
+ end
18
+
19
+ for_attribute(:noDrilldown) do
20
+ with_values([true, false]) do
21
+ it_should_assign_successfully
22
+ it_should_output_regular_xml
23
+ end
24
+
25
+ with_value(:neither) do
26
+ it_should_raise_an_exception
27
+ end
28
+ end
29
+
30
+ for_attribute(:noGrouping, displays_as: :noGrp) do
31
+ with_values([true, false]) do
32
+ it_should_assign_successfully
33
+ it_should_output_regular_xml
34
+ end
35
+
36
+ with_value(:neither) do
37
+ it_should_raise_an_exception
38
+ end
39
+ end
40
+
41
+ for_attribute(:noMove) do
42
+ with_values([true, false]) do
43
+ it_should_assign_successfully
44
+ it_should_output_regular_xml
45
+ end
46
+
47
+ with_value(:neither) do
48
+ it_should_raise_an_exception
49
+ end
50
+ end
51
+
52
+ for_attribute(:noResize) do
53
+ with_values([true, false]) do
54
+ it_should_assign_successfully
55
+ it_should_output_regular_xml
56
+ end
57
+
58
+ with_value(:neither) do
59
+ it_should_raise_an_exception
60
+ end
61
+ end
62
+
63
+ for_attribute(:noSelect) do
64
+ with_values([true, false]) do
65
+ it_should_assign_successfully
66
+ it_should_output_regular_xml
67
+ end
68
+
69
+ with_value(:neither) do
70
+ it_should_raise_an_exception
71
+ end
72
+ end
73
+
74
+ with_no_attributes_set do
75
+ it_should_output "<a:graphicFrameLocks/>", assign: false
76
+ end
77
+
78
+ end