├── lib
├── openxml-docx.rb
└── openxml
│ ├── docx
│ ├── version.rb
│ ├── elements
│ │ ├── tab.rb
│ │ ├── dirty.rb
│ │ ├── last_rendered_page_break.rb
│ │ ├── long_day.rb
│ │ ├── page_number.rb
│ │ ├── long_month.rb
│ │ ├── long_year.rb
│ │ ├── short_day.rb
│ │ ├── short_year.rb
│ │ ├── carriage_return.rb
│ │ ├── short_month.rb
│ │ ├── hyperlink.rb
│ │ ├── nonbreaking_hyphen.rb
│ │ ├── optional_hyphen.rb
│ │ ├── content_part.rb
│ │ ├── deleted_text.rb
│ │ ├── drawing.rb
│ │ ├── group_shape.rb
│ │ ├── table_grid.rb
│ │ ├── vml_container.rb
│ │ ├── word_processing_drawing_wrap_none.rb
│ │ ├── grid_column.rb
│ │ ├── section_properties.rb
│ │ ├── textbox_content.rb
│ │ ├── compatibility_setting.rb
│ │ ├── even_and_odd_headers.rb
│ │ ├── title_page.rb
│ │ ├── wordprocessing_shape_group.rb
│ │ ├── book_fold_printing.rb
│ │ ├── markup_compatibility_fallback.rb
│ │ ├── book_fold_reverse_printing.rb
│ │ ├── bidi_embed.rb
│ │ ├── book_fold_printing_sheets.rb
│ │ ├── embed_system_fonts.rb
│ │ ├── save_subset_fonts.rb
│ │ ├── bidi_override.rb
│ │ ├── embed_true_type_fonts.rb
│ │ ├── markup_compatibility_alternate_content.rb
│ │ ├── paper_source.rb
│ │ ├── word_processing_groups_nv_shape_drawing_properties.rb
│ │ ├── font_panose_one.rb
│ │ ├── font_alternate_name.rb
│ │ ├── font_pitch.rb
│ │ ├── word_processing_drawing_nv_graphic_frame_properties.rb
│ │ ├── break.rb
│ │ ├── font.rb
│ │ ├── symbol.rb
│ │ ├── word_processing_drawing_simple_position.rb
│ │ ├── font_character_set.rb
│ │ ├── word_processing_drawing_wrap_polygon.rb
│ │ ├── markup_compatibility_choice.rb
│ │ ├── word_processing_shapes_textual_contents.rb
│ │ ├── word_processing_shapes_shape.rb
│ │ ├── word_processing_drawing_extent.rb
│ │ ├── control.rb
│ │ ├── word_processing_shapes_shape_properties.rb
│ │ ├── word_processing_drawing_position_h.rb
│ │ ├── word_processing_drawing_position_v.rb
│ │ ├── word_processing_drawing_wrap_top_and_bottom.rb
│ │ ├── text.rb
│ │ ├── word_processing_groups_group_shape_properties.rb
│ │ ├── absolute_position_tab.rb
│ │ ├── compatibility_settings.rb
│ │ ├── word_processing_drawing_effect_extent.rb
│ │ ├── embed_bold.rb
│ │ ├── embed_italic.rb
│ │ ├── word_processing_drawing_object_nv_properties.rb
│ │ ├── background.rb
│ │ ├── embed_bold_italic.rb
│ │ ├── word_processing_drawing_wrap_tight.rb
│ │ ├── font_sig.rb
│ │ ├── word_processing_drawing_wrap_through.rb
│ │ ├── word_processing_shapes_nv_drawing_properties.rb
│ │ ├── word_processing_drawing_wrap_coordinate.rb
│ │ ├── word_processing_drawing_inline.rb
│ │ ├── word_processing_drawing_position_offset.rb
│ │ ├── family.rb
│ │ ├── word_processing_drawing_wrap_square.rb
│ │ └── level_override.rb
│ ├── properties
│ │ ├── bidi.rb
│ │ ├── caps.rb
│ │ ├── div_id.rb
│ │ ├── emboss.rb
│ │ ├── header.rb
│ │ ├── hidden.rb
│ │ ├── imprint.rb
│ │ ├── kinsoku.rb
│ │ ├── no_proof.rb
│ │ ├── no_wrap.rb
│ │ ├── outline.rb
│ │ ├── shadow.rb
│ │ ├── word_wrap.rb
│ │ ├── cant_split.rb
│ │ ├── grid_after.rb
│ │ ├── hide_mark.rb
│ │ ├── keep_lines.rb
│ │ ├── keep_next.rb
│ │ ├── personal.rb
│ │ ├── position.rb
│ │ ├── rtl_gutter.rb
│ │ ├── semi_hidden.rb
│ │ ├── small_caps.rb
│ │ ├── snap_to_grid.rb
│ │ ├── spec_vanish.rb
│ │ ├── web_hidden.rb
│ │ ├── grid_before.rb
│ │ ├── grid_span.rb
│ │ ├── mirror_indent.rb
│ │ ├── ui_priority.rb
│ │ ├── widow_control.rb
│ │ ├── personal_reply.rb
│ │ ├── supress_overlap.rb
│ │ ├── unhide_when_used.rb
│ │ ├── contextual_spacing.rb
│ │ ├── page_break_before.rb
│ │ ├── personal_compose.rb
│ │ ├── even_and_odd_headers.rb
│ │ ├── supress_auto_hyphens.rb
│ │ ├── supress_line_numbers.rb
│ │ ├── bold.rb
│ │ ├── italics.rb
│ │ ├── math.rb
│ │ ├── run_style.rb
│ │ ├── start.rb
│ │ ├── style_lock.rb
│ │ ├── title_page.rb
│ │ ├── complex_bold.rb
│ │ ├── hidden_style.rb
│ │ ├── hidden_text.rb
│ │ ├── kerning.rb
│ │ ├── paragraph_style.rb
│ │ ├── primary_style.rb
│ │ ├── right_to_left.rb
│ │ ├── style_aliases.rb
│ │ ├── style_name.rb
│ │ ├── complex_italics.rb
│ │ ├── font_size.rb
│ │ ├── form_protection.rb
│ │ ├── table_header.rb
│ │ ├── table_style.rb
│ │ ├── auto_space_de.rb
│ │ ├── auto_space_dn.rb
│ │ ├── legal_numbering.rb
│ │ ├── level_restart.rb
│ │ ├── strikethrough.rb
│ │ ├── table_caption.rb
│ │ ├── character_spacing.rb
│ │ ├── start_override.rb
│ │ ├── table_cell_fit_text.rb
│ │ ├── complex_font_size.rb
│ │ ├── double_strikethrough.rb
│ │ ├── outline_level.rb
│ │ ├── table_description.rb
│ │ ├── abstract_number_id.rb
│ │ ├── complex_script_formatting.rb
│ │ ├── compress_punctuation.rb
│ │ ├── style_auto_redefinition.rb
│ │ ├── overflow_punctuation.rb
│ │ ├── tabs.rb
│ │ ├── phonetic_guide_font_size.rb
│ │ ├── headers.rb
│ │ ├── valign.rb
│ │ ├── suffix.rb
│ │ ├── auto_adjust_right_indent.rb
│ │ ├── text_direction.rb
│ │ ├── phonetic_guide_base_font_size.rb
│ │ ├── phonetic_guide_font_size_raise.rb
│ │ ├── table_layout.rb
│ │ ├── text_alignment.rb
│ │ ├── emphasis.rb
│ │ ├── table_overlap.rb
│ │ ├── vertical_merge.rb
│ │ ├── effect.rb
│ │ ├── footer_references.rb
│ │ ├── header_references.rb
│ │ ├── table_borders.rb
│ │ ├── textbox_tight_wrap.rb
│ │ ├── vertical_text_alignment.rb
│ │ ├── vertical_alignment.rb
│ │ ├── multi_level_type.rb
│ │ ├── table_cell_borders.rb
│ │ ├── table_cell_cell_margin.rb
│ │ ├── table_cell_margins.rb
│ │ ├── level_text.rb
│ │ ├── section_type.rb
│ │ ├── style.rb
│ │ ├── transparent_container_property.rb
│ │ ├── alignment.rb
│ │ ├── wafter.rb
│ │ ├── wbefore.rb
│ │ ├── highlight.rb
│ │ ├── table_row_height.rb
│ │ ├── integer_property.rb
│ │ ├── level_alignment.rb
│ │ ├── boolean_property.rb
│ │ ├── manual_width.rb
│ │ ├── phonetic_guide_alignment.rb
│ │ ├── table_width.rb
│ │ ├── table_indent.rb
│ │ ├── positive_integer_property.rb
│ │ ├── table_cell_width.rb
│ │ ├── next_style.rb
│ │ ├── parent_style.rb
│ │ ├── linked_style.rb
│ │ ├── table_cell_spacing.rb
│ │ ├── string_property.rb
│ │ ├── table_cell_margin.rb
│ │ ├── document_grid.rb
│ │ ├── phonetic_guide_language.rb
│ │ ├── color.rb
│ │ ├── on_off_property.rb
│ │ ├── complex_property.rb
│ │ ├── line_numbering.rb
│ │ ├── column.rb
│ │ ├── expansion.rb
│ │ ├── page_size.rb
│ │ ├── section.rb
│ │ ├── toggle_property.rb
│ │ ├── east_asian_layout.rb
│ │ ├── page_margins.rb
│ │ ├── footer_reference.rb
│ │ ├── header_reference.rb
│ │ ├── table_look.rb
│ │ ├── language.rb
│ │ ├── numbering.rb
│ │ ├── spacing.rb
│ │ └── columns.rb
│ ├── element.rb
│ ├── parts.rb
│ ├── elements.rb
│ └── parts
│ │ └── settings.rb
│ ├── vml
│ └── elements.rb
│ └── vml.rb
├── examples
├── ochanomizu.jpg
└── base
├── .gitignore
├── spec
├── support
│ ├── data
│ │ ├── elements
│ │ │ ├── break_element.xml
│ │ │ ├── grid_column_element.xml
│ │ │ ├── text_element.xml
│ │ │ ├── symbol_element.xml
│ │ │ ├── break_with_attributes_element.xml
│ │ │ ├── run_element.xml
│ │ │ ├── table_grid_element.xml
│ │ │ ├── table_cell_element.xml
│ │ │ ├── paragraph_element.xml
│ │ │ ├── table_row_element.xml
│ │ │ ├── paragraph_with_runs_element.xml
│ │ │ ├── table_element.xml
│ │ │ └── paragraph_with_section_properties_element.xml
│ │ ├── parts
│ │ │ ├── settings_part.xml
│ │ │ ├── global_rels_part.xml
│ │ │ ├── rels_part.xml
│ │ │ ├── styles_part.xml
│ │ │ ├── content_types_part.xml
│ │ │ └── styles_with_custom_style_part.xml
│ │ └── styles
│ │ │ ├── paragraph_styles.xml
│ │ │ └── character_styles.xml
│ └── part_test_macros.rb
├── elements
│ ├── textbox_content_spec.rb
│ ├── compatibility_settings_spec.rb
│ ├── tab_spec.rb
│ ├── dirty_spec.rb
│ ├── drawing_spec.rb
│ ├── group_shape_spec.rb
│ ├── long_day_spec.rb
│ ├── long_year_spec.rb
│ ├── page_number_spec.rb
│ ├── short_day_spec.rb
│ ├── vml_container_spec.rb
│ ├── carriage_return_spec.rb
│ ├── long_month_spec.rb
│ ├── short_year_spec.rb
│ ├── word_processing_groups_nv_shape_drawing_properties_spec.rb
│ ├── short_month_spec.rb
│ ├── optional_hyphen_spec.rb
│ ├── section_properties_spec.rb
│ ├── run_spec.rb
│ ├── grid_column_spec.rb
│ ├── nonbreaking_hyphen_spec.rb
│ ├── wordprocessing_shape_group_spec.rb
│ ├── table_cell_spec.rb
│ ├── markup_compatibility_fallback_spec.rb
│ ├── last_rendered_page_break_spec.rb
│ ├── word_processing_drawing_wrap_none_spec.rb
│ ├── markup_compatibility_alternate_content_spec.rb
│ ├── table_grid_spec.rb
│ ├── word_processing_drawing_nv_graphic_frame_properties_spec.rb
│ ├── table_row_spec.rb
│ ├── content_part_spec.rb
│ ├── book_fold_printing_spec.rb
│ ├── save_subset_fonts_spec.rb
│ ├── embed_system_fonts_spec.rb
│ ├── font_character_set_spec.rb
│ ├── embed_true_type_fonts_spec.rb
│ ├── font_alternate_name_spec.rb
│ ├── font_panose_one_spec.rb
│ ├── book_fold_reverse_printing_spec.rb
│ ├── table_spec.rb
│ ├── font_pitch_spec.rb
│ ├── title_page_spec.rb
│ ├── text_spec.rb
│ ├── deleted_text_spec.rb
│ ├── markup_compatibility_choice_spec.rb
│ ├── even_and_odd_headers_spec.rb
│ ├── word_processing_shapes_textual_content_spec.rb
│ ├── word_processing_shapes_shape_spec.rb
│ ├── word_processing_drawing_wrap_polygon_spec.rb
│ ├── word_processing_drawing_position_v_spec.rb
│ ├── book_fold_printing_sheets_spec.rb
│ ├── word_processing_drawing_position_h_spec.rb
│ ├── word_processing_shapes_shape_properties_spec.rb
│ ├── word_processing_groups_group_shape_properties_spec.rb
│ └── symbol_spec.rb
├── properties
│ ├── run_style_spec.rb
│ ├── paragraph_style_spec.rb
│ ├── phonetic_guide_language_spec.rb
│ ├── div_id_spec.rb
│ ├── style_name_spec.rb
│ ├── header_spec.rb
│ ├── linked_style_spec.rb
│ ├── parent_style_spec.rb
│ ├── next_style_spec.rb
│ ├── table_style_spec.rb
│ ├── table_caption_spec.rb
│ ├── table_description_spec.rb
│ ├── outline_level_spec.rb
│ ├── bold_spec.rb
│ ├── language_spec.rb
│ ├── valign_spec.rb
│ ├── bidi_spec.rb
│ ├── caps_spec.rb
│ ├── italics_spec.rb
│ ├── math_spec.rb
│ ├── emboss_spec.rb
│ ├── hidden_spec.rb
│ ├── imprint_spec.rb
│ ├── no_wrap_spec.rb
│ ├── outline_spec.rb
│ ├── complex_bold_spec.rb
│ ├── no_proof_spec.rb
│ ├── personal_spec.rb
│ ├── right_to_left_spec.rb
│ ├── shadow_property_spec.rb
│ ├── small_caps_spec.rb
│ ├── style_lock_spec.rb
│ ├── hidden_text_spec.rb
│ ├── hide_mark_spec.rb
│ ├── keep_next_spec.rb
│ ├── title_page_spec.rb
│ ├── cant_split_spec.rb
│ ├── complex_italics_spec.rb
│ ├── hidden_style_spec.rb
│ ├── keep_lines_spec.rb
│ ├── kerning_spec.rb
│ ├── rtl_gutter_spec.rb
│ ├── strikethrough_spec.rb
│ ├── web_hidden_spec.rb
│ ├── font_size_spec.rb
│ ├── primary_style_spec.rb
│ ├── semi_hidden_spec.rb
│ ├── table_header_spec.rb
│ ├── auto_space_de_spec.rb
│ ├── auto_space_dn_spec.rb
│ ├── spec_vanish_spec.rb
│ ├── ui_priority_spec.rb
│ ├── form_protection_spec.rb
│ ├── grid_span_spec.rb
│ ├── mirror_indent_spec.rb
│ ├── personal_reply_spec.rb
│ ├── complex_script_formatting_spec.rb
│ ├── double_strikethrough_spec.rb
│ ├── table_cell_fit_text_spec.rb
│ ├── complex_font_size_spec.rb
│ ├── personal_compose_spec.rb
│ ├── supress_overlap_spec.rb
│ ├── overflow_punctuation_spec.rb
│ ├── unhide_when_used_spec.rb
│ ├── page_break_before_spec.rb
│ ├── phonetic_guide_font_size_spec.rb
│ ├── table_overlap_spec.rb
│ ├── table_row_height_spec.rb
│ ├── vertical_merge_spec.rb
│ ├── auto_adjust_right_indent_spec.rb
│ ├── wafter_spec.rb
│ ├── contextual_spacing_spec.rb
│ ├── style_auto_redefinition_spec.rb
│ ├── table_width_spec.rb
│ ├── wbefore_spec.rb
│ ├── even_and_odd_headers_spec.rb
│ ├── supress_auto_hyphens_spec.rb
│ ├── supress_line_numbers_spec.rb
│ ├── table_cell_width_spec.rb
│ ├── phonetic_guide_font_size_raise_spec.rb
│ ├── phonetic_guide_base_font_size_spec.rb
│ ├── table_cell_spacing_spec.rb
│ ├── grid_after_spec.rb
│ ├── position_spec.rb
│ ├── grid_before_spec.rb
│ ├── style_aliases_spec.rb
│ ├── character_spacing_spec.rb
│ ├── table_layout_spec.rb
│ ├── expansion_spec.rb
│ ├── vertical_alignment_spec.rb
│ ├── kinsoku_spec.rb
│ ├── vertical_text_alignment_spec.rb
│ ├── word_wrap_spec.rb
│ └── snap_to_grid_spec.rb
├── spec_helper.rb
└── parts
│ ├── settings_spec.rb
│ └── styles_spec.rb
├── Rakefile
├── bin
├── setup
└── console
├── Gemfile
└── .github
└── workflows
└── ci.yml
/lib/openxml-docx.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx"
2 |
--------------------------------------------------------------------------------
/examples/ochanomizu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxml/openxml-docx/HEAD/examples/ochanomizu.jpg
--------------------------------------------------------------------------------
/lib/openxml/docx/version.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | VERSION = "0.11.5"
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .ruby-version
2 | .DS_Store
3 | rocx-0.1.0.gem
4 | *.gem
5 | .rspec-local
6 | /coverage
7 | TODO.md
8 |
--------------------------------------------------------------------------------
/spec/support/data/elements/break_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require "rspec/core/rake_task"
2 |
3 | RSpec::Core::RakeTask.new
4 | task default: :spec
5 | task test: :spec
6 | require "bundler/gem_tasks"
7 |
--------------------------------------------------------------------------------
/spec/support/data/elements/grid_column_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euo pipefail
3 | IFS=$'\n\t'
4 | set -vx
5 |
6 | bundle install
7 |
8 | # Do any other automated setup that you need to do here
9 |
--------------------------------------------------------------------------------
/spec/support/data/elements/text_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Banana
4 |
5 |
--------------------------------------------------------------------------------
/spec/support/data/elements/symbol_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/tab.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Tab < OpenXml::Docx::Element
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/bidi.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Bidi < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/caps.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Caps < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/dirty.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Dirty < OpenXml::Docx::Element
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/div_id.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class DivId < IntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/emboss.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Emboss < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/header.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Header < StringProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/hidden.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Hidden < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/imprint.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Imprint < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/kinsoku.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Kinsoku < OnOffProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/no_proof.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class NoProof < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/no_wrap.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class NoWrap < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/outline.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Outline < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/shadow.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Shadow < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/word_wrap.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class WordWrap < OnOffProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/spec/support/data/elements/break_with_attributes_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/cant_split.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class CantSplit < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/grid_after.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class GridAfter < IntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/hide_mark.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class HideMark < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/keep_lines.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class KeepLines < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/keep_next.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class KeepNext < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/personal.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Personal < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/position.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Position < IntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/rtl_gutter.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class RtlGutter < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/semi_hidden.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SemiHidden < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/small_caps.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SmallCaps < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/snap_to_grid.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SnapToGrid < OnOffProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/spec_vanish.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SpecVanish < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/web_hidden.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class WebHidden < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/grid_before.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class GridBefore < IntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/grid_span.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class GridSpan < PositiveIntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/mirror_indent.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class MirrorIndent < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/ui_priority.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class UiPriority < IntegerProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/widow_control.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class WidowControl < OnOffProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/spec/support/data/elements/run_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/spec/support/data/elements/table_grid_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/personal_reply.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PersonalReply < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/supress_overlap.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SupressOverlap < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/unhide_when_used.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class UnhideWhenUsed < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/element.rb:
--------------------------------------------------------------------------------
1 | require "openxml/element"
2 |
3 | module OpenXml
4 | module Docx
5 | class Element < ::OpenXml::Element
6 | namespace :w
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/contextual_spacing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ContextualSpacing < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/page_break_before.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PageBreakBefore < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/personal_compose.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PersonalCompose < BooleanProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/even_and_odd_headers.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class EvenAndOddHeaders < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/supress_auto_hyphens.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SupressAutoHyphens < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/supress_line_numbers.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SupressLineNumbers < ToggleProperty
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/bold.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Bold < ToggleProperty
5 | tag :b
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/support/data/elements/table_cell_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/last_rendered_page_break.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class LastRenderedPageBreak < OpenXml::Docx::Element
5 | end
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/italics.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Italics < ToggleProperty
5 | tag :i
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/math.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Math < ToggleProperty
5 | tag :oMath
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/run_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class RunStyle < Style
5 | tag :rStyle
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/start.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Start < IntegerProperty
5 | tag :start
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/support/data/elements/paragraph_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/style_lock.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StyleLock < ToggleProperty
5 | tag :locked
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/title_page.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TitlePage < ToggleProperty
5 | tag :titlePg
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/long_day.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class LongDay < OpenXml::Docx::Element
5 | tag :dayLong
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/page_number.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class PageNumber < OpenXml::Docx::Element
5 | tag :pgNum
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/complex_bold.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ComplexBold < ToggleProperty
5 | tag :bCs
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/hidden_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class HiddenStyle < ToggleProperty
5 | tag :hidden
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/hidden_text.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class HiddenText < ToggleProperty
5 | tag :vanish
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/kerning.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Kerning < PositiveIntegerProperty
5 | tag :kern
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/paragraph_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ParagraphStyle < Style
5 | tag :pStyle
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/primary_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PrimaryStyle < ToggleProperty
5 | tag :qFormat
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/right_to_left.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class RightToLeft < ToggleProperty
5 | tag :rtl
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/style_aliases.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StyleAliases < StringProperty
5 | tag :aliases
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/style_name.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StyleName < StringProperty
5 | tag :name
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/long_month.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class LongMonth < OpenXml::Docx::Element
5 | tag :monthLong
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/long_year.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class LongYear < OpenXml::Docx::Element
5 | tag :yearLong
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/short_day.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class ShortDay < OpenXml::Docx::Element
5 | tag :dayShort
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/short_year.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class ShortYear < OpenXml::Docx::Element
5 | tag :yearShort
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/complex_italics.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ComplexItalics < ToggleProperty
5 | tag :iCs
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/font_size.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class FontSize < PositiveIntegerProperty
5 | tag :sz
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/form_protection.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class FormProtection < ToggleProperty
5 | tag :formProt
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_header.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableHeader < ToggleProperty
5 | tag :tblHeader
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableStyle < StringProperty
5 | tag :tblStyle
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/elements/textbox_content_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::TextboxContent do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :txbxContent, name: "textbox_content"
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/carriage_return.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class CarriageReturn < OpenXml::Docx::Element
5 | tag :cr
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/short_month.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class ShortMonth < OpenXml::Docx::Element
5 | tag :monthShort
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/parts.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Parts
4 | end
5 | end
6 | end
7 |
8 | Dir.glob("#{File.join(File.dirname(__FILE__), "parts", "*.rb")}").each do |file|
9 | require file
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/auto_space_de.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class AutoSpaceDe < BooleanProperty
5 | tag :autoSpaceDE
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/auto_space_dn.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class AutoSpaceDn < BooleanProperty
5 | tag :autoSpaceDN
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/legal_numbering.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LegalNumbering < OnOffProperty
5 | tag :isLgl
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/level_restart.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LevelRestart < IntegerProperty
5 | tag :lvlRestart
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/strikethrough.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Strikethrough < BooleanProperty
5 | tag :strike
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_caption.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableCaption < StringProperty
5 | tag :tblCaption
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/character_spacing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class CharacterSpacing < IntegerProperty
5 | tag :spacing
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/start_override.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StartOverride < IntegerProperty
5 | tag :startOverride
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_fit_text.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableCellFitText < BooleanProperty
5 | tag :tcFitText
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/hyperlink.rb:
--------------------------------------------------------------------------------
1 | class OpenXml::Docx::Elements::Hyperlink < OpenXml::Docx::Element
2 | include OpenXml::HasChildren
3 |
4 | tag :hyperlink
5 |
6 | with_namespace :r do
7 | attribute :id
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/nonbreaking_hyphen.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class NonbreakingHyphen < OpenXml::Docx::Element
5 | tag :noBreakHyphen
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/optional_hyphen.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class OptionalHyphen < OpenXml::Docx::Element
5 | tag :softHyphen
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/complex_font_size.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ComplexFontSize < PositiveIntegerProperty
5 | tag :szCs
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/double_strikethrough.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class DoubleStrikethrough < BooleanProperty
5 | tag :dstrike
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/outline_level.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class OutlineLevel < PositiveIntegerProperty
5 | tag :outlineLvl
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_description.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableDescription < StringProperty
5 | tag :tblDescription
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/elements/compatibility_settings_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::CompatibilitySettings do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :compat, name: "compatibility_settings"
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/abstract_number_id.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class AbstractNumberingId < IntegerProperty
5 | tag :abstractNumId
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/complex_script_formatting.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ComplexScriptFormatting < ToggleProperty
5 | tag :cs
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/compress_punctuation.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class CompressPunctuation < OnOffProperty
5 | tag :topLinePunct
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/style_auto_redefinition.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StyleAutoRedefinition < ToggleProperty
5 | tag :autoRedefine
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/overflow_punctuation.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class OverflowPunctuation < BooleanProperty
5 | tag :overflowPunct
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/support/data/parts/settings_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/content_part.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class ContentPart < OpenXml::Docx::Element
5 | attribute :id, expects: :string, namespace: :r
6 |
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/tabs.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/tab"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class Tabs < ContainerProperty
7 | child_class :tab
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/deleted_text.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class DeletedText < Text
5 | tag :del
6 | attribute :space, one_of: [:preserve, nil], namespace: :xml
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/drawing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Drawing < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :drawing
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/phonetic_guide_font_size.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PhoneticGuideFontSize < PositiveIntegerProperty
5 | tag :hps
6 | name "font_size"
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/group_shape.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class GroupShape < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :grpSp
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/table_grid.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class TableGrid < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :tblGrid
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/vml_container.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class VmlContainer < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :pict
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/headers.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/header"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class Headers < ContainerProperty
7 | child_class :header
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/valign.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class VAlign < ValueProperty
5 |
6 | def ok_values
7 | %i(both bottom center top)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_none.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapNone < OpenXml::Docx::Element
5 | tag :wrapNone
6 | namespace :wp
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/suffix.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Suffix < ValueProperty
5 | tag :suff
6 |
7 | def ok_values
8 | %i(tab space nothing)
9 | end
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/grid_column.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class GridColumn < OpenXml::Docx::Element
5 | tag :gridCol
6 |
7 | attribute :w, expects: :integer, namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/section_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class SectionProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :sectPr
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/textbox_content.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class TextboxContent < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :txbxContent
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/auto_adjust_right_indent.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class AutoAdjustRightIndent < BooleanProperty
5 | tag :adjustRightInd
6 | name "auto_adjust_right_ind"
7 |
8 | end
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/text_direction.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TextDirection < ValueProperty
5 |
6 | def ok_values
7 | %i(lr lrV rl rlV tb tbV btLr)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/elements/tab_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Tab do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :tab, name: "tab"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/compatibility_setting.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class CompatibilitySettings < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :compat
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/phonetic_guide_base_font_size.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PhoneticGuideBaseFontSize < PositiveIntegerProperty
5 | tag :hpsBaseText
6 | name "base_font_size"
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/phonetic_guide_font_size_raise.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PhoneticGuideFontSizeRaise < PositiveIntegerProperty
5 | tag :hpsRaise
6 | name "font_size_raise"
7 | end
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/even_and_odd_headers.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EvenAndOddHeaders < OpenXml::Docx::Element
5 |
6 | attribute :value, expects: :boolean, displays_as: :val, namespace: :w
7 |
8 | end
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_layout.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableLayout < ComplexProperty
5 | tag :tblLayout
6 |
7 | attribute :type, one_of: %i(autofit fixed), namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/text_alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TextAlignment < ValueProperty
5 |
6 | def ok_values
7 | %i(auto baseline bottom center top)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/elements/dirty_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Dirty do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :dirty, name: "dirty"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/emphasis.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Emphasis < ValueProperty
5 | tag :em
6 |
7 | def ok_values
8 | %i(circle comma dot none underDot)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_overlap.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableOverlap < ValueProperty
5 | tag :tblOverlap
6 |
7 | def ok_values
8 | %i(never overlap)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/elements/drawing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Drawing do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :drawing, name: "drawing"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/support/data/elements/table_row_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/title_page.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class TitlePage < OpenXml::Docx::Element
5 | tag :titlePg
6 |
7 | attribute :value, expects: :boolean, displays_as: :val, namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/vertical_merge.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class VerticalMerge < ValueProperty
5 | tag :vMerge
6 |
7 | def ok_values
8 | %i(restart continue)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/elements/group_shape_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::GroupShape do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :grpSp, name: "group_shape"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/elements/long_day_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::LongDay do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :dayLong, name: "long_day"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/wordprocessing_shape_group.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordprocessingShapeGroup < OpenXml::Docx::Element
5 | include HasChildren
6 |
7 | tag :wgp
8 | namespace :wpg
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/effect.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Effect < ValueProperty
5 |
6 | def ok_values
7 | %i(antsBlack antsRed blinkBackground lights none shimmer sparkle)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/elements/long_year_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::LongYear do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :yearLong, name: "long_year"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/page_number_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::PageNumber do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :pgNum, name: "page_number"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/short_day_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::ShortDay do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :dayShort, name: "short_day"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/vml_container_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::VmlContainer do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :pict, name: "vml_container"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/elements/carriage_return_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::CarriageReturn do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :cr, name: "carriage_return"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/long_month_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::LongMonth do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :monthLong, name: "long_month"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/short_year_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::ShortYear do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :yearShort, name: "short_year"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_groups_nv_shape_drawing_properties_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingGroupsNvShapeDrawingProperties do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :cNvGrpSpPr, name: "word_processing_groups_nv_shape_drawing_properties"
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/footer_references.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/footer_reference"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class FooterReferences < TransparentContainerProperty
7 | child_class :footer_reference
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/header_references.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/header_reference"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class HeaderReferences < TransparentContainerProperty
7 | child_class :header_reference
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_borders.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/table_border"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class TableBorders < ContainerProperty
7 | tag :tblBorders
8 | child_class :table_border
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/elements/short_month_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::ShortMonth do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :monthShort, name: "short_month"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/support/data/parts/global_rels_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/textbox_tight_wrap.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TextboxTightWrap < ValueProperty
5 |
6 | def ok_values
7 | %i(allLines firstAndLastLine firstLineOnly lastLineOnly none)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/vertical_text_alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class VerticalTextAlignment < ValueProperty
5 | tag :vAlign
6 |
7 | def ok_values
8 | %i(both bottom center top)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/book_fold_printing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class BookFoldPrinting < OpenXml::Docx::Element
5 | tag :bookFoldPrinting
6 |
7 | attribute :value, expects: :boolean, displays_as: :val, namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/vertical_alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class VerticalAlignment < ValueProperty
5 | tag :vertAlign
6 |
7 | def ok_values
8 | %i(baseline subscript superscript)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/markup_compatibility_fallback.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class MarkupCompatibilityFallback < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :Fallback
8 | namespace :mc
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/multi_level_type.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class MultiLevelType < ValueProperty
5 | tag :multiLevelType
6 |
7 | def ok_values
8 | %i(singleLevel multilevel hybridMultilevel)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/vml/elements.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Vml
3 | module Elements
4 | end
5 | end
6 | end
7 |
8 | require "openxml/element"
9 | require "openxml/has_children"
10 | require "openxml/docx/elements/text"
11 | Dir.glob("#{File.join(File.dirname(__FILE__), "elements", "*.rb")}").each do |file|
12 | require file
13 | end
14 |
--------------------------------------------------------------------------------
/spec/elements/optional_hyphen_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::OptionalHyphen do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :softHyphen, name: "optional_hyphen"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/section_properties_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::SectionProperties do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :sectPr, name: "section_properties"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_borders.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/table_cell_border"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class TableCellBorders < ContainerProperty
7 | tag :tcBorders
8 | child_class :table_cell_border
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_cell_margin.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/table_cell_margin"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class TableCellCellMargin < ContainerProperty
7 | tag :tcMar
8 | child_class :table_cell_margin
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_margins.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/table_cell_margin"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class TableCellMargins < ContainerProperty
7 | tag :tblCellMar
8 | child_class :table_cell_margin
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | end
5 | end
6 | end
7 |
8 | require "openxml/docx/element"
9 | require "openxml/has_children"
10 | require "openxml/docx/elements/text"
11 | Dir.glob("#{File.join(File.dirname(__FILE__), "elements", "*.rb")}").each do |file|
12 | require file
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/book_fold_reverse_printing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class BookFoldReversePrinting < OpenXml::Docx::Element
5 | tag :bookFoldRevPrinting
6 |
7 | attribute :value, expects: :boolean, displays_as: :val, namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/level_text.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LevelText < StringProperty
5 | include HasAttributes
6 | tag :lvlText
7 |
8 | with_namespace :w do
9 | attribute :null, expects: :boolean
10 | end
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/elements/run_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Run do
4 | include ElementTestMacros
5 |
6 | context "after creation" do
7 | before(:each) do
8 | @instance = described_class.new
9 | instance.italics = true
10 | end
11 |
12 | it_should_output_correct_xml
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/spec/properties/run_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::RunStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :rStyle, name: "run_style", value: "Nope"
7 |
8 | with_value("Nope") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gemspec
4 |
5 | # Optional: use the development version of openxml-package
6 | # gem "openxml-package", github: "openxml/openxml-package", branch: "master"
7 |
8 | # Optional: use the development version of openxml-drawingml
9 | # gem "openxml-drawingml", github: "openxml/openxml-drawingml", branch: "master"
10 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/bidi_embed.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class BidiEmbed < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :dir
8 | attribute :direction, one_of: %i(rtl ltr), displays_as: :val, namespace: :w
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/grid_column_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::GridColumn do
4 | include ElementTestMacros
5 |
6 | context "after creation" do
7 | before(:each) do
8 | @instance = described_class.new
9 | instance.w = 1
10 | end
11 |
12 | it_should_output_correct_xml
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/spec/elements/nonbreaking_hyphen_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::NonbreakingHyphen do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :noBreakHyphen, name: "nonbreaking_hyphen"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/book_fold_printing_sheets.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class BookFoldPrintingSheets < OpenXml::Docx::Element
5 | tag :bookFoldPrintingSheets
6 |
7 | attribute :value, expects: :positive_integer, displays_as: :val, namespace: :w
8 |
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/embed_system_fonts.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EmbedSystemFonts < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :value, expects: :boolean, displays_as: :val
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/save_subset_fonts.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class SaveSubsetFonts < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :value, expects: :boolean, displays_as: :val
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/section_type.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class SectionType < ValueProperty
5 | tag :type
6 | name "type"
7 |
8 | def ok_values
9 | %i(continuous evenPage nextColumn nextPage oddPage)
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/elements/wordprocessing_shape_group_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordprocessingShapeGroup do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :wgp, name: "wordprocessing_shape_group"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/bidi_override.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class BidiOverride < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :bdo
8 | attribute :direction, one_of: %i(rtl ltr), displays_as: :val, namespace: :w
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/embed_true_type_fonts.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EmbedTrueTypeFonts < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :value, expects: :boolean, displays_as: :val
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/markup_compatibility_alternate_content.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class MarkupCompatibilityAlternateContent < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :AlternateContent
8 | namespace :mc
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Style < ValueProperty
5 |
6 | def valid?
7 | !value.nil?
8 | end
9 |
10 | def invalid_message
11 | "Invalid #{name}: value must not be nil"
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/elements/table_cell_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::TableCell do
4 | include ElementTestMacros
5 |
6 | context "after creation" do
7 | before(:each) do
8 | @instance = described_class.new
9 | instance.no_wrap = true
10 | end
11 |
12 | it_should_output_correct_xml
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/spec/support/data/elements/paragraph_with_runs_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Hey Run 1
9 |
10 |
11 | Hey Run 2
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/transparent_container_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TransparentContainerProperty < ContainerProperty
5 |
6 | def to_xml(xml)
7 | return unless render?
8 | each { |child| child.to_xml(xml) }
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/elements/markup_compatibility_fallback_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::MarkupCompatibilityFallback do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :Fallback, name: "markup_compatibility_fallback"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/properties/paragraph_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ParagraphStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :pStyle, name: "paragraph_style", value: "Nope"
7 |
8 | with_value("Nope") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/properties/phonetic_guide_language_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PhoneticGuideLanguage do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :lid, name: "language", value: "ja-JP"
7 |
8 | with_value("ja-JP") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/paper_source.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PaperSource < ComplexProperty
5 | tag :paperSrc
6 |
7 | with_namespace :w do
8 | attribute :first, expects: :integer
9 | attribute :other, expects: :integer
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_groups_nv_shape_drawing_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingGroupsNvShapeDrawingProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :cNvGrpSpPr
8 | namespace :wpg
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Alignment < ValueProperty
5 | tag :jc
6 |
7 | def ok_values
8 | %i(both center distribute end highKashida lowKashida mediumKashida numTab start thaiDistribute left right)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/wafter.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class WAfter < ComplexProperty
5 |
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
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/wbefore.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class WBefore < ComplexProperty
5 |
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
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/support/data/styles/paragraph_styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font_panose_one.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class FontPanoseOne < OpenXml::Docx::Element
5 | namespace :w
6 | tag :panose1
7 |
8 | with_namespace :w do
9 | attribute :value, expects: :hex_string, displays_as: :val
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/highlight.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Highlight < ValueProperty
5 |
6 | def ok_values
7 | %i(black blue cyan darkBlue darkCyan darkGray darkGreen darkMagenta darkRed darkYellow green lightGray magenta none red white yellow)
8 | end
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_row_height.rb:
--------------------------------------------------------------------------------
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
14 |
--------------------------------------------------------------------------------
/spec/elements/last_rendered_page_break_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::LastRenderedPageBreak do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :lastRenderedPageBreak, name: "last_rendered_page_break"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_drawing_wrap_none_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingDrawingWrapNone do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :wrapNone, name: "word_processing_drawing_wrap_none"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font_alternate_name.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class FontAlternateName < OpenXml::Docx::Element
5 | namespace :w
6 | tag :altName
7 |
8 | with_namespace :w do
9 | attribute :value, expects: :string, displays_as: :val
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font_pitch.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class FontPitch < OpenXml::Docx::Element
5 | namespace :w
6 | tag :pitch
7 |
8 | with_namespace :w do
9 | attribute :value, one_of: %i(default fixed variable), displays_as: :val
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_nv_graphic_frame_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingNvGraphicFrameProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :cNvGraphicFramePr
8 | namespace :wp
9 |
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/integer_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class IntegerProperty < ValueProperty
5 |
6 | def valid?
7 | value.is_a? Integer
8 | end
9 |
10 | def invalid_message
11 | "Invalid #{name}: must be an integer"
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/break.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Break < OpenXml::Docx::Element
5 | tag :br
6 |
7 | with_namespace :w do
8 | attribute :clear, one_of: %i(all left none right)
9 | attribute :type, one_of: %i(column page textWrapping)
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Font < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | namespace :w
8 |
9 | with_namespace :w do
10 | attribute :font_name, expects: :string, displays_as: :name
11 | end
12 |
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/symbol.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Symbol < OpenXml::Docx::Element
5 | tag :sym
6 |
7 | with_namespace :w do
8 | attribute :font, expects: :string
9 | attribute :character, expects: :hex_digit_4, displays_as: :char
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_simple_position.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingSimplePosition < OpenXml::Docx::Element
5 | tag :simplePos
6 | namespace :wp
7 |
8 | attribute :x, expects: :integer
9 | attribute :y, expects: :integer
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/level_alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LevelAlignment < ValueProperty
5 | tag :lvlJc
6 |
7 | def ok_values
8 | %i(both center distribute end highKashida lowKashida mediumKashida numTab start thaiDistribute left right)
9 | end
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/bin/console:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "bundler/setup"
4 | require "openxml/docx"
5 |
6 | # You can add fixtures and/or initialization code here to make experimenting
7 | # with your gem easier. You can also use a different console, if you like.
8 |
9 | # (If you use this, don't forget to add pry to your Gemfile!)
10 | # require "pry"
11 | # Pry.start
12 |
13 | require "irb"
14 | IRB.start
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font_character_set.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class FontCharacterSet < OpenXml::Docx::Element
5 | namespace :w
6 | tag :charset
7 |
8 | with_namespace :w do
9 | attribute :character_set, expects: :string, displays_as: :characterSet
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/boolean_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class BooleanProperty < ValueProperty
5 |
6 | def ok_values
7 | [nil, true, false]
8 | end
9 |
10 | def to_xml(xml)
11 | xml["w"].public_send(tag, "w:val" => value) if value
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/manual_width.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ManualWidth < ComplexProperty
5 | tag :fitText
6 |
7 | with_namespace :w do
8 | attribute :id, expects: :integer
9 | attribute :width, expects: :positive_integer, displays_as: :val
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/properties/div_id_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::DivId do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :divId, name: "div_id", value: 1
7 |
8 | with_value(2) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:big) do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_polygon.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapPolygon < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :wrapPolygon
8 | namespace :wp
9 |
10 | attribute :edited, expects: :boolean
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/phonetic_guide_alignment.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PhoneticGuideAlignment < ValueProperty
5 | tag :rubyAlign
6 | name "alignment"
7 |
8 | def ok_values
9 | %i(center distributeLetter distributeSpace left right rightVertical)
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_width.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableWidth < ComplexProperty
5 | tag :tblW
6 |
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
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/elements/markup_compatibility_alternate_content_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::MarkupCompatibilityAlternateContent do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :AlternateContent, name: "markup_compatibility_alternate_content"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/markup_compatibility_choice.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class MarkupCompatibilityChoice < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :Choice
8 | namespace :mc
9 |
10 | attribute :requires, expects: :string, displays_as: :Requires
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_shapes_textual_contents.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingShapesTextualContent < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :txbx
8 | namespace :wps
9 |
10 | attribute :id, expects: :positive_integer
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_indent.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableIndent < ComplexProperty
5 | tag :tblInd
6 |
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
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/support/data/elements/table_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/positive_integer_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PositiveIntegerProperty < IntegerProperty
5 |
6 | def valid?
7 | super && value >= 0
8 | end
9 |
10 | def invalid_message
11 | "Invalid #{name}: must be a positive integer"
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_width.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableCellWidth < ComplexProperty
5 | tag :tcW
6 |
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
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/next_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class NextStyle < ValueProperty
5 | tag :next
6 |
7 | def valid?
8 | value.is_a?(String) && value.length > 0
9 | end
10 |
11 | def invalid_message
12 | "#{name} must be a string that is not empty"
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/parent_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ParentStyle < ValueProperty
5 | tag :basedOn
6 |
7 | def valid?
8 | value.is_a?(String) && value.length > 0
9 | end
10 |
11 | def invalid_message
12 | "#{name} must be a string that is not empty"
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_shapes_shape.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingShapesShape < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :wsp
8 | namespace :wps
9 | attribute :normal_east_asian_flow, expects: :boolean, displays_as: :normalEastAsianFlow
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/linked_style.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LinkedStyle < ValueProperty
5 | tag :link
6 |
7 | def valid?
8 | value.is_a?(String) && value.length > 0
9 | end
10 |
11 | def invalid_message
12 | "#{name} must be a string that is not empty"
13 | end
14 |
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_spacing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableCellSpacing < ComplexProperty
5 | tag :tblCellSpacing
6 |
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
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/elements/table_grid_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::TableGrid do
4 | include ElementTestMacros
5 |
6 | context "after creation" do
7 | before(:each) do
8 | @instance = described_class.new
9 | column = OpenXml::Docx::Elements::GridColumn.new
10 | column.w = 1
11 | instance << column
12 | end
13 |
14 | it_should_output_correct_xml
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/style_name_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::StyleName do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :name, name: "style_name", value: "Something"
7 |
8 | with_value("Something") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/header_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Header do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :header, name: "header", value: "Something"
7 |
8 | with_value("Something Else") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/linked_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::LinkedStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :link, name: "linked_style", value: "Something"
7 |
8 | with_value("Something") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/string_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class StringProperty < ValueProperty
5 |
6 | def valid?
7 | value.is_a?(String) && !value.length.zero?
8 | end
9 |
10 | def invalid_message
11 | "Invalid value for #{name}; string expected (provided: #{value.inspect})"
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_drawing_nv_graphic_frame_properties_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingDrawingNvGraphicFrameProperties do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :cNvGraphicFramePr, name: "word_processing_drawing_nv_graphic_frame_properties"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require "rr"
2 | require "pry"
3 | require "timecop"
4 | require "support/element_test_macros"
5 | require "support/part_test_macros"
6 | require "support/property_test_macros"
7 | require "support/style_test_macros"
8 | require "support/value_property_test_macros"
9 |
10 | require "simplecov"
11 | SimpleCov.start
12 |
13 | require "openxml/docx"
14 | require "openxml/drawingml"
15 | require "openxml/vml"
16 | require "nokogiri"
17 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_extent.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingExtent < OpenXml::Docx::Element
5 | tag :extent
6 | namespace :wp
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
15 |
--------------------------------------------------------------------------------
/spec/properties/parent_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ParentStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :basedOn, name: "parent_style", value: "Something"
7 |
8 | with_value("Something") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(12.4) do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/control.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Control < OpenXml::Docx::Element
5 | attribute :id, expects: :string, namespace: :r
6 |
7 | with_namespace :w do
8 | attribute :unique_name, expects: :string, displays_as: :name
9 | attribute :shape_id, expects: :string, displays_as: :shapeid
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_cell_margin.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableCellMargin < ComplexProperty
5 | tag_is_one_of %i(top start bottom end left right)
6 |
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
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/vml.rb:
--------------------------------------------------------------------------------
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/has_properties"
8 | require "openxml/docx/properties"
9 | require "openxml/docx/elements"
10 | require "openxml/docx/package"
11 | require "openxml/docx/parts"
12 | require "openxml/docx/section"
13 | require "openxml/docx/style"
14 |
15 | # And then add our own stuff
16 | require "openxml/vml/elements"
17 |
--------------------------------------------------------------------------------
/spec/properties/next_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::NextStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :next, name: "next_style", value: "Style Name"
7 |
8 | with_value("The Name of a Style") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/table_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tblStyle, name: "table_style", value: "Something"
7 |
8 | with_value("Something Else") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/support/data/parts/rels_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/spec/properties/table_caption_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableCaption do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tblCaption, name: "table_caption", value: "Something"
7 |
8 | with_value("Something Else") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/document_grid.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class DocumentGrid < ComplexProperty
5 | tag :docGrid
6 |
7 | with_namespace :w do
8 | attribute :char_space, expects: :integer
9 | attribute :line_pitch, expects: :integer
10 | attribute :type, one_of: %i(default lines linesAndChars snapToChars)
11 | end
12 |
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/elements/table_row_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::TableRow do
4 | include ElementTestMacros
5 |
6 | context "after creation" do
7 | before(:each) do
8 | @instance = described_class.new
9 | instance.hidden = true
10 | cell = OpenXml::Docx::Elements::TableCell.new
11 | cell.no_wrap = true
12 | instance << cell
13 | end
14 |
15 | it_should_output_correct_xml
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/phonetic_guide_language.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PhoneticGuideLanguage < ValueProperty
5 | tag :lid
6 | name "language"
7 |
8 | def valid?
9 | value =~ /[a-z]{2}-[A-Z]{2}/
10 | end
11 |
12 | def invalid_message
13 | "Invalid #{name}: must be a language code (RFC 4646)"
14 | end
15 |
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/support/data/elements/paragraph_with_section_properties_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/spec/support/data/parts/styles_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/spec/properties/table_description_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableDescription do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tblDescription, name: "table_description", value: "Something"
7 |
8 | with_value("Something Else") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("") do
14 | it_should_not_work
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/color.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Color < ComplexProperty
5 | with_namespace :w do
6 | attribute :color, expects: :hex_color, displays_as: :val
7 | attribute :theme_color, one_of: OpenXml::Docx::THEME_COLORS
8 | attribute :theme_shade, expects: :hex_digit
9 | attribute :theme_tint, expects: :hex_digit
10 | end
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/elements/content_part_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::ContentPart do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :contentPart, name: "content_part"
7 |
8 | for_attribute(:id) do
9 | with_value("rId8") do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value("") do
15 | it_should_raise_an_exception
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/properties/outline_level_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::OutlineLevel do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :outlineLvl, name: "outline_level", value: 2
7 |
8 | with_value(:big) do
9 | it_should_not_work
10 | end
11 |
12 | with_value(-1) do
13 | it_should_not_work
14 | end
15 |
16 | with_value(2) do
17 | it_should_work
18 | it_should_output ""
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingShapesShapeProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :spPr
8 | namespace :wps
9 |
10 | attribute :bw_mode, displays_as: :bwMode, one_of: %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white)
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/properties/bold_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Bold do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :b, name: "bold", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/language_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Language do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :lang, name: "language"
7 |
8 | for_attribute(:bidi) do
9 | it_should_assign_and_output_xml "en-US"
10 | end
11 |
12 | for_attribute(:east_asia) do
13 | it_should_assign_and_output_xml "ko-KR"
14 | end
15 |
16 | for_attribute(:latin) do
17 | it_should_assign_and_output_xml "fr-CA"
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_position_h.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingPositionH < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :positionH
8 | namespace :wp
9 |
10 | attribute :relative_from, one_of: %i(character column insideMargin leftMargin margin outsideMargin page rightMargin), displays_as: :relativeFrom
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_position_v.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingPositionV < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :positionV
8 | namespace :wp
9 |
10 | attribute :relative_from, one_of: %i(bottomMargin insideMargin line margin outsideMargin page paragraph topMargin), displays_as: :relativeFrom
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_top_and_bottom.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapTopAndBottom < OpenXml::Docx::Element
5 | tag :wrapTopAndBottom
6 | namespace :wp
7 |
8 | attribute :distance_from_bottom, expects: :positive_integer, displays_as: :distB
9 | attribute :distance_from_top, expects: :positive_integer, displays_as: :distT
10 |
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/on_off_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class OnOffProperty < ValueProperty
5 |
6 | def ok_values
7 | [true, false, :on, :off] # :on and :off are from the Transitional Spec
8 | end
9 |
10 | def to_xml(xml)
11 | return xml["w"].public_send(tag) if value == true
12 | xml["w"].public_send(tag, "w:val" => value)
13 | end
14 |
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/properties/valign_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::VAlign do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :vAlign, name: "v_align", value: :both
7 |
8 | %i(both bottom center top).each do |good_value|
9 | with_value(good_value) do
10 | it_should_work
11 | it_should_output ""
12 | end
13 | end
14 |
15 | with_value(:invalid) do
16 | it_should_not_work
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/text.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Text < OpenXml::Docx::Element
5 | attr_reader :text
6 |
7 | tag :t
8 |
9 | attribute :space, one_of: [:preserve, nil], namespace: :xml
10 |
11 | def initialize(text=nil)
12 | @text = text
13 | end
14 |
15 | def to_xml(xml)
16 | xml["w"].public_send(tag, text, xml_attributes)
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/complex_property.rb:
--------------------------------------------------------------------------------
1 | require "openxml/has_attributes"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class ComplexProperty < BaseProperty
7 | include HasAttributes
8 |
9 | def to_xml(xml)
10 | return unless render?
11 | xml[namespace].public_send(tag, xml_attributes)
12 | end
13 |
14 | def render?
15 | !xml_attributes.empty?
16 | end
17 |
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/bidi_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Bidi do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :bidi, name: "bidi", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/caps_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Caps do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :caps, name: "caps", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/italics_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Italics do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :i, name: "italics", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/math_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Math do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :oMath, name: "math", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_groups_group_shape_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingGroupsGroupShapeProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :grpSpPr
8 | namespace :wpg
9 |
10 | attribute :bw_mode, one_of: %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white), displays_as: :bwMode
11 |
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/properties/emboss_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Emboss do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :emboss, name: "emboss", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/hidden_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Hidden do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hidden, name: "hidden", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/line_numbering.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class LineNumbering < ComplexProperty
5 | tag :lnNumType
6 |
7 | with_namespace :w do
8 | attribute :count_by, expects: :integer
9 | attribute :distance, expects: :positive_integer
10 | attribute :restart, one_of: %i(continuous newPage newSection)
11 | attribute :start, expects: :integer
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/elements/book_fold_printing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::BookFoldPrinting do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :bookFoldPrinting, name: "book_fold_printing"
7 |
8 | for_attribute(:value) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value("true") do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/imprint_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Imprint do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :imprint, name: "imprint", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/no_wrap_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::NoWrap do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :noWrap, name: "no_wrap", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/outline_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Outline do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :outline, name: "outline"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/absolute_position_tab.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class AbsolutePositionTab < OpenXml::Docx::Element
5 | tag :ptab
6 |
7 | with_namespace :w do
8 | attribute :alignment, one_of: %i(center left right)
9 | attribute :leader, one_of: %i(dot hyphen middleDot none underscore)
10 | attribute :relative_to, one_of: %i(indent margin), displays_as: :relativeTo
11 | end
12 |
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/column.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Column < ComplexProperty
5 | tag :col
6 |
7 | with_namespace :w do
8 | attribute :space, expects: :positive_integer
9 | attribute :width, expects: :positive_integer, displays_as: :w
10 | end
11 |
12 | def initialize(space, width)
13 | self.space = space
14 | self.width = width
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/elements/save_subset_fonts_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::SaveSubsetFonts do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :saveSubsetFonts, name: "save_subset_fonts"
7 |
8 | for_attribute(:value) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:somethingElse) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/complex_bold_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ComplexBold do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :bCs, name: "complex_bold", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/no_proof_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::NoProof do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :noProof, name: "no_proof"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/personal_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Personal do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :personal, name: "personal"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/right_to_left_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::RightToLeft do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :rtl, name: "right_to_left", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/shadow_property_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Shadow do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :shadow, name: "shadow"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/small_caps_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SmallCaps do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :smallCaps, name: "small_caps"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/style_lock_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::StyleLock do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :locked, name: "style_lock", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/embed_system_fonts_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::EmbedSystemFonts do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :embedSystemFonts, name: "embed_system_fonts"
7 |
8 | for_attribute(:value) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:somethingElse) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/hidden_text_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::HiddenText do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :vanish, name: "hidden_text", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/hide_mark_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::HideMark do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hideMark, name: "hide_mark", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/keep_next_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::KeepNext do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :keepNext, name: "keep_next", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/title_page_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TitlePage do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :titlePg, name: "title_page", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/font_character_set_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::FontCharacterSet do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :charset, name: "font_character_set"
7 |
8 | for_attribute(:character_set) do
9 | with_value("String") do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:somethingElse) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/cant_split_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::CantSplit do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :cantSplit, name: "cant_split", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/complex_italics_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ComplexItalics do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :iCs, name: "complex_italics", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/hidden_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::HiddenStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hidden, name: "hidden_style", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/keep_lines_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::KeepLines do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :keepLines, name: "keep_lines", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/kerning_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Kerning do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :kern, name: "kerning", value: 22
7 |
8 | with_value(20) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-20) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(23.1) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(:big) do
22 | it_should_not_work
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/spec/properties/rtl_gutter_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::RtlGutter do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :rtlGutter, name: "rtl_gutter"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/strikethrough_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Strikethrough do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :strike, name: "strikethrough"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/web_hidden_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::WebHidden do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :webHidden, name: "web_hidden", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/compatibility_settings.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class CompatibilitySetting < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :compatSetting
8 |
9 | with_namespace :w do
10 | attribute :setting_name, expects: :string, displays_as: :name
11 | attribute :uri, expects: :string
12 | attribute :value, expects: :string, displays_as: :val
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/expansion.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Expansion < ValueProperty
5 | tag :w
6 |
7 | def valid?
8 | return false unless value =~ /(\d{1,3})%/
9 | percentage = $1.to_i
10 | percentage >= 1 && percentage <= 600
11 | end
12 |
13 | def invalid_message
14 | "Invalid #{name}: value must be a percentage greater than 0 or less than 601"
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/elements/embed_true_type_fonts_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::EmbedTrueTypeFonts do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :embedTrueTypeFonts, name: "embed_true_type_fonts"
7 |
8 | for_attribute(:value) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:somethingElse) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/elements/font_alternate_name_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::FontAlternateName do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :altName, name: "font_alternate_name"
7 |
8 | for_attribute(:value) do
9 | with_value("String Font Name") do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:somethingElse) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/elements/font_panose_one_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::FontPanoseOne do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :panose1, name: "font_panose_one"
7 |
8 | for_attribute(:value) do
9 | with_value("ABCDE1234567890") do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value("Not a string of hex digits") do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/font_size_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::FontSize do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :sz, name: "font_size", value: 22
7 |
8 | with_value(20) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-20) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(23.1) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(:big) do
22 | it_should_not_work
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/spec/properties/primary_style_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PrimaryStyle do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :qFormat, name: "primary_style", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/semi_hidden_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SemiHidden do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :semiHidden, name: "semi_hidden", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/table_header_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableHeader do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tblHeader, name: "table_header", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Tests
2 | on: [push]
3 |
4 | jobs:
5 | ruby:
6 | name: Ruby Tests
7 | runs-on: ubuntu-latest
8 | strategy:
9 | matrix:
10 | ruby-version: [ "2.6", "2.7", "3.0" ]
11 |
12 | steps:
13 | - name: Checkout
14 | uses: actions/checkout@v2
15 | - name: Setup Ruby
16 | uses: ruby/setup-ruby@v1
17 | with:
18 | bundler-cache: true
19 | ruby-version: ${{ matrix.ruby-version }}
20 | - name: Run Tests
21 | run: bundle exec rake spec
22 |
--------------------------------------------------------------------------------
/spec/properties/auto_space_de_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::AutoSpaceDe do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :autoSpaceDE, name: "auto_space_de"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/auto_space_dn_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::AutoSpaceDn do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :autoSpaceDN, name: "auto_space_dn"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/spec_vanish_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SpecVanish do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :specVanish, name: "spec_vanish", value: false
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/ui_priority_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::UiPriority do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :uiPriority, name: "ui_priority", value: 1
7 |
8 | with_value(2) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-2) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:low) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/support/data/styles/character_styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/page_size.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PageSize < ComplexProperty
5 | tag :pgSz
6 |
7 | with_namespace :w do
8 | attribute :code, expects: :integer
9 | attribute :height, expects: :positive_integer, displays_as: :h
10 | attribute :orientation, one_of: %i(portrait landscape), displays_as: :orient
11 | attribute :width, expects: :positive_integer, displays_as: :w
12 | end
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/elements/book_fold_reverse_printing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::BookFoldReversePrinting do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :bookFoldRevPrinting, name: "book_fold_reverse_printing"
7 |
8 | for_attribute(:value) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value("true") do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/form_protection_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::FormProtection do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :formProt, name: "form_protection", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/grid_span_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::GridSpan do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :gridSpan, name: "grid_span", value: 22
7 |
8 | with_value(20) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-20) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(23.1) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(:big) do
22 | it_should_not_work
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/section.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/columns"
2 | require "openxml/docx/properties/page_margins"
3 | require "openxml/docx/properties/page_size"
4 | require "openxml/docx/properties/header_reference"
5 | require "openxml/docx/properties/section_type"
6 |
7 | module OpenXml
8 | module Docx
9 | module Properties
10 | class Section < ContainerProperty
11 | tag :sectPr
12 | child_classes :page_size, :page_margins, :columns, :header_reference, :section_type
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/elements/table_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Table do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :tbl, name: "table"
7 |
8 | before(:each) do
9 | @instance = described_class.new
10 | instance.cant_split = true
11 | row = OpenXml::Docx::Elements::TableRow.new
12 | row.hidden = true
13 | cell = OpenXml::Docx::Elements::TableCell.new
14 | cell.no_wrap = true
15 | row << cell
16 | instance << row
17 | end
18 |
19 | it_should_output_correct_xml
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/mirror_indent_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::MirrorIndent do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :mirrorIndent, name: "mirror_indent", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/personal_reply_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PersonalReply do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :personalReply, name: "personal_reply"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/complex_script_formatting_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ComplexScriptFormatting do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :cs, name: "complex_script_formatting", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/double_strikethrough_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::DoubleStrikethrough do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :dstrike, name: "double_strikethrough"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/table_cell_fit_text_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableCellFitText do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tcFitText, name: "table_cell_fit_text"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/complex_font_size_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ComplexFontSize do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :szCs, name: "complex_font_size", value: 22
7 |
8 | with_value(20) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-20) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(23.1) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(:big) do
22 | it_should_not_work
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/spec/properties/personal_compose_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PersonalCompose do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :personalCompose, name: "personal_compose"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/supress_overlap_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SupressOverlap do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :supressOverlap, name: "supress_overlap", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/overflow_punctuation_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::OverflowPunctuation do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :overflowPunct, name: "overflow_punctuation"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/unhide_when_used_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::UnhideWhenUsed do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :unhideWhenUsed, name: "unhide_when_used", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/font_pitch_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::FontPitch do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :pitch, name: "font_pitch"
7 |
8 | for_attribute(:value) do
9 | %i(default fixed variable).each do |good_value|
10 | with_value(good_value) do
11 | it_should_assign_successfully
12 | it_should_output ""
13 | end
14 | end
15 |
16 | with_value(:bad_value) do
17 | it_should_raise_an_exception
18 | end
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/page_break_before_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PageBreakBefore do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :pageBreakBefore, name: "page_break_before", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/phonetic_guide_font_size_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PhoneticGuideFontSize do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hps, name: "font_size", value: 1
7 |
8 | with_value(24) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-24) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(:big) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(23.3) do
22 | it_should_not_work
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/spec/properties/table_overlap_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableOverlap do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :tblOverlap, name: "table_overlap", value: :never
7 |
8 | with_value(:never) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:overlap) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:nope) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/table_row_height_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableRowHeight do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :trHeight, name: "table_row_height"
7 |
8 | for_attribute(:hRule) do
9 | values = %i(auto atLeast exact)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | end
13 |
14 | for_attribute(:val) do
15 | it_should_assign_and_output_xml 2
16 | it_should_not_allow_floats
17 | it_should_not_allow_invalid_value
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/spec/properties/vertical_merge_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::VerticalMerge do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :vMerge, name: "vertical_merge", value: :restart
7 |
8 | with_value(:restart) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:continue) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:not_ok) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_effect_extent.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingEffectExtent < OpenXml::Docx::Element
5 | tag :effectExtent
6 | namespace :wp
7 |
8 | attribute :bottom_edge, expects: :integer, displays_as: :b
9 | attribute :left_edge, expects: :integer, displays_as: :l
10 | attribute :right_edge, expects: :integer, displays_as: :r
11 | attribute :top_edge, expects: :integer, displays_as: :t
12 |
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/properties/auto_adjust_right_indent_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::AutoAdjustRightIndent do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :adjustRightInd, name: "auto_adjust_right_ind"
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/wafter_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::WAfter do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :wAfter, name: "w_after"
7 |
8 | for_attribute(:type) do
9 | values = %i(auto dxa nil pct)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | it_should_not_allow_integers
13 | end
14 |
15 | for_attribute(:width) do
16 | it_should_assign_and_output_xml 2
17 | it_should_not_allow_invalid_value
18 | it_should_not_allow_floats
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/contextual_spacing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::ContextualSpacing do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :contextualSpacing, name: "contextual_spacing", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/style_auto_redefinition_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::StyleAutoRedefinition do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :autoRedefine, name: "style_auto_redefinition", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/table_width_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableWidth do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :tblW, name: "table_width"
7 |
8 | for_attribute(:type) do
9 | values = %i(dxa pct)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | it_should_not_allow_integers
13 | end
14 |
15 | for_attribute(:width) do
16 | it_should_assign_and_output_xml 2
17 | it_should_not_allow_floats
18 | it_should_not_allow_invalid_value
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/wbefore_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::WBefore do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :wBefore, name: "w_before"
7 |
8 | for_attribute(:type) do
9 | values = %i(auto dxa nil pct)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | it_should_not_allow_integers
13 | end
14 |
15 | for_attribute(:width) do
16 | it_should_assign_and_output_xml 2
17 | it_should_not_allow_invalid_value
18 | it_should_not_allow_floats
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/toggle_property.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class ToggleProperty < OnOffProperty
5 | # Toggle properties are no different in representation than on/off properties;
6 | # rather, the difference is in how they compose with one another (cf.
7 | # Section 17.7.3). It's helpful, then, to retain the concept, but entirely
8 | # unnecessary to duplicate implementation.
9 | # cf. Section A.6.9 of the spec, and Section A.7.9 of the transitional spec.
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/properties/even_and_odd_headers_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::EvenAndOddHeaders do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :evenAndOddHeaders, name: "even_and_odd_headers", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/supress_auto_hyphens_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SupressAutoHyphens do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :supressAutoHyphens, name: "supress_auto_hyphens", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/supress_line_numbers_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SupressLineNumbers do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :supressLineNumbers, name: "supress_line_numbers", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(nil) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/title_page_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::TitlePage do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :titlePg, name: "title_page"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | for_attribute(:value) do
13 | with_value(true) do
14 | it_should_assign_successfully
15 | it_should_output ""
16 | end
17 |
18 | with_value(:somethingElse) do
19 | it_should_raise_an_exception
20 | end
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/table_cell_width_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableCellWidth do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :tcW, name: "table_cell_width"
7 |
8 | for_attribute(:type) do
9 | values = %i(dxa pct)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | it_should_not_allow_integers
13 | end
14 |
15 | for_attribute(:width) do
16 | it_should_assign_and_output_xml 2
17 | it_should_not_allow_invalid_value
18 | it_should_not_allow_floats
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/embed_bold.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EmbedBold < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9 | attribute :subsetted, expects: :boolean
10 | end
11 |
12 | attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/parts/settings_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Parts::Settings do
4 | include PartTestMacros
5 |
6 | context "always" do
7 | before(:each) do
8 | @doc = described_class.new
9 | booklet_printing = OpenXml::Docx::Elements::BookFoldPrinting.new
10 | booklet_printing.value = true
11 | @doc << booklet_printing
12 | booklet_pagecount = OpenXml::Docx::Elements::BookFoldPrintingSheets.new
13 | booklet_pagecount.value = 4
14 | @doc << booklet_pagecount
15 | end
16 |
17 | it_should_output_correct_xml
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/properties/phonetic_guide_font_size_raise_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PhoneticGuideFontSizeRaise do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hpsRaise, name: "font_size_raise", value: 1
7 |
8 | with_value(24) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-24) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(:big) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(23.3) do
22 | it_should_not_work
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/embed_italic.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EmbedItalic < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9 | attribute :subsetted, expects: :boolean
10 | end
11 |
12 | attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingObjectNvProperties < OpenXml::Docx::Element
5 | tag :docPr
6 | namespace :wp
7 |
8 | attribute :description, expects: :string, displays_as: :descr
9 | attribute :hidden, expects: :boolean
10 | attribute :id, expects: :positive_integer
11 | attribute :object_name, expects: :string, displays_as: :name
12 | attribute :title, expects: :string
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/phonetic_guide_base_font_size_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::PhoneticGuideBaseFontSize do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :hpsBaseText, name: "base_font_size", value: 1
7 |
8 | with_value(24) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-24) do
14 | it_should_not_work
15 | end
16 |
17 | with_value(:big) do
18 | it_should_not_work
19 | end
20 |
21 | with_value(23.3) do
22 | it_should_not_work
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/background.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Background < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | with_namespace :w do
8 | attribute :color, expects: :hex_color
9 | attribute :theme_color, one_of: OpenXml::Docx::THEME_COLORS, displays_as: :themeColor
10 | attribute :theme_shade, expects: :hex_digit, displays_as: :themeShade
11 | attribute :theme_tint, expects: :hex_digit, displays_as: :themeTint
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/embed_bold_italic.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class EmbedBoldItalic < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :font_key, displays_as: :fontKey, matches: /\{[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}\}/ # Regex taken from spec section 22.9.2.4
9 | attribute :subsetted, expects: :boolean
10 | end
11 |
12 | attribute :relationship_id, expects: :string, displays_as: :id, namespace: :r
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/east_asian_layout.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class EastAsianLayout < ComplexProperty
5 |
6 | with_namespace :w do
7 | attribute :combine, expects: :on_or_off
8 | attribute :combine_brackets, one_of: %i(angle curly none round square)
9 | attribute :id, expects: :integer
10 | attribute :vertical, expects: :on_or_off, displays_as: :vert
11 | attribute :vertical_compress, expects: :on_or_off, displays_as: :vertCompress
12 | end
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/table_cell_spacing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableCellSpacing do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :tblCellSpacing, name: "table_cell_spacing"
7 |
8 | for_attribute(:type) do
9 | values = %i(dxa pct)
10 | it_should_assign_and_output_xml values
11 | it_should_not_allow_invalid_value
12 | it_should_not_allow_integers
13 | end
14 |
15 | for_attribute(:width) do
16 | it_should_assign_and_output_xml 2
17 | it_should_not_allow_invalid_value
18 | it_should_not_allow_floats
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/grid_after_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::GridAfter do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :gridAfter, name: "grid_after", value: 1
7 |
8 | with_value(400) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-230) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(4.2) do
19 | it_should_not_work
20 | end
21 |
22 | with_value(:twelve) do
23 | it_should_not_work
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/spec/properties/position_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Position do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :position, name: "position", value: 1
7 |
8 | with_value(204) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-612) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(812.2) do
19 | it_should_not_work
20 | end
21 |
22 | with_value(:something_else) do
23 | it_should_not_work
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/spec/elements/text_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Text do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :t, name: "text"
7 |
8 | for_attribute(:space, with_namespace: :xml) do
9 | with_value(nil) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:preserve) do
15 | it_should_assign_successfully
16 | it_should_output ""
17 | end
18 |
19 | with_value(:the_final_frontier) do
20 | it_should_raise_an_exception
21 | end
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/spec/properties/grid_before_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::GridBefore do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :gridBefore, name: "grid_before", value: 1
7 |
8 | with_value(400) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-230) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(4.2) do
19 | it_should_not_work
20 | end
21 |
22 | with_value(:twelve) do
23 | it_should_not_work
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/spec/properties/style_aliases_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::StyleAliases do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :aliases, name: "style_aliases", value: "Default"
7 |
8 | with_value("AltStyleName") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value("AltStyleName1,Alt Style Name 2") do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(5) do
19 | it_should_not_work
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_tight.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapTight < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :wrapTight
8 | namespace :wp
9 |
10 | attribute :distance_from_left, expects: :positive_integer, displays_as: :distL
11 | attribute :distance_from_right, expects: :positive_integer, displays_as: :distR
12 | attribute :wrap_text, one_of: %i(bothSides largest left right), displays_as: :wrapText
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/elements/deleted_text_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::DeletedText do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :del, name: "deleted_text"
7 |
8 | for_attribute(:space) do
9 | with_value(nil) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:preserve) do
15 | it_should_assign_successfully
16 | it_should_output ""
17 | end
18 |
19 | with_value(:the_final_frontier) do
20 | it_should_raise_an_exception
21 | end
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/font_sig.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class FontSig < OpenXml::Docx::Element
5 | namespace :w
6 | tag :sig
7 |
8 | with_namespace :w do
9 | attribute :csb0, expects: :long_hex_number
10 | attribute :csb1, expects: :long_hex_number
11 | attribute :usb0, expects: :long_hex_number
12 | attribute :usb1, expects: :long_hex_number
13 | attribute :usb2, expects: :long_hex_number
14 | attribute :usb3, expects: :long_hex_number
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_through.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapThrough < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :wrapThrough
8 | namespace :wp
9 |
10 | attribute :distance_from_left, expects: :positive_integer, displays_as: :distL
11 | attribute :distance_from_right, expects: :positive_integer, displays_as: :distR
12 | attribute :wrap_text, one_of: %i(bothSides largest left right), displays_as: :wrapText
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/elements/markup_compatibility_choice_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::MarkupCompatibilityChoice do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :Choice, name: "markup_compatibility_choice"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | for_attribute(:requires) do
13 | with_value("wps") do
14 | it_should_assign_successfully
15 | it_should_output ""
16 | end
17 |
18 | with_value(1234) do
19 | it_should_raise_an_exception
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/properties/character_spacing_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::CharacterSpacing do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :spacing, name: "character_spacing", value: 1
7 |
8 | with_value(400) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(-230) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(4.2) do
19 | it_should_not_work
20 | end
21 |
22 | with_value(:twelve) do
23 | it_should_not_work
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/spec/elements/even_and_odd_headers_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::EvenAndOddHeaders do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :evenAndOddHeaders, name: "even_and_odd_headers"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | for_attribute(:value) do
13 | with_value(true) do
14 | it_should_assign_successfully
15 | it_should_output ""
16 | end
17 |
18 | with_value(:somethingElse) do
19 | it_should_raise_an_exception
20 | end
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_shapes_textual_content_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingShapesTextualContent do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :txbx, name: "word_processing_shapes_textual_content"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | for_attribute(:id) do
13 | with_value(1)do
14 | it_should_assign_successfully
15 | it_should_output ""
16 | end
17 |
18 | with_value("invalid") do
19 | it_should_raise_an_exception
20 | end
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/spec/properties/table_layout_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::TableLayout do
4 | include PropertyTestMacros
5 |
6 | it_should_use tag: :tblLayout, name: "table_layout"
7 |
8 | for_attribute(:type) do
9 | with_value(:autofit) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:fixed) do
15 | it_should_assign_successfully
16 | it_should_output ""
17 | end
18 |
19 | with_value(:nope) do
20 | it_should_raise_an_exception
21 | end
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_shapes_nv_drawing_properties.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingShapesNvDrawingProperties < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :cNvPr
8 | namespace :wps
9 |
10 | attribute :description, expects: :string, displays_as: :descr
11 | attribute :hidden, expects: :boolean
12 | attribute :id, expects: :positive_integer
13 | attribute :object_name, expects: :string, displays_as: :name
14 | attribute :title, expects: :string
15 |
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_shapes_shape_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingShapesShape do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :wsp, name: "word_processing_shapes_shape"
7 |
8 | with_no_attributes_set do
9 | it_should_output "", assign: false
10 | end
11 |
12 | for_attribute(:normal_east_asian_flow) do
13 | with_value(true)do
14 | it_should_assign_successfully
15 | it_should_output ""
16 | end
17 |
18 | with_value("invalid") do
19 | it_should_raise_an_exception
20 | end
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/page_margins.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class PageMargins < ComplexProperty
5 | tag :pgMar
6 |
7 | with_namespace :w do
8 | attribute :bottom, expects: :integer
9 | attribute :footer, expects: :positive_integer
10 | attribute :gutter, expects: :positive_integer
11 | attribute :header, expects: :positive_integer
12 | attribute :left, expects: :positive_integer
13 | attribute :right, expects: :positive_integer
14 | attribute :top, expects: :integer
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/footer_reference.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class FooterReference < ComplexProperty
5 | namespace :w
6 |
7 | attribute :id, expects: :string, namespace: :r
8 | attribute :type, expects: :valid_footer_type, namespace: :w
9 |
10 | private
11 |
12 | def valid_footer_type(value)
13 | ok_values = %i(default even first)
14 | message = "Invalid footer type (#{value}). Allowed types are: #{ok_values.join(", ")}."
15 | raise ArgumentError, message unless ok_values.include? value
16 | end
17 |
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/header_reference.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class HeaderReference < ComplexProperty
5 | namespace :w
6 |
7 | attribute :id, expects: :string, namespace: :r
8 | attribute :type, expects: :valid_header_type, namespace: :w
9 |
10 | private
11 |
12 | def valid_header_type(value)
13 | ok_values = %i(default even first)
14 | message = "Invalid header type (#{value}). Allowed types are: #{ok_values.join(", ")}."
15 | raise ArgumentError, message unless ok_values.include? value
16 | end
17 |
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/support/data/parts/content_types_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/table_look.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class TableLook < ComplexProperty
5 | tag :tblLook
6 |
7 | with_namespace :w do
8 | attribute :firstColumn, expects: :boolean
9 | attribute :firstRow, expects: :boolean
10 | attribute :lastColumn, expects: :boolean
11 | attribute :lastRow, expects: :boolean
12 | attribute :noHBand, expects: :boolean
13 | attribute :noVBand, expects: :boolean
14 | attribute :value, expects: :hex_digit_4, displays_as: :val, deprecated: true
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_drawing_wrap_polygon_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingDrawingWrapPolygon do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :wrapPolygon, name: "word_processing_drawing_wrap_polygon"
7 |
8 | for_attribute(:edited) do
9 | with_value(true) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(:no_good) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | with_no_attributes_set do
20 | it_should_output "", assign: false
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_coordinate.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapCoordinate < OpenXml::Docx::Element
5 | namespace :wp
6 |
7 | attr_reader :tag
8 |
9 | attribute :x, expects: :integer
10 | attribute :y, expects: :integer
11 |
12 | def initialize(tag)
13 | raise ArgumentError, "Tag must be one of #{ok_tags.join(", ")}" unless ok_tags.include? tag
14 | @tag = tag
15 | end
16 |
17 | private
18 |
19 | def ok_tags
20 | %i(start lineTo)
21 | end
22 |
23 | end
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/language.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Language < ComplexProperty
5 | tag :lang
6 |
7 | with_namespace :w do
8 | attribute :bidi, expects: :valid_language
9 | attribute :east_asia, expects: :valid_language
10 | attribute :latin, expects: :valid_language, displays_as: :val
11 | end
12 |
13 | private
14 |
15 | def valid_language(value)
16 | message = "Invalid #{name}: must be a language code (RFC 4646)"
17 | raise ArgumentError, message unless value =~ /[a-z]{2}-[A-Z]{2}/
18 | end
19 |
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_inline.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingInline < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 |
7 | tag :inline
8 | namespace :wp
9 |
10 | attribute :distance_from_bottom, expects: :positive_integer, displays_as: :distB
11 | attribute :distance_from_left, expects: :positive_integer, displays_as: :distL
12 | attribute :distance_from_right, expects: :positive_integer, displays_as: :distR
13 | attribute :distance_from_top, expects: :positive_integer, displays_as: :distT
14 |
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/parts/styles_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Parts::Styles do
4 | include PartTestMacros
5 |
6 | context "when adding no additional styles" do
7 | before(:each) do
8 | @doc = described_class.new
9 | end
10 |
11 | it_should_output_correct_xml
12 | end
13 |
14 | context "after adding additional styles" do
15 | before(:each) do
16 | @doc = described_class.new
17 |
18 | style = OpenXml::Docx::Style.new(:paragraph)
19 | style.id = "coolStyle"
20 | style.paragraph.alignment = :start
21 |
22 | doc << style
23 | end
24 |
25 | it_should_output_correct_xml part: "styles_with_custom_style"
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/numbering.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Numbering < ComplexProperty
5 | tag :numPr
6 |
7 | with_namespace :w do
8 | attribute :level, expects: :positive_integer, displays_as: :ilvl
9 | attribute :id, expects: :positive_integer, displays_as: :numId
10 | end
11 |
12 | def to_xml(xml)
13 | return unless render?
14 | xml["w"].public_send(tag) {
15 | xml_attributes.each do |tag_name, value|
16 | xml.public_send(tag_name, "w:val" => value)
17 | end
18 | }
19 | end
20 |
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_position_offset.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingPositionOffset < OpenXml::Docx::Element
5 | tag :posOffset
6 | namespace :wp
7 |
8 | def <<(text)
9 | value << text if text.is_a? String
10 | end
11 |
12 | def value
13 | @value ||= ""
14 | end
15 |
16 | def value=(new_value)
17 | @value = new_value if new_value.is_a? String
18 | end
19 |
20 | def to_xml(xml)
21 | xml[namespace.to_s].public_send(tag, value, xml_attributes)
22 | end
23 |
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/examples/base:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # require "rails" # workaround: openxml-package uses `extract_options!`
4 | $:.push Dir.pwd + "/lib"
5 | require "openxml/docx"
6 |
7 | document = OpenXml::Docx::Package.new
8 |
9 | include OpenXml::Docx::Elements
10 |
11 | text = Text.new("Some text that I want to include in my new OOXML document")
12 |
13 | run = Run.new
14 | run << text
15 | paragraph = Paragraph.new
16 | paragraph << run
17 |
18 | document.document << paragraph
19 |
20 | filename = "rocx_test_base.docx"
21 | system "rm -f ~/Desktop/#{filename}" # -f so that we don't have an error if the file doesn't exist
22 | document.save File.expand_path("~/Desktop/#{filename}")
23 | exec "open ~/Desktop/#{filename}"
24 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/family.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class Family < OpenXml::Docx::Element
5 | namespace :w
6 |
7 | with_namespace :w do
8 | attribute :value, expects: :valid_font_family, displays_as: :val
9 | end
10 |
11 | private
12 |
13 | def valid_font_family(value)
14 | ok_values = %i(auto decorative modern roman script swiss) # From the spec section 17.18.30
15 | message = "Invalid font family type (#{value}). Valid options are: #{ok_values.join(", ")}."
16 | raise ArgumentError, message unless ok_values.include? value
17 | end
18 |
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_drawing_position_v_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingDrawingPositionV do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :positionV, name: "word_processing_drawing_position_v"
7 |
8 | for_attribute(:relative_from) do
9 | %i(bottomMargin insideMargin line margin outsideMargin page paragraph topMargin).each do |good_value|
10 | with_value(good_value) do
11 | it_should_assign_successfully
12 | it_should_output ""
13 | end
14 | end
15 |
16 | with_value(:notRight) do
17 | it_should_raise_an_exception
18 | end
19 | end
20 |
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/support/part_test_macros.rb:
--------------------------------------------------------------------------------
1 | module PartTestMacros
2 |
3 | def xml(part)
4 | File.read(File.join(File.dirname(__FILE__), "data", "parts", "#{part}_part.xml")).lines.map(&:strip).join
5 | end
6 |
7 | def self.included(base)
8 | attr_reader :doc
9 | base.extend ClassMethods
10 | end
11 |
12 | module ClassMethods
13 |
14 | def it_should_output_correct_xml(part: nil)
15 | it "should be able to output the correct XML" do
16 | if part.nil?
17 | part = described_class.to_s.split(/::/).last
18 | part = part.gsub(/(.)([A-Z])/, '\1_\2').downcase
19 | end
20 |
21 | expect(doc.read).to eq(xml(part))
22 | end
23 | end
24 |
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/spec/elements/book_fold_printing_sheets_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::BookFoldPrintingSheets do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :bookFoldPrintingSheets, name: "book_fold_printing_sheets"
7 |
8 | for_attribute(:value) do
9 | with_value(1) do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(-1) do
15 | it_should_raise_an_exception
16 | end
17 |
18 | with_value(1.1) do
19 | it_should_raise_an_exception
20 | end
21 |
22 | with_value(:not_a_number) do
23 | it_should_raise_an_exception
24 | end
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_drawing_position_h_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingDrawingPositionH do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :positionH, name: "word_processing_drawing_position_h"
7 |
8 | for_attribute(:relative_from) do
9 | %i(character column insideMargin leftMargin margin outsideMargin page rightMargin).each do |good_value|
10 | with_value(good_value) do
11 | it_should_assign_successfully
12 | it_should_output ""
13 | end
14 | end
15 |
16 | with_value(:notRight) do
17 | it_should_raise_an_exception
18 | end
19 | end
20 |
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_shapes_shape_properties_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingShapesShapeProperties do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :spPr, name: "word_processing_shapes_shape_properties"
7 |
8 | for_attribute(:bw_mode) do
9 | %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white).each do |allowed_value|
10 | with_value(allowed_value) do
11 | it_should_assign_successfully
12 | it_should_output ""
13 | end
14 | end
15 |
16 | with_value(:notRight) do
17 | it_should_raise_an_exception
18 | end
19 | end
20 |
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/lib/openxml/docx/parts/settings.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Parts
4 | class Settings < OpenXml::Part
5 | include RootNamespaces
6 |
7 | use_namespace :w
8 |
9 | attr_reader :settings
10 |
11 | def initialize
12 | @settings = []
13 | end
14 |
15 | def <<(child)
16 | settings << child
17 | end
18 |
19 | def to_xml
20 | build_standalone_xml do |xml|
21 | xml.settings(root_namespaces) {
22 | xml.parent.namespace = :w
23 | settings.each { |setting| setting.to_xml(xml) }
24 | }
25 | end
26 | end
27 |
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/spec/elements/word_processing_groups_group_shape_properties_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::WordProcessingGroupsGroupShapeProperties do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :grpSpPr, name: "word_processing_groups_group_shape_properties"
7 |
8 | for_attribute(:bw_mode) do
9 | %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white).each do |good_value|
10 | with_value(good_value) do
11 | it_should_assign_successfully
12 | it_should_output ""
13 | end
14 | end
15 |
16 | with_value(:no_good) do
17 | it_should_raise_an_exception
18 | end
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/properties/expansion_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Expansion do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :w, name: "expansion", value: "100%"
7 |
8 | with_value("1%") do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(1) do
14 | it_should_not_work
15 | end
16 |
17 | with_value("0%") do
18 | it_should_not_work
19 | end
20 |
21 | with_value(600) do
22 | it_should_not_work
23 | end
24 |
25 | with_value("600%") do
26 | it_should_work
27 | it_should_output ""
28 | end
29 |
30 | with_value("601%") do
31 | it_should_not_work
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/spec/properties/vertical_alignment_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::VerticalAlignment do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :vertAlign, name: "vertical_alignment", value: :baseline
7 |
8 | with_value(:baseline) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:subscript) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:superscript) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | with_value(:megascript) do
24 | it_should_not_work
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/spec/elements/symbol_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Elements::Symbol do
4 | include ElementTestMacros
5 |
6 | it_should_use tag: :sym, name: "symbol"
7 |
8 | for_attribute(:font) do
9 | with_value("Wingdings") do
10 | it_should_assign_successfully
11 | it_should_output ""
12 | end
13 |
14 | with_value(123) do
15 | it_should_raise_an_exception
16 | end
17 | end
18 |
19 | for_attribute(:character) do
20 | with_value("43FD") do
21 | it_should_assign_successfully
22 | it_should_output ""
23 | end
24 |
25 | with_value("43gg") do
26 | it_should_raise_an_exception
27 | end
28 |
29 | end
30 |
31 | end
32 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/word_processing_drawing_wrap_square.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class WordProcessingDrawingWrapSquare < OpenXml::Docx::Element
5 | tag :wrapSquare
6 | namespace :wp
7 |
8 | attribute :distance_from_bottom, expects: :positive_integer, displays_as: :distB
9 | attribute :distance_from_left, expects: :positive_integer, displays_as: :distL
10 | attribute :distance_from_right, expects: :positive_integer, displays_as: :distR
11 | attribute :distance_from_top, expects: :positive_integer, displays_as: :distT
12 | attribute :wrap_text, one_of: %i(bothSides largest left right), displays_as: :wrapText
13 |
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/properties/kinsoku_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::Kinsoku do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :kinsoku, name: "kinsoku", value: true
7 |
8 | with_value(true) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(false) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:on) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | with_value(:off) do
24 | it_should_work
25 | it_should_output ""
26 | end
27 |
28 | with_value(nil) do
29 | it_should_not_work
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/spec/properties/vertical_text_alignment_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::VerticalTextAlignment do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :vAlign, name: "vertical_text_alignment", value: :both
7 |
8 | with_value(:both) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:bottom) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(:center) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | with_value(:top) do
24 | it_should_work
25 | it_should_output ""
26 | end
27 |
28 | end
29 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/spacing.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Properties
4 | class Spacing < ComplexProperty
5 |
6 | with_namespace :w do
7 | attribute :after, expects: :positive_integer
8 | attribute :after_auto, expects: :on_or_off, displays_as: :afterAutospacing
9 | attribute :after_lines, expects: :integer
10 | attribute :before, expects: :positive_integer
11 | attribute :before_auto, expects: :on_or_off, displays_as: :beforeAutospacing
12 | attribute :before_lines, expects: :integer
13 | attribute :line, expects: :integer
14 | attribute :line_rule, one_of: %i(atLeast auto exact)
15 | end
16 |
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/elements/level_override.rb:
--------------------------------------------------------------------------------
1 | module OpenXml
2 | module Docx
3 | module Elements
4 | class LevelOverride < OpenXml::Docx::Element
5 | include HasChildren, HasProperties
6 | tag :lvlOverride
7 |
8 | with_namespace :w do
9 | attribute :level, expects: :integer, displays_as: :ilvl # required
10 | end
11 |
12 | value_property :start_override
13 |
14 | def override
15 | @override ||= Level.new
16 | end
17 |
18 | def to_xml(xml)
19 | xml["w"].public_send(tag, xml_attributes) {
20 | start_override.to_xml(xml)
21 | @override.to_xml(xml) unless @override.nil?
22 | }
23 | end
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/spec/properties/word_wrap_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::WordWrap do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :wordWrap, name: "word_wrap", value: true
7 |
8 | with_value(:on) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:off) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(true) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | with_value(false) do
24 | it_should_work
25 | it_should_output ""
26 | end
27 |
28 |
29 | with_value(nil) do
30 | it_should_not_work
31 | end
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/spec/support/data/parts/styles_with_custom_style_part.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lib/openxml/docx/properties/columns.rb:
--------------------------------------------------------------------------------
1 | require "openxml/docx/properties/column"
2 |
3 | module OpenXml
4 | module Docx
5 | module Properties
6 | class Columns < ContainerProperty
7 | tag :cols
8 | child_class :column
9 |
10 | with_namespace :w do
11 | attribute :equal_width, expects: :boolean
12 | attribute :number, expects: :integer, displays_as: :num
13 | attribute :separator, expects: :boolean, displays_as: :sep
14 | attribute :space, expects: :integer
15 | end
16 |
17 | def render?
18 | return true if %i(equal_width number separator space).any? { |attribute| !public_send(attribute).nil? }
19 | super
20 | end
21 |
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/properties/snap_to_grid_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe OpenXml::Docx::Properties::SnapToGrid do
4 | include ValuePropertyTestMacros
5 |
6 | it_should_use tag: :snapToGrid, name: "snap_to_grid", value: true
7 |
8 | with_value(:on) do
9 | it_should_work
10 | it_should_output ""
11 | end
12 |
13 | with_value(:off) do
14 | it_should_work
15 | it_should_output ""
16 | end
17 |
18 | with_value(true) do
19 | it_should_work
20 | it_should_output ""
21 | end
22 |
23 | with_value(false) do
24 | it_should_work
25 | it_should_output ""
26 | end
27 |
28 | with_value(nil) do
29 | it_should_not_work
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------