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,40 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module DrawingML
|
3
|
+
module Elements
|
4
|
+
class ShapeGuide < OpenXml::Docx::Elements::Element
|
5
|
+
namespace :a
|
6
|
+
tag :gd
|
7
|
+
|
8
|
+
attribute :formula, expects: :valid_formula, displays_as: :fmla
|
9
|
+
attribute :guide_name, expects: :string, displays_as: :name
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def valid_formula(value)
|
14
|
+
raise ArgumentError unless ok_formulae.any? { |f| value =~ f }
|
15
|
+
end
|
16
|
+
|
17
|
+
def ok_formulae # Office Open XML spec section 20.1.9.11
|
18
|
+
[ /^\*\/\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Multiply Divide formula "*/ x y z" = ((x * y) / z)
|
19
|
+
/^\+\-\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Add Subtract formula "+- x y z" = ((x + y) - z)
|
20
|
+
/^\+\/\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Add Divide formula "+/ x y z" = ((x + y) / z)
|
21
|
+
/^\?\:\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # If Else formula "?: x y z" = (x > 0) ? y : z
|
22
|
+
/^abs\s[0-9a-z\-]+$/i, # Absolute Value formula "abs x" = (x < 0) -1 * x : x
|
23
|
+
/^at2\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # ArcTan formula "at2 x y" = arctan(y / x)
|
24
|
+
/^cat2\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Cosine ArcTan formula "cat2 x y z" = (x * cos(arctan(z / y)))
|
25
|
+
/^cos\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Cosine formula "cos x y" = x * cos(y)
|
26
|
+
/^max\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Maximum Value formula "max x y" = (x > y) ? x : y
|
27
|
+
/^min\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Minimum Value formula "min x y" = (x < y) ? x : y
|
28
|
+
/^mod\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Modulo formula "mod x y z" = sqrt(x^2 + y^2 + z^2)
|
29
|
+
/^pin\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Pin To formula "pin x y z" = if(y < x) x elsif(y > z) z else y
|
30
|
+
/^sat2\s[0-9a-z\-]+\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Sine ArcTan formula "sat2 x y z" = (x * sin(arctan(z / y)))
|
31
|
+
/^sin\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Sine formula "sin x y" = x * sin(y)
|
32
|
+
/^sqrt\s[0-9a-z\-]+$/i, # Square Root formula "sqrt x" = sqrt(x)
|
33
|
+
/^tan\s[0-9a-z\-]+\s[0-9a-z\-]+$/i, # Tangent formula "tan x y" = x * tan(y)
|
34
|
+
/^val\s[0-9a-z\-]+$/i ] # Literal Value formula "val x" = x
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module DrawingML
|
3
|
+
module Elements
|
4
|
+
class TailEnd < OpenXml::Docx::Elements::Element
|
5
|
+
namespace :a
|
6
|
+
|
7
|
+
attribute :length, expects: :valid_end_size, displays_as: :len
|
8
|
+
attribute :type, expects: :valid_end_type
|
9
|
+
attribute :width, expects: :valid_end_size, displays_as: :w
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def valid_end_size(value)
|
14
|
+
ok_values = %i(lg med sm)
|
15
|
+
message = "Invalid #{name} (#{value}). Valid values are: #{ok_values.join(", ")}."
|
16
|
+
raise ArgumentError, message unless ok_values.include? value
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid_end_type(value)
|
20
|
+
ok_values = %i(arrow diamond none oval stealth triangle)
|
21
|
+
message = "Invalid end type (#{value}). Valid values are: #{ok_values.join(", ")}."
|
22
|
+
raise ArgumentError, message unless ok_values.include? value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module DrawingML
|
3
|
+
module Elements
|
4
|
+
class TransformEffect < OpenXml::Docx::Elements::Container
|
5
|
+
namespace :a
|
6
|
+
tag :xfrm
|
7
|
+
|
8
|
+
attribute :horizontal_skew, expects: :integer, displays_as: :kx
|
9
|
+
attribute :vertical_skew, expects: :integer, displays_as: :ky
|
10
|
+
attribute :horizontal_ratio, expects: :percentage, displays_as: :sx
|
11
|
+
attribute :vertical_ratio, expects: :percentage, displays_as: :sy
|
12
|
+
attribute :horizontal_shift, expects: :integer, displays_as: :tx
|
13
|
+
attribute :vertical_shift, expects: :integer, displays_as: :ty
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/openxml/vml.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Vml
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
# For now, we'll rely on Docx's basic implementations
|
7
|
+
require "openxml/docx/attribute_builder"
|
8
|
+
require "openxml/docx/property_builder"
|
9
|
+
require "openxml/docx/properties"
|
10
|
+
require "openxml/docx/elements"
|
11
|
+
require "openxml/docx/package"
|
12
|
+
require "openxml/docx/parts"
|
13
|
+
require "openxml/docx/section"
|
14
|
+
require "openxml/docx/style"
|
15
|
+
|
16
|
+
# And then add our own stuff
|
17
|
+
require "openxml/vml/elements"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Vml
|
3
|
+
module Elements
|
4
|
+
end
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "openxml/docx/elements/element"
|
9
|
+
require "openxml/docx/elements/container"
|
10
|
+
require "openxml/docx/elements/text"
|
11
|
+
Dir.glob("#{File.join(File.dirname(__FILE__), "elements", "*.rb")}").each do |file|
|
12
|
+
require file
|
13
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Vml
|
3
|
+
module Elements
|
4
|
+
class Group < OpenXml::Docx::Elements::Container
|
5
|
+
namespace :v
|
6
|
+
|
7
|
+
attribute :alt, expects: :string
|
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
|
11
|
+
attribute :edit_as, one_of: %i(bullseye canvas cycle orgchart radial stacked venn), displays_as: :editas
|
12
|
+
attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
|
13
|
+
attribute :filled, expects: :explicit_true_false
|
14
|
+
attribute :href, expects: :string
|
15
|
+
attribute :id, expects: :string
|
16
|
+
attribute :print, expects: :explicit_true_false
|
17
|
+
attribute :style, expects: :string
|
18
|
+
attribute :target, expects: :string
|
19
|
+
attribute :title, expects: :string
|
20
|
+
attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
|
21
|
+
|
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
|
25
|
+
attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
|
26
|
+
attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
|
27
|
+
attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
|
28
|
+
attribute :border_top_color, expects: :string, displays_as: :bordertopcolor
|
29
|
+
attribute :bullet, expects: :explicit_true_false
|
30
|
+
attribute :button, expects: :explicit_true_false
|
31
|
+
attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
|
32
|
+
attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
|
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
|
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
|
42
|
+
attribute :regroup_id, expects: :integer, displays_as: :regroupid
|
43
|
+
attribute :optional_string, expects: :string, displays_as: :spid
|
44
|
+
attribute :table_limits, expects: :string, displays_as: :tablelimits
|
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
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def valid_color(value)
|
53
|
+
ok_color_names = %i(black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua)
|
54
|
+
valid_hex = /#[0-9a-f]{6}/i
|
55
|
+
valid_palette_entry = /^\w+(?:\s\[[0-9]+\])?$/
|
56
|
+
message = "Invalid color. Please specify a color name, a hex value (with #), or a palette entry."
|
57
|
+
raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
|
58
|
+
end
|
59
|
+
|
60
|
+
def valid_coordinate(value)
|
61
|
+
raise ArgumentError, "Invalid coordinates." unless value =~ /^[\-0-9]+,\s?[\-0-9]+$/
|
62
|
+
end
|
63
|
+
|
64
|
+
def valid_diagram_layout(value)
|
65
|
+
message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
|
66
|
+
raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
|
67
|
+
end
|
68
|
+
|
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
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Vml
|
3
|
+
module Elements
|
4
|
+
class Rectangle < OpenXml::Docx::Elements::Container
|
5
|
+
namespace :v
|
6
|
+
tag :rect
|
7
|
+
|
8
|
+
attribute :alt, expects: :string
|
9
|
+
attribute :chroma_key, expects: :valid_color, displays_as: :chromakey
|
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
|
13
|
+
attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
|
14
|
+
attribute :filled, expects: :explicit_true_false
|
15
|
+
attribute :href, expects: :string
|
16
|
+
attribute :id, expects: :string
|
17
|
+
attribute :inset_pen, expects: :explicit_true_false, displays_as: :insetpen
|
18
|
+
attribute :opacity, expects: :string # Can be a float or 1/65536ths when followed by `f`
|
19
|
+
attribute :print, expects: :explicit_true_false
|
20
|
+
attribute :stroke_color, expects: :valid_color, displays_as: :strokecolor
|
21
|
+
attribute :stroked, expects: :explicit_true_false
|
22
|
+
attribute :stroke_weight, expects: :string, displays_as: :strokeweight # Expects number with units
|
23
|
+
attribute :style, expects: :string
|
24
|
+
attribute :target, expects: :string
|
25
|
+
attribute :title, expects: :string
|
26
|
+
attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
|
27
|
+
|
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
|
31
|
+
attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
|
32
|
+
attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
|
33
|
+
attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
|
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
|
43
|
+
attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
|
44
|
+
attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
|
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
|
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
|
58
|
+
attribute :regroup_id, expects: :integer, displays_as: :regroupid
|
59
|
+
attribute :optional_string, expects: :string, displays_as: :spid
|
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
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
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
|
+
def valid_color(value)
|
74
|
+
ok_color_names = %i(black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua)
|
75
|
+
valid_hex = /#[0-9a-f]{6}/i
|
76
|
+
valid_palette_entry = /^\w+(?:\s\[[0-9]+\])?$/
|
77
|
+
message = "Invalid color. Please specify a color name, a hex value (with #), or a palette entry."
|
78
|
+
raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
|
79
|
+
end
|
80
|
+
|
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
|
+
def valid_diagram_layout(value)
|
92
|
+
message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
|
93
|
+
raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
|
94
|
+
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
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Vml
|
3
|
+
module Elements
|
4
|
+
class RoundedRectangle < OpenXml::Docx::Elements::Container
|
5
|
+
namespace :v
|
6
|
+
tag :roundrect
|
7
|
+
|
8
|
+
attribute :alt, expects: :string
|
9
|
+
attribute :arc_size, expects: :valid_arc_size, displays_as: :arcsize
|
10
|
+
attribute :chroma_key, expects: :valid_color, displays_as: :chromakey
|
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
|
14
|
+
attribute :fill_color, expects: :valid_color, displays_as: :fillcolor
|
15
|
+
attribute :filled, expects: :explicit_true_false
|
16
|
+
attribute :href, expects: :string
|
17
|
+
attribute :id, expects: :string
|
18
|
+
attribute :inset_pen, expects: :explicit_true_false, displays_as: :insetpen
|
19
|
+
attribute :opacity, expects: :string # Can be a float or 1/65536ths when followed by `f`
|
20
|
+
attribute :print, expects: :explicit_true_false
|
21
|
+
attribute :stroke_color, expects: :valid_color, displays_as: :strokecolor
|
22
|
+
attribute :stroked, expects: :explicit_true_false
|
23
|
+
attribute :stroke_weight, expects: :string, displays_as: :strokeweight # Expects number with units
|
24
|
+
attribute :style, expects: :string
|
25
|
+
attribute :target, expects: :string
|
26
|
+
attribute :title, expects: :string
|
27
|
+
attribute :wrap_coordinates, expects: :string, displays_as: :wrapcoords
|
28
|
+
|
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
|
32
|
+
attribute :border_bottom_color, expects: :string, displays_as: :borderbottomcolor
|
33
|
+
attribute :border_left_color, expects: :string, displays_as: :borderleftcolor
|
34
|
+
attribute :border_right_color, expects: :string, displays_as: :borderrightcolor
|
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
|
44
|
+
attribute :diagram_node_layout, expects: :valid_diagram_layout, displays_as: :dgmlayout
|
45
|
+
attribute :diagram_node_recent_layout, expects: :valid_diagram_layout, displays_as: :dgmlayoutmru
|
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
|
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
|
59
|
+
attribute :regroup_id, expects: :integer, displays_as: :regroupid
|
60
|
+
attribute :optional_string, expects: :string, displays_as: :spid
|
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
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def valid_arc_size(value)
|
69
|
+
message = "Invalid arc size. Requires a percent or value in terms of f."
|
70
|
+
raise ArgumentError, message unless value.is_a?(String) && value =~ /^[0-9]+[%f]$/
|
71
|
+
end
|
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
|
+
def valid_color(value)
|
80
|
+
ok_color_names = %i(black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua)
|
81
|
+
valid_hex = /#[0-9a-f]{6}/i
|
82
|
+
valid_palette_entry = /^\w+(?:\s\[[0-9]+\])?$/
|
83
|
+
message = "Invalid color. Please specify a color name, a hex value (with #), or a palette entry."
|
84
|
+
raise ArgumentError, message unless ok_color_names.include?(value) || value =~ valid_hex || value =~ valid_palette_entry
|
85
|
+
end
|
86
|
+
|
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
|
+
def valid_diagram_layout(value)
|
98
|
+
message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
|
99
|
+
raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
|
100
|
+
end
|
101
|
+
|
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
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|