openxml-docx 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,5 +1,5 @@
1
1
  module OpenXml
2
2
  module Docx
3
- VERSION = "0.10.1"
3
+ VERSION = "0.10.2"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ module OpenXml
6
6
  tag :blipFill
7
7
 
8
8
  attribute :dpi, expects: :integer
9
- attribute :rotate_with_shape, expects: :true_or_false, displays_as: :rotWithShape
9
+ attribute :rotate_with_shape, expects: :boolean, displays_as: :rotWithShape
10
10
 
11
11
  end
12
12
  end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module DrawingML
3
+ module Elements
4
+ class ChildrenExtents < OpenXml::Docx::Elements::Element
5
+ namespace :a
6
+ tag :chExt
7
+
8
+ attribute :extent_length, expects: :positive_integer, displays_as: :cx
9
+ attribute :extent_width, expects: :positive_integer, displays_as: :cy
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module DrawingML
3
+ module Elements
4
+ class ChildrenOffset < OpenXml::Docx::Elements::Element
5
+ namespace :a
6
+ tag :chOff
7
+
8
+ attribute :x, expects: :integer
9
+ attribute :y, expects: :integer
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,12 +4,12 @@ module OpenXml
4
4
  class GraphicFrameLocks < OpenXml::Docx::Elements::Element
5
5
  namespace :a
6
6
 
7
- attribute :disallow_aspect_ratio_changes, expects: :true_or_false, displays_as: :noChangeAspect
8
- attribute :disallow_drilldown, expects: :true_or_false, displays_as: :noDrilldown
9
- attribute :disallow_grouping, expects: :true_or_false, displays_as: :noGrp
10
- attribute :disallow_moving, expects: :true_or_false, displays_as: :noMove
11
- attribute :disallow_resizing, expects: :true_or_false, displays_as: :noResize
12
- attribute :disallow_selection, expects: :true_or_false, displays_as: :noSelect
7
+ attribute :disallow_aspect_ratio_changes, expects: :boolean, displays_as: :noChangeAspect
8
+ attribute :disallow_drilldown, expects: :boolean, displays_as: :noDrilldown
9
+ attribute :disallow_grouping, expects: :boolean, displays_as: :noGrp
10
+ attribute :disallow_moving, expects: :boolean, displays_as: :noMove
11
+ attribute :disallow_resizing, expects: :boolean, displays_as: :noResize
12
+ attribute :disallow_selection, expects: :boolean, displays_as: :noSelect
13
13
 
14
14
  end
15
15
  end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module DrawingML
3
+ module Elements
4
+ class NoAutofit < OpenXml::Docx::Elements::Element
5
+ namespace :a
6
+ tag :noAutofit
7
+ end
8
+ end
9
+ end
10
+ end
@@ -3,7 +3,7 @@ module OpenXml
3
3
  module Elements
4
4
  class NoFill < OpenXml::Docx::Elements::Element
5
5
  namespace :a
6
-
6
+ tag :noFill
7
7
  end
8
8
  end
9
9
  end
@@ -6,7 +6,7 @@ module OpenXml
6
6
  tag :cNvPr
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 :picture_name, expects: :string, displays_as: :name
12
12
  attribute :title, expects: :string
@@ -5,7 +5,7 @@ module OpenXml
5
5
  namespace :pic
6
6
  tag :cNvPicPr
7
7
 
8
- attribute :preferRelativeResize, expects: :true_or_false
8
+ attribute :preferRelativeResize, expects: :boolean
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,12 @@
1
+ module OpenXml
2
+ module DrawingML
3
+ module Elements
4
+ class NonVisualShapeDrawingProperties < OpenXml::Docx::Elements::Container
5
+ namespace :wps
6
+ tag :cNvSpPr
7
+
8
+ attribute :textbox, expects: :boolean, displays_as: :txBox
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,17 +5,17 @@ module OpenXml
5
5
  namespace :a
6
6
  tag :picLocks
7
7
 
8
- attribute :hide_adjust_handles, expects: :true_or_false, displays_as: :noAdjustHandles
9
- attribute :disallow_arrowhead_changes, expects: :true_or_false, displays_as: :noChangeArrowheads
10
- attribute :disallow_aspect_ratio_changes, expects: :true_or_false, displays_as: :noChangeAspect
11
- attribute :disallow_shape_type_changes, expects: :true_or_false, displays_as: :noChangeShapeType
12
- attribute :disallow_cropping, expects: :true_or_false, displays_as: :noCrop
13
- attribute :disallow_editing_points, expects: :true_or_false, displays_as: :noEditPoints
14
- attribute :disallow_grouping, expects: :true_or_false, displays_as: :noGrp
15
- attribute :disallow_moving, expects: :true_or_false, displays_as: :noMove
16
- attribute :disallow_resizing, expects: :true_or_false, displays_as: :noResize
17
- attribute :disallow_rotation, expects: :true_or_false, displays_as: :noRot
18
- attribute :disallow_selection, expects: :true_or_false, displays_as: :noSelect
8
+ attribute :hide_adjust_handles, expects: :boolean, displays_as: :noAdjustHandles
9
+ attribute :disallow_arrowhead_changes, expects: :boolean, displays_as: :noChangeArrowheads
10
+ attribute :disallow_aspect_ratio_changes, expects: :boolean, displays_as: :noChangeAspect
11
+ attribute :disallow_shape_type_changes, expects: :boolean, displays_as: :noChangeShapeType
12
+ attribute :disallow_cropping, expects: :boolean, displays_as: :noCrop
13
+ attribute :disallow_editing_points, expects: :boolean, displays_as: :noEditPoints
14
+ attribute :disallow_grouping, expects: :boolean, displays_as: :noGrp
15
+ attribute :disallow_moving, expects: :boolean, displays_as: :noMove
16
+ attribute :disallow_resizing, expects: :boolean, displays_as: :noResize
17
+ attribute :disallow_rotation, expects: :boolean, displays_as: :noRot
18
+ attribute :disallow_selection, expects: :boolean, displays_as: :noSelect
19
19
 
20
20
  end
21
21
  end
@@ -0,0 +1,25 @@
1
+ module OpenXml
2
+ module DrawingML
3
+ module Elements
4
+ class PresetTextWarp < OpenXml::Docx::Elements::Container
5
+ namespace :a
6
+ tag :prstTxWarp
7
+
8
+ attribute :preset, one_of: %i(textArchDown textArchDownPour textArchUp
9
+ textArchUpPour textButton textButtonPour
10
+ textCanDown textCanUp textCascadeDown
11
+ textCascadeUp textChevron textChevronInverted
12
+ textCircle textCirclePour textCurveDown
13
+ textCurveUp textDeflate textDeflateBottom
14
+ textDeflateInflate textDeflateTop
15
+ textDoubleWave1 textFadeDown textFadeLeft
16
+ textFadeRight textFadeUp textInflate
17
+ textInflateBottom textInflateTop textNoShape
18
+ textPlain textRingInside textRingOutside
19
+ textSlantDown textSlantUp textStop textTriangle
20
+ textTriangleInverted textWave1 textWave2
21
+ textWave4), displays_as: :prst
22
+ end
23
+ end
24
+ end
25
+ end
@@ -6,45 +6,45 @@ module OpenXml
6
6
 
7
7
  attribute :alt, expects: :string
8
8
  attribute :css_class, expects: :string, displays_as: :class
9
- attribute :coordinate_origin, expects: :valid_coordinate, displays_as: :coordorigin
10
- attribute :coordinate_size, expects: :valid_coordinate, displays_as: :coordsize
9
+ attribute :coordinate_origin, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordorigin
10
+ attribute :coordinate_size, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordsize
11
11
  attribute :edit_as, one_of: %i(bullseye canvas cycle orgchart radial stacked venn), displays_as: :editas
12
12
  attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
13
- attribute :filled, expects: :explicit_true_false
13
+ attribute :filled, expects: :boolean
14
14
  attribute :href, expects: :string
15
15
  attribute :id, expects: :string
16
- attribute :print, expects: :explicit_true_false
16
+ attribute :print, expects: :boolean
17
17
  attribute :style, expects: :string
18
18
  attribute :target, expects: :string
19
19
  attribute :title, expects: :string
20
20
  attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
21
21
 
22
22
  with_namespace :o do
23
- attribute :allow_in_cell, expects: :explicit_true_false, displays_as: :allowincell
24
- attribute :allow_overlap, expects: :explicit_true_false, displays_as: :allowoverlap
23
+ attribute :allow_in_cell, expects: :boolean, displays_as: :allowincell
24
+ attribute :allow_overlap, expects: :boolean, displays_as: :allowoverlap
25
25
  attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
26
26
  attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
27
27
  attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
28
28
  attribute :border_top_color, expects: :string, displays_as: :bordertopcolor
29
- attribute :bullet, expects: :explicit_true_false
30
- attribute :button, expects: :explicit_true_false
29
+ attribute :bullet, expects: :boolean
30
+ attribute :button, expects: :boolean
31
31
  attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
32
32
  attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
33
33
  attribute :diagram_node_kind, expects: :integer, displays_as: :dgmnodekind
34
- attribute :double_click_notify, expects: :explicit_true_false, displays_as: :doubleclicknotify
35
- attribute :hr, expects: :explicit_true_false
36
- attribute :hr_align, expects: :valid_hr_align, displays_as: :hralign
37
- attribute :hr_no_shade, expects: :explicit_true_false, displays_as: :hrnoshade
34
+ attribute :double_click_notify, expects: :boolean, displays_as: :doubleclicknotify
35
+ attribute :hr, expects: :boolean
36
+ attribute :hr_align, one_of: %i(center left right), displays_as: :hralign
37
+ attribute :hr_no_shade, expects: :boolean, displays_as: :hrnoshade
38
38
  attribute :hr_percent, expects: :integer, displays_as: :hrpct
39
- attribute :hr_standard, expects: :explicit_true_false, displays_as: :hrstd
40
- attribute :inset_mode, expects: :valid_inset_mode, displays_as: :insetmode
41
- attribute :hide_extra_handles, expects: :explicit_true_false, displays_as: :oned
39
+ attribute :hr_standard, expects: :boolean, displays_as: :hrstd
40
+ attribute :inset_mode, one_of: %i(auto custom), displays_as: :insetmode
41
+ attribute :hide_extra_handles, expects: :boolean, displays_as: :oned
42
42
  attribute :regroup_id, expects: :integer, displays_as: :regroupid
43
43
  attribute :optional_string, expects: :string, displays_as: :spid
44
44
  attribute :table_limits, expects: :string, displays_as: :tablelimits
45
45
  attribute :table_properties, expects: :string, displays_as: :tableproperties
46
- attribute :user_drawn, expects: :explicit_true_false, displays_as: :userdrawn
47
- attribute :user_hidden, expects: :explicit_true_false, displays_as: :userhidden
46
+ attribute :user_drawn, expects: :boolean, displays_as: :userdrawn
47
+ attribute :user_hidden, expects: :boolean, displays_as: :userhidden
48
48
  end
49
49
 
50
50
  private
@@ -57,31 +57,11 @@ module OpenXml
57
57
  raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
58
58
  end
59
59
 
60
- def valid_coordinate(value)
61
- raise ArgumentError, "Invalid coordinates." unless value =~ /^[\-0-9]+,\s?[\-0-9]+$/
62
- end
63
-
64
60
  def valid_diagram_layout(value)
65
61
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
66
62
  raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
67
63
  end
68
64
 
69
- def valid_hr_align(value)
70
- ok_values = %i(center left right)
71
- message = "Invalid hr alignment (#{value}). Valid values are: #{ok_values.join(", ")}."
72
- raise ArgumentError, message unless ok_values.include? value
73
- end
74
-
75
- def valid_inset_mode(value)
76
- ok_values = %i(auto custom)
77
- message = "Invalid inset mode (#{value}). Valid modes are: #{ok_values.join(", ")}."
78
- raise ArgumentError, message unless ok_values.include? value
79
- end
80
-
81
- def explicit_true_false(value)
82
- raise ArgumentError unless value.to_s =~ /^(?:[01tf]|true|false)$/
83
- end
84
-
85
65
  end
86
66
  end
87
67
  end
@@ -8,17 +8,17 @@ module OpenXml
8
8
  attribute :alt, expects: :string
9
9
  attribute :chroma_key, expects: :valid_color, displays_as: :chromakey
10
10
  attribute :css_class, expects: :string, displays_as: :class
11
- attribute :coordinate_origin, expects: :valid_coordinate, displays_as: :coordorigin
12
- attribute :coordinate_size, expects: :valid_coordinate, displays_as: :coordsize
11
+ attribute :coordinate_origin, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordorigin
12
+ attribute :coordinate_size, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordsize
13
13
  attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
14
- attribute :filled, expects: :explicit_true_false
14
+ attribute :filled, expects: :boolean
15
15
  attribute :href, expects: :string
16
16
  attribute :id, expects: :string
17
- attribute :inset_pen, expects: :explicit_true_false, displays_as: :insetpen
17
+ attribute :inset_pen, expects: :boolean, displays_as: :insetpen
18
18
  attribute :opacity, expects: :string # Can be a float or 1/65536ths when followed by `f`
19
- attribute :print, expects: :explicit_true_false
19
+ attribute :print, expects: :boolean
20
20
  attribute :stroke_color, expects: :valid_color, displays_as: :strokecolor
21
- attribute :stroked, expects: :explicit_true_false
21
+ attribute :stroked, expects: :boolean
22
22
  attribute :stroke_weight, expects: :string, displays_as: :strokeweight # Expects number with units
23
23
  attribute :style, expects: :string
24
24
  attribute :target, expects: :string
@@ -26,50 +26,44 @@ module OpenXml
26
26
  attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
27
27
 
28
28
  with_namespace :o do
29
- attribute :allow_in_cell, expects: :explicit_true_false, displays_as: :allowincell
30
- attribute :allow_overlap, expects: :explicit_true_false, displays_as: :allowoverlap
29
+ attribute :allow_in_cell, expects: :boolean, displays_as: :allowincell
30
+ attribute :allow_overlap, expects: :boolean, displays_as: :allowoverlap
31
31
  attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
32
32
  attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
33
33
  attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
34
34
  attribute :border_top_color, expects: :string, displays_as: :bordertopcolor
35
- attribute :bullet, expects: :explicit_true_false
36
- attribute :button, expects: :explicit_true_false
37
- attribute :bw_mode, expects: :valid_bw_mode, displays_as: :bwmode
38
- attribute :bw_normal, expects: :valid_bw_mode, displays_as: :bwnormal
39
- attribute :bw_pure, expects: :valid_bw_mode, displays_as: :bwpure
40
- attribute :clip, expects: :explicit_true_false
41
- attribute :clip_to_wrap, expects: :explicit_true_false, displays_as: :cliptowrap
42
- attribute :connector_type, expects: :valid_connector_type, displays_as: :connectortype
35
+ attribute :bullet, expects: :boolean
36
+ attribute :button, expects: :boolean
37
+ attribute :bw_mode, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white), displays_as: :bwmode
38
+ attribute :bw_normal, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white), displays_as: :bwnormal
39
+ attribute :bw_pure, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white), displays_as: :bwpure
40
+ attribute :clip, expects: :boolean
41
+ attribute :clip_to_wrap, expects: :boolean, displays_as: :cliptowrap
42
+ attribute :connector_type, one_of: %i(curved elbow none straight), displays_as: :connectortype
43
43
  attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
44
44
  attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
45
45
  attribute :diagram_node_kind, expects: :integer, displays_as: :dgmnodekind
46
- attribute :double_click_notify, expects: :explicit_true_false, displays_as: :doubleclicknotify
47
- attribute :force_dash, expects: :explicit_true_false, displays_as: :forcedash
48
- attribute :hr, expects: :explicit_true_false
49
- attribute :hr_align, expects: :valid_hr_align, displays_as: :hralign
50
- attribute :hr_no_shade, expects: :explicit_true_false, displays_as: :hrnoshade
46
+ attribute :double_click_notify, expects: :boolean, displays_as: :doubleclicknotify
47
+ attribute :force_dash, expects: :boolean, displays_as: :forcedash
48
+ attribute :hr, expects: :boolean
49
+ attribute :hr_align, one_of: %i(center left right), displays_as: :hralign
50
+ attribute :hr_no_shade, expects: :boolean, displays_as: :hrnoshade
51
51
  attribute :hr_percent, expects: :integer, displays_as: :hrpct
52
- attribute :hr_standard, expects: :explicit_true_false, displays_as: :hrstd
53
- attribute :inset_mode, expects: :valid_inset_mode, displays_as: :insetmode
54
- attribute :ole, expects: :explicit_true_false
55
- attribute :ole_icon, expects: :explicit_true_false, displays_as: :oleicon
56
- attribute :hide_extra_handles, expects: :explicit_true_false, displays_as: :oned
57
- attribute :prefer_relative, expects: :explicit_true_false, displays_as: :preferrelative
52
+ attribute :hr_standard, expects: :boolean, displays_as: :hrstd
53
+ attribute :inset_mode, one_of: %i(auto custom), displays_as: :insetmode
54
+ attribute :ole, expects: :boolean
55
+ attribute :ole_icon, expects: :boolean, displays_as: :oleicon
56
+ attribute :hide_extra_handles, expects: :boolean, displays_as: :oned
57
+ attribute :prefer_relative, expects: :boolean, displays_as: :preferrelative
58
58
  attribute :regroup_id, expects: :integer, displays_as: :regroupid
59
59
  attribute :optional_string, expects: :string, displays_as: :spid
60
60
  attribute :optional_number, expects: :string, displays_as: :spt # Actually expects float
61
- attribute :user_drawn, expects: :explicit_true_false, displays_as: :userdrawn
62
- attribute :user_hidden, expects: :explicit_true_false, displays_as: :userhidden
61
+ attribute :user_drawn, expects: :boolean, displays_as: :userdrawn
62
+ attribute :user_hidden, expects: :boolean, displays_as: :userhidden
63
63
  end
64
64
 
65
65
  private
66
66
 
67
- def valid_bw_mode(value)
68
- ok_values = %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white)
69
- message = "Invalid black and white mode (#{value}). Valid options are: #{ok_values.join(", ")}."
70
- raise ArgumentError, message unless ok_values.include? value
71
- end
72
-
73
67
  def valid_color(value)
74
68
  ok_color_names = %i(black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua)
75
69
  valid_hex = /#[0-9a-f]{6}/i
@@ -78,37 +72,10 @@ module OpenXml
78
72
  raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
79
73
  end
80
74
 
81
- def valid_connector_type(value)
82
- ok_values = %i(curved elbow none straight)
83
- message = "Invalid connector type (#{value}). Valid types are: #{ok_values.join(", ")}."
84
- raise ArgumentError, message unless ok_values.include? value
85
- end
86
-
87
- def valid_coordinate(value)
88
- raise ArgumentError, "Invalid coordinates." unless value =~ /^[\-0-9]+,\s?[\-0-9]+$/
89
- end
90
-
91
75
  def valid_diagram_layout(value)
92
76
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
93
77
  raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
94
78
  end
95
-
96
- def valid_hr_align(value)
97
- ok_values = %i(center left right)
98
- message = "Invalid hr alignment (#{value}). Valid values are: #{ok_values.join(", ")}."
99
- raise ArgumentError, message unless ok_values.include? value
100
- end
101
-
102
- def valid_inset_mode(value)
103
- ok_values = %i(auto custom)
104
- message = "Invalid inset mode (#{value}). Valid modes are: #{ok_values.join(", ")}."
105
- raise ArgumentError, message unless ok_values.include? value
106
- end
107
-
108
- def explicit_true_false(value)
109
- raise ArgumentError unless value.to_s =~ /^(?:[01tf]|true|false)$/
110
- end
111
-
112
79
  end
113
80
  end
114
81
  end
@@ -9,17 +9,17 @@ module OpenXml
9
9
  attribute :arc_size, expects: :valid_arc_size, displays_as: :arcsize
10
10
  attribute :chroma_key, expects: :valid_color, displays_as: :chromakey
11
11
  attribute :css_class, expects: :string, displays_as: :class
12
- attribute :coordinate_origin, expects: :valid_coordinate, displays_as: :coordorigin
13
- attribute :coordinate_size, expects: :valid_coordinate, displays_as: :coordsize
12
+ attribute :coordinate_origin, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordorigin
13
+ attribute :coordinate_size, matches: /^[\-0-9]+,\s?[\-0-9]+$/, displays_as: :coordsize
14
14
  attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
15
- attribute :filled, expects: :explicit_true_false
15
+ attribute :filled, expects: :boolean
16
16
  attribute :href, expects: :string
17
17
  attribute :id, expects: :string
18
- attribute :inset_pen, expects: :explicit_true_false, displays_as: :insetpen
18
+ attribute :inset_pen, expects: :boolean, displays_as: :insetpen
19
19
  attribute :opacity, expects: :string # Can be a float or 1/65536ths when followed by `f`
20
- attribute :print, expects: :explicit_true_false
20
+ attribute :print, expects: :boolean
21
21
  attribute :stroke_color, expects: :valid_color, displays_as: :strokecolor
22
- attribute :stroked, expects: :explicit_true_false
22
+ attribute :stroked, expects: :boolean
23
23
  attribute :stroke_weight, expects: :string, displays_as: :strokeweight # Expects number with units
24
24
  attribute :style, expects: :string
25
25
  attribute :target, expects: :string
@@ -27,40 +27,40 @@ module OpenXml
27
27
  attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
28
28
 
29
29
  with_namespace :o do
30
- attribute :allow_in_cell, expects: :explicit_true_false, displays_as: :allowincell
31
- attribute :allow_overlap, expects: :explicit_true_false, displays_as: :allowoverlap
30
+ attribute :allow_in_cell, expects: :boolean, displays_as: :allowincell
31
+ attribute :allow_overlap, expects: :boolean, displays_as: :allowoverlap
32
32
  attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
33
33
  attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
34
34
  attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
35
35
  attribute :border_top_color, expects: :string, displays_as: :bordertopcolor
36
- attribute :bullet, expects: :explicit_true_false
37
- attribute :button, expects: :explicit_true_false
38
- attribute :bw_mode, expects: :valid_bw_mode, displays_as: :bwmode
39
- attribute :bw_normal, expects: :valid_bw_mode, displays_as: :bwnormal
40
- attribute :bw_pure, expects: :valid_bw_mode, displays_as: :bwpure
41
- attribute :clip, expects: :explicit_true_false
42
- attribute :clip_to_wrap, expects: :explicit_true_false, displays_as: :cliptowrap
43
- attribute :connector_type, expects: :valid_connector_type, displays_as: :connectortype
36
+ attribute :bullet, expects: :boolean
37
+ attribute :button, expects: :boolean
38
+ attribute :bw_mode, displays_as: :bwmode, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white)
39
+ attribute :bw_normal, displays_as: :bwnormal, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white)
40
+ attribute :bw_pure, displays_as: :bwpure, one_of: %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white)
41
+ attribute :clip, expects: :boolean
42
+ attribute :clip_to_wrap, expects: :boolean, displays_as: :cliptowrap
43
+ attribute :connector_type, one_of: %i(curved elbow none straight), displays_as: :connectortype
44
44
  attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
45
45
  attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
46
46
  attribute :diagram_node_kind, expects: :integer, displays_as: :dgmnodekind
47
- attribute :double_click_notify, expects: :explicit_true_false, displays_as: :doubleclicknotify
48
- attribute :force_dash, expects: :explicit_true_false, displays_as: :forcedash
49
- attribute :hr, expects: :explicit_true_false
50
- attribute :hr_align, expects: :valid_hr_align, displays_as: :hralign
51
- attribute :hr_no_shade, expects: :explicit_true_false, displays_as: :hrnoshade
47
+ attribute :double_click_notify, expects: :boolean, displays_as: :doubleclicknotify
48
+ attribute :force_dash, expects: :boolean, displays_as: :forcedash
49
+ attribute :hr, expects: :boolean
50
+ attribute :hr_align, one_of: %i(center left right), displays_as: :hralign
51
+ attribute :hr_no_shade, expects: :boolean, displays_as: :hrnoshade
52
52
  attribute :hr_percent, expects: :integer, displays_as: :hrpct
53
- attribute :hr_standard, expects: :explicit_true_false, displays_as: :hrstd
54
- attribute :inset_mode, expects: :valid_inset_mode, displays_as: :insetmode
55
- attribute :ole, expects: :explicit_true_false
56
- attribute :ole_icon, expects: :explicit_true_false, displays_as: :oleicon
57
- attribute :hide_extra_handles, expects: :explicit_true_false, displays_as: :oned
58
- attribute :prefer_relative, expects: :explicit_true_false, displays_as: :preferrelative
53
+ attribute :hr_standard, expects: :boolean, displays_as: :hrstd
54
+ attribute :inset_mode, one_of: %i(auto custom), displays_as: :insetmode
55
+ attribute :ole, expects: :boolean
56
+ attribute :ole_icon, expects: :boolean, displays_as: :oleicon
57
+ attribute :hide_extra_handles, expects: :boolean, displays_as: :oned
58
+ attribute :prefer_relative, expects: :boolean, displays_as: :preferrelative
59
59
  attribute :regroup_id, expects: :integer, displays_as: :regroupid
60
60
  attribute :optional_string, expects: :string, displays_as: :spid
61
61
  attribute :optional_number, expects: :string, displays_as: :spt # Actually expects float
62
- attribute :user_drawn, expects: :explicit_true_false, displays_as: :userdrawn
63
- attribute :user_hidden, expects: :explicit_true_false, displays_as: :userhidden
62
+ attribute :user_drawn, expects: :boolean, displays_as: :userdrawn
63
+ attribute :user_hidden, expects: :boolean, displays_as: :userhidden
64
64
  end
65
65
 
66
66
  private
@@ -70,12 +70,6 @@ module OpenXml
70
70
  raise ArgumentError, message unless value.is_a?(String) && value =~ /^[0-9]+[%f]$/
71
71
  end
72
72
 
73
- def valid_bw_mode(value)
74
- ok_values = %i(auto black blackTextAndLines color grayOutline grayScale hide highContrast inverseGray lightGrayscale undrawn white)
75
- message = "Invalid black and white mode (#{value}). Valid options are: #{ok_values.join(", ")}."
76
- raise ArgumentError, message unless ok_values.include? value
77
- end
78
-
79
73
  def valid_color(value)
80
74
  ok_color_names = %i(black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua)
81
75
  valid_hex = /#[0-9a-f]{6}/i
@@ -84,37 +78,11 @@ module OpenXml
84
78
  raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
85
79
  end
86
80
 
87
- def valid_connector_type(value)
88
- ok_values = %i(curved elbow none straight)
89
- message = "Invalid connector type (#{value}). Valid types are: #{ok_values.join(", ")}."
90
- raise ArgumentError, message unless ok_values.include? value
91
- end
92
-
93
- def valid_coordinate(value)
94
- raise ArgumentError, "Invalid coordinates." unless value =~ /^[\-0-9]+,\s?[\-0-9]+$/
95
- end
96
-
97
81
  def valid_diagram_layout(value)
98
82
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
99
83
  raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
100
84
  end
101
85
 
102
- def valid_hr_align(value)
103
- ok_values = %i(center left right)
104
- message = "Invalid hr alignment (#{value}). Valid values are: #{ok_values.join(", ")}."
105
- raise ArgumentError, message unless ok_values.include? value
106
- end
107
-
108
- def valid_inset_mode(value)
109
- ok_values = %i(auto custom)
110
- message = "Invalid inset mode (#{value}). Valid modes are: #{ok_values.join(", ")}."
111
- raise ArgumentError, message unless ok_values.include? value
112
- end
113
-
114
- def explicit_true_false(value)
115
- raise ArgumentError unless value.to_s =~ /^(?:[01tf]|true|false)$/
116
- end
117
-
118
86
  end
119
87
  end
120
88
  end