openxml-docx 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -2,17 +2,19 @@ module OpenXml
|
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
4
|
class TableBorder < ComplexProperty
|
|
5
|
-
tag_is_one_of %i(top start bottom end insideH insideV)
|
|
5
|
+
tag_is_one_of %i(top start bottom end insideH insideV left right)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :color, expects: :hex_color
|
|
9
|
+
attribute :frame, expects: :true_or_false
|
|
10
|
+
attribute :shadow, expects: :true_or_false
|
|
11
|
+
attribute :space, expects: :positive_integer
|
|
12
|
+
attribute :theme_color, expects: :valid_theme_color
|
|
13
|
+
attribute :theme_shade, expects: :hex_digit
|
|
14
|
+
attribute :theme_tint, expects: :hex_digit
|
|
15
|
+
attribute :value, expects: :valid_type, displays_as: :val
|
|
16
|
+
attribute :width, expects: :positive_integer, displays_as: :sz
|
|
17
|
+
end
|
|
16
18
|
|
|
17
19
|
def initialize(tag, value)
|
|
18
20
|
super tag
|
|
@@ -2,17 +2,19 @@ module OpenXml
|
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
4
|
class TableCellBorder < ComplexProperty
|
|
5
|
-
tag_is_one_of %i(top start bottom end insideH insideV tl2br tr2bl)
|
|
5
|
+
tag_is_one_of %i(top start bottom end insideH insideV tl2br tr2bl left right)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :color, expects: :hex_color
|
|
9
|
+
attribute :frame, expects: :true_or_false
|
|
10
|
+
attribute :shadow, expects: :true_or_false
|
|
11
|
+
attribute :space, expects: :positive_integer
|
|
12
|
+
attribute :theme_color, expects: :valid_theme_color
|
|
13
|
+
attribute :theme_shade, expects: :hex_digit
|
|
14
|
+
attribute :theme_tint, expects: :hex_digit
|
|
15
|
+
attribute :value, expects: :valid_type, displays_as: :val
|
|
16
|
+
attribute :width, expects: :positive_integer, displays_as: :sz
|
|
17
|
+
end
|
|
16
18
|
|
|
17
19
|
def initialize(tag, value)
|
|
18
20
|
super tag
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableCellMargin <
|
|
5
|
-
tag_is_one_of %i(top start bottom end)
|
|
4
|
+
class TableCellMargin < ComplexProperty
|
|
5
|
+
tag_is_one_of %i(top start bottom end left right)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
9
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
10
|
+
end
|
|
9
11
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableCellSpacing <
|
|
4
|
+
class TableCellSpacing < ComplexProperty
|
|
5
5
|
tag :tblCellSpacing
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
9
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
10
|
+
end
|
|
9
11
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableCellWidth <
|
|
4
|
+
class TableCellWidth < ComplexProperty
|
|
5
5
|
tag :tcW
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
9
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
10
|
+
end
|
|
9
11
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableIndent <
|
|
4
|
+
class TableIndent < ComplexProperty
|
|
5
5
|
tag :tblInd
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
9
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
10
|
+
end
|
|
9
11
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableLayout <
|
|
4
|
+
class TableLayout < ComplexProperty
|
|
5
5
|
tag :tblLayout
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
%i(autofit fixed)
|
|
9
|
-
end
|
|
7
|
+
attribute :type, one_of: %i(autofit fixed), namespace: :w
|
|
10
8
|
|
|
11
9
|
end
|
|
12
10
|
end
|
|
@@ -4,12 +4,14 @@ module OpenXml
|
|
|
4
4
|
class TableLook < ComplexProperty
|
|
5
5
|
tag :tblLook
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :firstColumn, expects: :true_or_false
|
|
9
|
+
attribute :firstRow, expects: :true_or_false
|
|
10
|
+
attribute :lastColumn, expects: :true_or_false
|
|
11
|
+
attribute :lastRow, expects: :true_or_false
|
|
12
|
+
attribute :noHBand, expects: :true_or_false
|
|
13
|
+
attribute :noVBand, expects: :true_or_false
|
|
14
|
+
end
|
|
13
15
|
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -4,37 +4,18 @@ module OpenXml
|
|
|
4
4
|
class TablePPr < ComplexProperty
|
|
5
5
|
tag :tblpPr
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def valid_anchor(value)
|
|
21
|
-
list = %i(margin page text)
|
|
22
|
-
message = "Invalid #{name}: must be one of #{list.join(", ")} (was #{value.inspect})"
|
|
23
|
-
raise ArgumentError, message unless list.include? value
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def valid_x_spec(value)
|
|
27
|
-
list = %i(center inside left outside right)
|
|
28
|
-
message = "Invalid #{name}: must be one of #{list.join(", ")} (was #{value.inspect})"
|
|
29
|
-
raise ArgumentError, message unless list.include? value
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :bottomFromText, expects: :positive_integer
|
|
9
|
+
attribute :horizAnchor, one_of: %i(margin page text)
|
|
10
|
+
attribute :leftFromText, expects: :positive_integer
|
|
11
|
+
attribute :rightFromText, expects: :positive_integer
|
|
12
|
+
attribute :tblpX, expects: :integer
|
|
13
|
+
attribute :tblpXSpec, one_of: %i(center inside left outside right)
|
|
14
|
+
attribute :tblpY, expects: :integer
|
|
15
|
+
attribute :tblpYSpec, one_of: %i(bottom center inline inside outside top)
|
|
16
|
+
attribute :topFromText, expects: :positive_integer
|
|
17
|
+
attribute :vertAnchor, one_of: %i(margin page text)
|
|
30
18
|
end
|
|
31
|
-
|
|
32
|
-
def valid_y_spec(value)
|
|
33
|
-
list = %i(bottom center inline inside outside top)
|
|
34
|
-
message = "Invalid #{name}: must be one of #{list.join(", ")} (was #{value.inspect})"
|
|
35
|
-
raise ArgumentError, message unless list.include? value
|
|
36
|
-
end
|
|
37
|
-
|
|
38
19
|
end
|
|
39
20
|
end
|
|
40
21
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module OpenXml
|
|
2
|
+
module Docx
|
|
3
|
+
module Properties
|
|
4
|
+
class TableRowHeight < ComplexProperty
|
|
5
|
+
tag :trHeight
|
|
6
|
+
|
|
7
|
+
attribute :hRule, one_of: %i(auto atLeast exact), namespace: :w
|
|
8
|
+
attribute :val, expects: :positive_integer, namespace: :w
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class TableWidth <
|
|
4
|
+
class TableWidth < ComplexProperty
|
|
5
5
|
tag :tblW
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
with_namespace :w do
|
|
8
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
9
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
10
|
+
end
|
|
9
11
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -4,20 +4,21 @@ module OpenXml
|
|
|
4
4
|
class Underline < ComplexProperty
|
|
5
5
|
tag :u
|
|
6
6
|
|
|
7
|
-
VALID_UNDERLINE_TYPES =
|
|
7
|
+
VALID_UNDERLINE_TYPES =
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
with_namespace :w do
|
|
10
|
+
attribute :color, expects: :hex_color
|
|
11
|
+
attribute :theme_color, expects: :valid_theme_color
|
|
12
|
+
attribute :theme_shade, expects: :hex_digit
|
|
13
|
+
attribute :theme_tint, expects: :hex_digit
|
|
14
|
+
attribute :type, displays_as: :val, one_of: %i(dash dashDotDotHeavy
|
|
15
|
+
dashDotHeavy dashedHeavy
|
|
16
|
+
dashLong dashLongHeavy
|
|
17
|
+
dotDash dotDotDash
|
|
18
|
+
dotted dottedHeavy double
|
|
19
|
+
none single thick wave
|
|
20
|
+
wavyDouble wavyHeavy words)
|
|
19
21
|
end
|
|
20
|
-
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class WAfter <
|
|
4
|
+
class WAfter < ComplexProperty
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
with_namespace :w do
|
|
7
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
8
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
9
|
+
end
|
|
8
10
|
|
|
9
11
|
end
|
|
10
12
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
module OpenXml
|
|
2
2
|
module Docx
|
|
3
3
|
module Properties
|
|
4
|
-
class WBefore <
|
|
4
|
+
class WBefore < ComplexProperty
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
with_namespace :w do
|
|
7
|
+
attribute :type, one_of: %i(auto dxa nil pct)
|
|
8
|
+
attribute :width, expects: :positive_integer, displays_as: :w
|
|
9
|
+
end
|
|
8
10
|
|
|
9
11
|
end
|
|
10
12
|
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module OpenXml
|
|
2
|
+
module Docx
|
|
3
|
+
module RootNamespaces
|
|
4
|
+
|
|
5
|
+
POSSIBLE_NAMESPACES = {
|
|
6
|
+
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas".freeze,
|
|
7
|
+
mo: "http://schemas.microsoft.com/office/mac/office/2008/main".freeze,
|
|
8
|
+
mv: "urn:schemas-microsoft-com:mac:vml".freeze,
|
|
9
|
+
o: "urn:schemas-microsoft-com:office:office".freeze,
|
|
10
|
+
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships".freeze,
|
|
11
|
+
m: "http://schemas.openxmlformats.org/officeDocument/2006/math".freeze,
|
|
12
|
+
v: "urn:schemas-microsoft-com:vml".freeze,
|
|
13
|
+
wp14: "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing".freeze,
|
|
14
|
+
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing".freeze,
|
|
15
|
+
w10: "urn:schemas-microsoft-com:office:word".freeze,
|
|
16
|
+
w14: "http://schemas.microsoft.com/office/word/2010/wordml".freeze,
|
|
17
|
+
w15: "http://schemas.microsoft.com/office/word/2012/wordml".freeze,
|
|
18
|
+
wpg: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup".freeze,
|
|
19
|
+
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk".freeze,
|
|
20
|
+
wne: "http://schemas.microsoft.com/office/word/2006/wordml".freeze,
|
|
21
|
+
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape".freeze,
|
|
22
|
+
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main".freeze,
|
|
23
|
+
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006".freeze,
|
|
24
|
+
a: "http://schemas.openxmlformats.org/drawingml/2006/main".freeze,
|
|
25
|
+
a14: "http://schemas.microsoft.com/office/drawing/2010/main".freeze,
|
|
26
|
+
pic: "http://purl.oclc.org/ooxml/drawingml/main".freeze
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def self.included(base)
|
|
30
|
+
base.extend ClassMethods
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module ClassMethods
|
|
34
|
+
|
|
35
|
+
def use_namespaces(*args)
|
|
36
|
+
args.each do |arg|
|
|
37
|
+
prefix = arg.to_sym
|
|
38
|
+
raise ArgumentError, "Reference to undefined namespace prefix: #{prefix}" if POSSIBLE_NAMESPACES[prefix].nil?
|
|
39
|
+
active_namespaces << prefix unless active_namespaces.include?(prefix)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
alias :use_namespace :use_namespaces
|
|
43
|
+
|
|
44
|
+
def can_ignore(*args)
|
|
45
|
+
args.each { |arg| ignorable_namespaces[arg.to_sym] = true }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def ignorable_namespaces
|
|
49
|
+
@ignorable_namespaces ||= {}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def active_namespaces
|
|
53
|
+
@active_namespaces ||= []
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def root_namespaces
|
|
61
|
+
namespace_defs = {}
|
|
62
|
+
unless self.class.ignorable_namespaces.empty?
|
|
63
|
+
namespace_defs["mc:Ignorable"] = self.class.ignorable_namespaces.keys.join(" ")
|
|
64
|
+
self.class.use_namespace :mc
|
|
65
|
+
end
|
|
66
|
+
self.class.active_namespaces.map do |prefix|
|
|
67
|
+
namespace_defs["xmlns:#{prefix}"] = POSSIBLE_NAMESPACES[prefix]
|
|
68
|
+
end
|
|
69
|
+
namespace_defs
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/openxml/docx/section.rb
CHANGED
data/lib/openxml/docx/style.rb
CHANGED
|
@@ -6,10 +6,10 @@ module OpenXml
|
|
|
6
6
|
|
|
7
7
|
attr_reader :paragraph, :character, :table, :type
|
|
8
8
|
|
|
9
|
-
attribute :custom, expects: :true_or_false, displays_as: :customStyle
|
|
10
|
-
attribute :default, expects: :true_or_false
|
|
11
|
-
attribute :id, expects: :string, displays_as: :styleId
|
|
12
|
-
attribute :type, expects: :valid_style_type
|
|
9
|
+
attribute :custom, expects: :true_or_false, displays_as: :customStyle, namespace: :w
|
|
10
|
+
attribute :default, expects: :true_or_false, namespace: :w
|
|
11
|
+
attribute :id, expects: :string, displays_as: :styleId, namespace: :w
|
|
12
|
+
attribute :type, expects: :valid_style_type, namespace: :w
|
|
13
13
|
|
|
14
14
|
value_property :auto_redefine, as: :style_auto_redefinition
|
|
15
15
|
value_property :hidden_style
|
data/lib/openxml/docx/version.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module OpenXml
|
|
2
|
+
module DrawingML
|
|
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/drawingml/elements"
|