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.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/examples/drawing-ml +134 -0
- data/examples/table +28 -0
- data/lib/openxml/docx.rb +9 -0
- data/lib/openxml/docx/attribute_builder.rb +17 -4
- data/lib/openxml/docx/elements/absolute_position_tab.rb +4 -19
- data/lib/openxml/docx/elements/bidi_embed.rb +1 -10
- data/lib/openxml/docx/elements/bidi_override.rb +1 -9
- data/lib/openxml/docx/elements/break.rb +3 -14
- data/lib/openxml/docx/elements/control.rb +5 -2
- data/lib/openxml/docx/elements/deleted_text.rb +1 -1
- data/lib/openxml/docx/elements/drawing.rb +9 -0
- data/lib/openxml/docx/elements/element.rb +2 -1
- data/lib/openxml/docx/elements/embed_bold.rb +25 -0
- data/lib/openxml/docx/elements/embed_bold_italic.rb +25 -0
- data/lib/openxml/docx/elements/embed_italic.rb +25 -0
- data/lib/openxml/docx/elements/embed_regular.rb +25 -0
- data/lib/openxml/docx/elements/family.rb +22 -0
- data/lib/openxml/docx/elements/font.rb +14 -0
- data/lib/openxml/docx/elements/grid_column.rb +2 -2
- data/lib/openxml/docx/elements/group_shape.rb +10 -0
- data/lib/openxml/docx/elements/markup_compatibility_alternate_content.rb +10 -0
- data/lib/openxml/docx/elements/markup_compatibility_choice.rb +13 -0
- data/lib/openxml/docx/elements/markup_compatibility_fallback.rb +10 -0
- data/lib/openxml/docx/elements/paper_source.rb +4 -2
- data/lib/openxml/docx/elements/section_properties.rb +9 -0
- data/lib/openxml/docx/elements/symbol.rb +4 -2
- data/lib/openxml/docx/elements/table.rb +1 -1
- data/lib/openxml/docx/elements/table_cell.rb +2 -1
- data/lib/openxml/docx/elements/table_row.rb +7 -5
- data/lib/openxml/docx/elements/text.rb +1 -10
- data/lib/openxml/docx/elements/vml_container.rb +10 -0
- data/lib/openxml/docx/elements/word_processing_drawing_anchor.rb +23 -0
- data/lib/openxml/docx/elements/word_processing_drawing_effect_extent.rb +16 -0
- data/lib/openxml/docx/elements/word_processing_drawing_extent.rb +14 -0
- data/lib/openxml/docx/elements/word_processing_drawing_nv_graphic_frame_properties.rb +11 -0
- data/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb +17 -0
- data/lib/openxml/docx/elements/word_processing_drawing_position_h.rb +23 -0
- data/lib/openxml/docx/elements/word_processing_drawing_position_offset.rb +10 -0
- data/lib/openxml/docx/elements/word_processing_drawing_position_v.rb +23 -0
- data/lib/openxml/docx/elements/word_processing_drawing_simple_position.rb +13 -0
- data/lib/openxml/docx/elements/word_processing_drawing_wrap_none.rb +10 -0
- data/lib/openxml/docx/elements/word_processing_shapes_body_properties.rb +58 -0
- data/lib/openxml/docx/elements/word_processing_shapes_shape.rb +12 -0
- data/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb +23 -0
- data/lib/openxml/docx/package.rb +73 -1
- data/lib/openxml/docx/parts/document.rb +6 -24
- data/lib/openxml/docx/parts/fonts.rb +35 -0
- data/lib/openxml/docx/parts/footer.rb +32 -0
- data/lib/openxml/docx/parts/header.rb +32 -0
- data/lib/openxml/docx/parts/settings.rb +6 -2
- data/lib/openxml/docx/parts/styles.rb +5 -6
- data/lib/openxml/docx/properties.rb +0 -1
- data/lib/openxml/docx/properties/alignment.rb +1 -1
- data/lib/openxml/docx/properties/base_property.rb +13 -0
- data/lib/openxml/docx/properties/border.rb +11 -9
- data/lib/openxml/docx/properties/color.rb +6 -4
- data/lib/openxml/docx/properties/column.rb +4 -2
- data/lib/openxml/docx/properties/columns.rb +6 -4
- data/lib/openxml/docx/properties/complex_property.rb +1 -1
- data/lib/openxml/docx/properties/conditional_formatting.rb +14 -12
- data/lib/openxml/docx/properties/document_grid.rb +4 -10
- data/lib/openxml/docx/properties/east_asian_layout.rb +6 -11
- data/lib/openxml/docx/properties/font.rb +18 -22
- data/lib/openxml/docx/properties/footer_reference.rb +21 -0
- data/lib/openxml/docx/properties/frame.rb +16 -47
- data/lib/openxml/docx/properties/header_reference.rb +21 -0
- data/lib/openxml/docx/properties/indentation.rb +11 -8
- data/lib/openxml/docx/properties/language.rb +5 -3
- data/lib/openxml/docx/properties/latent_styles.rb +9 -6
- data/lib/openxml/docx/properties/latent_styles_exception.rb +9 -6
- data/lib/openxml/docx/properties/line_numbering.rb +5 -11
- data/lib/openxml/docx/properties/manual_width.rb +4 -2
- data/lib/openxml/docx/properties/numbering.rb +4 -2
- data/lib/openxml/docx/properties/page_borders.rb +6 -19
- data/lib/openxml/docx/properties/page_margins.rb +10 -7
- data/lib/openxml/docx/properties/page_numbering.rb +66 -74
- data/lib/openxml/docx/properties/page_size.rb +5 -12
- data/lib/openxml/docx/properties/shading.rb +46 -52
- data/lib/openxml/docx/properties/spacing.rb +9 -14
- data/lib/openxml/docx/properties/table_border.rb +12 -10
- data/lib/openxml/docx/properties/table_cell_border.rb +12 -10
- data/lib/openxml/docx/properties/table_cell_margin.rb +6 -4
- data/lib/openxml/docx/properties/table_cell_spacing.rb +5 -3
- data/lib/openxml/docx/properties/table_cell_width.rb +5 -3
- data/lib/openxml/docx/properties/table_indent.rb +5 -3
- data/lib/openxml/docx/properties/table_layout.rb +2 -4
- data/lib/openxml/docx/properties/table_look.rb +8 -6
- data/lib/openxml/docx/properties/table_p_pr.rb +11 -30
- data/lib/openxml/docx/properties/table_row_height.rb +13 -0
- data/lib/openxml/docx/properties/table_width.rb +5 -3
- data/lib/openxml/docx/properties/underline.rb +13 -12
- data/lib/openxml/docx/properties/wafter.rb +5 -3
- data/lib/openxml/docx/properties/wbefore.rb +5 -3
- data/lib/openxml/docx/root_namespaces.rb +74 -0
- data/lib/openxml/docx/section.rb +2 -0
- data/lib/openxml/docx/style.rb +4 -4
- data/lib/openxml/docx/version.rb +1 -1
- data/lib/openxml/drawingml.rb +17 -0
- data/lib/openxml/drawingml/elements.rb +13 -0
- data/lib/openxml/drawingml/elements/adjust_values_list.rb +11 -0
- data/lib/openxml/drawingml/elements/blip_fill.rb +14 -0
- data/lib/openxml/drawingml/elements/extension.rb +13 -0
- data/lib/openxml/drawingml/elements/extension_list.rb +11 -0
- data/lib/openxml/drawingml/elements/extents.rb +14 -0
- data/lib/openxml/drawingml/elements/graphic.rb +10 -0
- data/lib/openxml/drawingml/elements/graphic_data.rb +12 -0
- data/lib/openxml/drawingml/elements/graphic_frame_locks.rb +17 -0
- data/lib/openxml/drawingml/elements/head_end.rb +28 -0
- data/lib/openxml/drawingml/elements/no_fill.rb +10 -0
- data/lib/openxml/drawingml/elements/non_visual_drawing_properties.rb +17 -0
- data/lib/openxml/drawingml/elements/non_visual_picture_drawing_properties.rb +12 -0
- data/lib/openxml/drawingml/elements/non_visual_picture_properties.rb +10 -0
- data/lib/openxml/drawingml/elements/offset.rb +14 -0
- data/lib/openxml/drawingml/elements/outline.rb +36 -0
- data/lib/openxml/drawingml/elements/picture.rb +10 -0
- data/lib/openxml/drawingml/elements/preset_geometry.rb +210 -0
- data/lib/openxml/drawingml/elements/round.rb +10 -0
- data/lib/openxml/drawingml/elements/shape_guide.rb +40 -0
- data/lib/openxml/drawingml/elements/solid_fill.rb +10 -0
- data/lib/openxml/drawingml/elements/srgb_color.rb +14 -0
- data/lib/openxml/drawingml/elements/tail_end.rb +28 -0
- data/lib/openxml/drawingml/elements/transform_effect.rb +18 -0
- data/lib/openxml/drawingml/elements/wordprocessing_shape_group.rb +11 -0
- data/lib/openxml/vml.rb +17 -0
- data/lib/openxml/vml/elements.rb +13 -0
- data/lib/openxml/vml/elements/group.rb +88 -0
- data/lib/openxml/vml/elements/rectangle.rb +115 -0
- data/lib/openxml/vml/elements/rounded_rectangle.rb +121 -0
- data/openxml-docx.gemspec +1 -1
- data/spec/elements/absolute_position_tab_spec.rb +15 -47
- data/spec/elements/bidi_embed_spec.rb +4 -8
- data/spec/elements/bidi_override_spec.rb +4 -8
- data/spec/elements/break_spec.rb +8 -31
- data/spec/elements/content_part_spec.rb +2 -2
- data/spec/elements/control_spec.rb +6 -6
- data/spec/elements/deleted_text_spec.rb +2 -2
- data/spec/elements/drawing_spec.rb +11 -0
- data/spec/elements/drawingml/adjust_values_list_spec.rb +8 -0
- data/spec/elements/drawingml/blip_fill_spec.rb +34 -0
- data/spec/elements/drawingml/extension_list_spec.rb +8 -0
- data/spec/elements/drawingml/extension_spec.rb +19 -0
- data/spec/elements/drawingml/extents_spec.rb +33 -0
- data/spec/elements/drawingml/graphic_data_spec.rb +19 -0
- data/spec/elements/drawingml/graphic_frame_locks_spec.rb +78 -0
- data/spec/elements/drawingml/graphic_spec.rb +8 -0
- data/spec/elements/drawingml/head_end_spec.rb +45 -0
- data/spec/elements/drawingml/no_fill_spec.rb +8 -0
- data/spec/elements/drawingml/non_visual_drawing_properties_spec.rb +63 -0
- data/spec/elements/drawingml/non_visual_picture_drawing_properties_spec.rb +18 -0
- data/spec/elements/drawingml/non_visual_picture_properties_spec.rb +8 -0
- data/spec/elements/drawingml/offset_spec.rb +32 -0
- data/spec/elements/drawingml/outline_spec.rb +58 -0
- data/spec/elements/drawingml/picture_spec.rb +8 -0
- data/spec/elements/drawingml/preset_geometry_spec.rb +19 -0
- data/spec/elements/drawingml/round_spec.rb +8 -0
- data/spec/elements/drawingml/shape_guide_spec.rb +49 -0
- data/spec/elements/drawingml/solid_fill_spec.rb +8 -0
- data/spec/elements/drawingml/srgb_color_spec.rb +20 -0
- data/spec/elements/drawingml/tail_end_spec.rb +44 -0
- data/spec/elements/drawingml/transform_effect_spec.rb +80 -0
- data/spec/elements/drawingml/wordprocessing_shape_group_spec.rb +12 -0
- data/spec/elements/group_shape_spec.rb +11 -0
- data/spec/elements/markup_compatibility_alternate_content_spec.rb +11 -0
- data/spec/elements/markup_compatibility_choice_spec.rb +22 -0
- data/spec/elements/markup_compatibility_fallback_spec.rb +11 -0
- data/spec/elements/section_properties_spec.rb +12 -0
- data/spec/elements/symbol_spec.rb +4 -7
- data/spec/elements/text_spec.rb +2 -2
- data/spec/elements/vml/group_spec.rb +542 -0
- data/spec/elements/vml/rectangle_spec.rb +739 -0
- data/spec/elements/vml/rounded_rectangle_spec.rb +656 -0
- data/spec/elements/vml_container_spec.rb +11 -0
- data/spec/elements/word_processing_drawing_anchor_spec.rb +40 -0
- data/spec/elements/word_processing_drawing_effect_extent_spec.rb +57 -0
- data/spec/elements/word_processing_drawing_extent_spec.rb +34 -0
- data/spec/elements/word_processing_drawing_nv_graphic_frame_properties_spec.rb +11 -0
- data/spec/elements/word_processing_drawing_object_nv_properties_spec.rb +67 -0
- data/spec/elements/word_processing_drawing_position_h_spec.rb +21 -0
- data/spec/elements/word_processing_drawing_position_v_spec.rb +21 -0
- data/spec/elements/word_processing_drawing_simple_position_spec.rb +34 -0
- data/spec/elements/word_processing_drawing_wrap_none_spec.rb +12 -0
- data/spec/elements/word_processing_shapes_body_properties_spec.rb +223 -0
- data/spec/elements/word_processing_shapes_shape_properties_spec.rb +21 -0
- data/spec/elements/word_processing_shapes_shape_spec.rb +23 -0
- data/spec/parts/footer_spec.rb +33 -0
- data/spec/parts/header_spec.rb +33 -0
- data/spec/properties/footer_reference_spec.rb +32 -0
- data/spec/properties/header_reference_spec.rb +32 -0
- data/spec/properties/page_numbering_spec.rb +1 -1
- data/spec/properties/{table_cell_fit_text.rb → table_cell_fit_text_spec.rb} +0 -0
- data/spec/properties/{table_cell_width.rb → table_cell_width_spec.rb} +0 -0
- data/spec/properties/table_layout_spec.rb +14 -12
- data/spec/properties/{table_row_height.rb → table_row_height_spec.rb} +0 -0
- data/spec/section_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/data/elements/grid_column_element.xml +1 -1
- data/spec/support/data/elements/table_grid_element.xml +1 -1
- data/spec/support/data/parts/document_with_children_part.xml +2 -1
- data/spec/support/data/parts/document_with_multiple_sections_part.xml +1 -1
- data/spec/support/data/parts/document_with_one_section_part.xml +1 -1
- data/spec/support/data/parts/empty_document_part.xml +1 -1
- data/spec/support/data/parts/empty_footer_part.xml +1 -0
- data/spec/support/data/parts/empty_header_part.xml +1 -0
- data/spec/support/data/parts/footer_with_children_part.xml +1 -0
- data/spec/support/data/parts/header_with_children_part.xml +1 -0
- data/spec/support/element_test_macros.rb +58 -9
- metadata +126 -9
- data/lib/openxml/docx/properties/tr_height.rb +0 -19
- data/lib/openxml/docx/properties/width_property.rb +0 -17
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::HeadEnd do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :headEnd, name: "head_end"
|
7
|
+
|
8
|
+
for_attribute(:length, displays_as: :len) do
|
9
|
+
allowed = %i(lg med sm)
|
10
|
+
with_values(allowed) do
|
11
|
+
it_should_assign_successfully
|
12
|
+
it_should_output_regular_xml
|
13
|
+
end
|
14
|
+
|
15
|
+
with_value(:bad_value) do
|
16
|
+
it_should_raise_an_exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
for_attribute(:type) do
|
21
|
+
allowed = %i(arrow diamond none oval stealth triangle)
|
22
|
+
with_values(allowed) do
|
23
|
+
it_should_assign_successfully
|
24
|
+
it_should_output_regular_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
with_value(:bad_value) do
|
28
|
+
it_should_raise_an_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
for_attribute(:width, displays_as: :w) do
|
33
|
+
allowed = %i(lg med sm)
|
34
|
+
with_values(allowed) do
|
35
|
+
it_should_assign_successfully
|
36
|
+
it_should_output_regular_xml
|
37
|
+
end
|
38
|
+
|
39
|
+
with_value(:bad_value) do
|
40
|
+
it_should_raise_an_exception
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::NonVisualDrawingProperties do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :cNvPr, name: "non_visual_drawing_properties"
|
7
|
+
|
8
|
+
for_attribute(:descr) do
|
9
|
+
with_value("string") do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output_regular_xml
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:not_a_string) do
|
15
|
+
it_should_raise_an_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
for_attribute(:hidden) 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
|
+
for_attribute(:id) do
|
31
|
+
with_value(123) do
|
32
|
+
it_should_assign_successfully
|
33
|
+
it_should_output_regular_xml
|
34
|
+
end
|
35
|
+
|
36
|
+
with_values([-123, :not_a_number]) do
|
37
|
+
it_should_raise_an_exception
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
for_attribute(:picture_name, displays_as: :name) do
|
42
|
+
with_value("string") do
|
43
|
+
it_should_assign_successfully
|
44
|
+
it_should_output_regular_xml
|
45
|
+
end
|
46
|
+
|
47
|
+
with_value(:not_a_string) do
|
48
|
+
it_should_raise_an_exception
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
for_attribute(:title) do
|
53
|
+
with_value("string") do
|
54
|
+
it_should_assign_successfully
|
55
|
+
it_should_output_regular_xml
|
56
|
+
end
|
57
|
+
|
58
|
+
with_value(:not_a_string) do
|
59
|
+
it_should_raise_an_exception
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::NonVisualPictureDrawingProperties do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :cNvPicPr, name: "non_visual_picture_drawing_properties"
|
7
|
+
|
8
|
+
for_attribute(:preferRelativeResize) do
|
9
|
+
with_values([true, false]) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output_regular_xml
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:not_a_boolean) do
|
15
|
+
it_should_raise_an_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::Offset do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :off, name: "offset"
|
7
|
+
|
8
|
+
attributes = %i(x y)
|
9
|
+
|
10
|
+
for_attribute(:x) do
|
11
|
+
with_values([1, -1]) do
|
12
|
+
it_should_assign_successfully
|
13
|
+
it_should_output_regular_xml
|
14
|
+
end
|
15
|
+
|
16
|
+
with_values([1.1, :not_a_number]) do
|
17
|
+
it_should_raise_an_exception
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
for_attribute(:y) do
|
22
|
+
with_values([1, -1]) do
|
23
|
+
it_should_assign_successfully
|
24
|
+
it_should_output_regular_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
with_values([1.1, :not_a_number]) do
|
28
|
+
it_should_raise_an_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::Outline do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :ln, name: "outline"
|
7
|
+
|
8
|
+
for_attribute(:alignment, displays_as: :algn) do
|
9
|
+
allowed = %i(ctr in)
|
10
|
+
with_values(allowed) do
|
11
|
+
it_should_assign_successfully
|
12
|
+
it_should_output_regular_xml
|
13
|
+
end
|
14
|
+
|
15
|
+
with_value(:not_ok) do
|
16
|
+
it_should_raise_an_exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
for_attribute(:cap) do
|
21
|
+
allowed = %i(flat rnd sq)
|
22
|
+
with_values(allowed) do
|
23
|
+
it_should_assign_successfully
|
24
|
+
it_should_output_regular_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
with_value(:not_ok) do
|
28
|
+
it_should_raise_an_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
for_attribute(:compound_type, displays_as: :cmpd) do
|
33
|
+
allowed = %i(dbl sng thickThin thinThick tri)
|
34
|
+
with_values(allowed) do
|
35
|
+
it_should_assign_successfully
|
36
|
+
it_should_output_regular_xml
|
37
|
+
end
|
38
|
+
|
39
|
+
with_value(:not_ok) do
|
40
|
+
it_should_raise_an_exception
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
for_attribute(:width, displays_as: :w) do
|
45
|
+
with_value(1) do
|
46
|
+
it_should_assign_successfully
|
47
|
+
it_should_output_regular_xml
|
48
|
+
end
|
49
|
+
|
50
|
+
with_values([1.1, -1]) do
|
51
|
+
it_should_raise_an_exception
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::PresetGeometry do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :prstGeom, name: "preset_geometry"
|
7
|
+
|
8
|
+
for_attribute(:preset, displays_as: :prst) do
|
9
|
+
with_value(:roundRect) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output_regular_xml
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:invalidGeometry) do
|
15
|
+
it_should_raise_an_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::ShapeGuide do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :gd, name: "shape_guide"
|
7
|
+
|
8
|
+
formulae = [ "*/ h 10 -100",
|
9
|
+
"+- h 10 -100",
|
10
|
+
"+/ h 10 -100",
|
11
|
+
"?: h 10 -100",
|
12
|
+
"abs -100",
|
13
|
+
"at2 h w",
|
14
|
+
"cat2 h w 100",
|
15
|
+
"cos h w",
|
16
|
+
"max 100 200",
|
17
|
+
"min 100 200",
|
18
|
+
"mod h w 10",
|
19
|
+
"pin h 10 -100",
|
20
|
+
"sat2 h 10 -100",
|
21
|
+
"sin h w",
|
22
|
+
"sqrt 4",
|
23
|
+
"tan h w",
|
24
|
+
"val 100" ] # Arguments to formulae can be a variable, a positive integer, or a negative integer
|
25
|
+
|
26
|
+
for_attribute(:guide_name, displays_as: :name) do
|
27
|
+
with_value("Some String") do
|
28
|
+
it_should_assign_successfully
|
29
|
+
it_should_output_regular_xml
|
30
|
+
end
|
31
|
+
|
32
|
+
with_values([1, :not_a_string]) do
|
33
|
+
it_should_raise_an_exception
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
for_attribute(:formula, displays_as: :fmla) do
|
38
|
+
with_values(formulae) do
|
39
|
+
it_should_assign_successfully
|
40
|
+
it_should_output_regular_xml
|
41
|
+
end
|
42
|
+
|
43
|
+
not_allowed = ["a^2 + b^2 = c^2", "Not a formula", 2 ]
|
44
|
+
with_values(not_allowed) do # Not a valid formula
|
45
|
+
it_should_raise_an_exception
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::SRGBColor do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :srgbClr, name: "srgb_color"
|
7
|
+
|
8
|
+
for_attribute(:value, displays_as: :val) do
|
9
|
+
with_value("FFFFFF") do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output_regular_xml
|
12
|
+
end
|
13
|
+
|
14
|
+
not_allowed = ["blue", :blue, 23]
|
15
|
+
with_values(not_allowed) do
|
16
|
+
it_should_raise_an_exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::TailEnd do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :tailEnd, name: "tail_end"
|
7
|
+
|
8
|
+
for_attribute(:length, displays_as: :len) do
|
9
|
+
allowed = %i(lg med sm)
|
10
|
+
with_values(allowed) do
|
11
|
+
it_should_assign_successfully
|
12
|
+
it_should_output_regular_xml
|
13
|
+
end
|
14
|
+
|
15
|
+
with_value(:bad_value) do
|
16
|
+
it_should_raise_an_exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
for_attribute(:type) do
|
21
|
+
allowed = %i(arrow diamond none oval stealth triangle)
|
22
|
+
with_values(allowed) do
|
23
|
+
it_should_assign_successfully
|
24
|
+
it_should_output_regular_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
with_value(:bad_value) do
|
28
|
+
it_should_raise_an_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
for_attribute(:width, displays_as: :w) do
|
33
|
+
allowed = %i(lg med sm)
|
34
|
+
with_values(allowed) do
|
35
|
+
it_should_assign_successfully
|
36
|
+
it_should_output_regular_xml
|
37
|
+
end
|
38
|
+
|
39
|
+
with_value(:bad_value) do
|
40
|
+
it_should_raise_an_exception
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OpenXml::DrawingML::Elements::TransformEffect do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :xfrm, name: "transform_effect"
|
7
|
+
|
8
|
+
for_attribute(:horizontal_skew, displays_as: :kx) 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(:vertical_skew, displays_as: :ky) do
|
20
|
+
with_values([1, -1]) do
|
21
|
+
it_should_assign_successfully
|
22
|
+
it_should_output_regular_xml
|
23
|
+
end
|
24
|
+
|
25
|
+
with_value(:not_a_number) do
|
26
|
+
it_should_raise_an_exception
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
for_attribute(:horizontal_shift, displays_as: :tx) do
|
31
|
+
with_values([1, -1]) do
|
32
|
+
it_should_assign_successfully
|
33
|
+
it_should_output_regular_xml
|
34
|
+
end
|
35
|
+
|
36
|
+
with_value(:not_a_number) do
|
37
|
+
it_should_raise_an_exception
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
for_attribute(:vertical_shift, displays_as: :ty) do
|
42
|
+
with_values([1, -1]) do
|
43
|
+
it_should_assign_successfully
|
44
|
+
it_should_output_regular_xml
|
45
|
+
end
|
46
|
+
|
47
|
+
with_value(:not_a_number) do
|
48
|
+
it_should_raise_an_exception
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
for_attribute(:horizontal_ratio, displays_as: :sx) do
|
53
|
+
allowed = %w(1% -1% 1.1%)
|
54
|
+
with_values(allowed) do
|
55
|
+
it_should_assign_successfully
|
56
|
+
it_should_output_regular_xml
|
57
|
+
end
|
58
|
+
|
59
|
+
with_values(["1", 1]) do
|
60
|
+
it_should_raise_an_exception
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
for_attribute(:vertical_ratio, displays_as: :sy) do
|
65
|
+
allowed = %w(1% -1% 1.1%)
|
66
|
+
with_values(allowed) do
|
67
|
+
it_should_assign_successfully
|
68
|
+
it_should_output_regular_xml
|
69
|
+
end
|
70
|
+
|
71
|
+
with_values(["1", 1]) do
|
72
|
+
it_should_raise_an_exception
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
with_no_attributes_set do
|
77
|
+
it_should_output "<a:xfrm/>", assign: false
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|