openxml-docx 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/Gemfile.lock +1 -1
  2. data/examples/booklet-printing +55 -0
  3. data/lib/openxml/docx/attribute_builder.rb +11 -5
  4. data/lib/openxml/docx/elements/absolute_position_tab.rb +1 -1
  5. data/lib/openxml/docx/elements/background.rb +16 -0
  6. data/lib/openxml/docx/elements/book_fold_printing.rb +1 -1
  7. data/lib/openxml/docx/elements/book_fold_reverse_printing.rb +1 -1
  8. data/lib/openxml/docx/elements/compatibility_setting.rb +10 -0
  9. data/lib/openxml/docx/elements/compatibility_settings.rb +15 -0
  10. data/lib/openxml/docx/elements/embed_bold.rb +2 -10
  11. data/lib/openxml/docx/elements/embed_bold_italic.rb +2 -10
  12. data/lib/openxml/docx/elements/embed_italic.rb +2 -10
  13. data/lib/openxml/docx/elements/embed_regular.rb +3 -3
  14. data/lib/openxml/docx/elements/embed_system_fonts.rb +1 -1
  15. data/lib/openxml/docx/elements/embed_true_type_fonts.rb +1 -1
  16. data/lib/openxml/docx/elements/even_and_odd_headers.rb +11 -0
  17. data/lib/openxml/docx/elements/family.rb +1 -1
  18. data/lib/openxml/docx/elements/markup_compatibility_choice.rb +1 -1
  19. data/lib/openxml/docx/elements/paragraph.rb +1 -0
  20. data/lib/openxml/docx/elements/save_subset_fonts.rb +1 -1
  21. data/lib/openxml/docx/elements/table_cell.rb +1 -0
  22. data/lib/openxml/docx/elements/textbox_content.rb +9 -0
  23. data/lib/openxml/docx/elements/word_processing_drawing_anchor.rb +6 -6
  24. data/lib/openxml/docx/elements/word_processing_drawing_inline.rb +16 -0
  25. data/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb +1 -1
  26. data/lib/openxml/docx/elements/word_processing_drawing_wrap_polygon.rb +1 -1
  27. data/lib/openxml/docx/elements/word_processing_shapes_body_properties.rb +12 -12
  28. data/lib/openxml/docx/elements/word_processing_shapes_nv_drawing_properties.rb +1 -1
  29. data/lib/openxml/docx/elements/word_processing_shapes_shape.rb +1 -2
  30. data/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb +1 -11
  31. data/lib/openxml/docx/elements/word_processing_shapes_textual_contents.rb +13 -0
  32. data/lib/openxml/{drawingml → docx}/elements/wordprocessing_shape_group.rb +1 -1
  33. data/lib/openxml/docx/package.rb +4 -3
  34. data/lib/openxml/docx/parts/document.rb +5 -0
  35. data/lib/openxml/docx/parts/header.rb +1 -1
  36. data/lib/openxml/docx/properties.rb +1 -0
  37. data/lib/openxml/docx/properties/border.rb +2 -2
  38. data/lib/openxml/docx/properties/columns.rb +8 -2
  39. data/lib/openxml/docx/properties/conditional_formatting.rb +12 -12
  40. data/lib/openxml/docx/properties/container_property.rb +10 -10
  41. data/lib/openxml/docx/properties/footer_references.rb +12 -0
  42. data/lib/openxml/docx/properties/frame.rb +1 -1
  43. data/lib/openxml/docx/properties/header_references.rb +12 -0
  44. data/lib/openxml/docx/properties/indentation.rb +5 -1
  45. data/lib/openxml/docx/properties/latent_styles.rb +4 -4
  46. data/lib/openxml/docx/properties/latent_styles_exception.rb +4 -4
  47. data/lib/openxml/docx/properties/section.rb +15 -0
  48. data/lib/openxml/docx/properties/table_border.rb +2 -2
  49. data/lib/openxml/docx/properties/table_cell_border.rb +2 -2
  50. data/lib/openxml/docx/properties/table_look.rb +7 -6
  51. data/lib/openxml/docx/properties/text_direction.rb +1 -1
  52. data/lib/openxml/docx/properties/transparent_container_property.rb +14 -0
  53. data/lib/openxml/docx/properties/vertical_merge.rb +14 -0
  54. data/lib/openxml/docx/section.rb +2 -0
  55. data/lib/openxml/docx/style.rb +18 -6
  56. data/lib/openxml/docx/version.rb +1 -1
  57. data/lib/openxml/drawingml/elements/blip_fill.rb +1 -1
  58. data/lib/openxml/drawingml/elements/children_extents.rb +14 -0
  59. data/lib/openxml/drawingml/elements/children_offset.rb +14 -0
  60. data/lib/openxml/drawingml/elements/graphic_frame_locks.rb +6 -6
  61. data/lib/openxml/drawingml/elements/no_autofit.rb +10 -0
  62. data/lib/openxml/drawingml/elements/no_fill.rb +1 -1
  63. data/lib/openxml/drawingml/elements/non_visual_drawing_properties.rb +1 -1
  64. data/lib/openxml/drawingml/elements/non_visual_picture_drawing_properties.rb +1 -1
  65. data/lib/openxml/drawingml/elements/non_visual_shape_drawing_properties.rb +12 -0
  66. data/lib/openxml/drawingml/elements/picture_locks.rb +11 -11
  67. data/lib/openxml/drawingml/elements/preset_text_warp.rb +25 -0
  68. data/lib/openxml/vml/elements/group.rb +17 -37
  69. data/lib/openxml/vml/elements/rectangle.rb +29 -62
  70. data/lib/openxml/vml/elements/rounded_rectangle.rb +29 -61
  71. data/spec/elements/absolute_position_tab_spec.rb +21 -15
  72. data/spec/elements/background_spec.rb +52 -0
  73. data/spec/elements/bidi_embed_spec.rb +12 -4
  74. data/spec/elements/bidi_override_spec.rb +12 -4
  75. data/spec/elements/break_spec.rb +12 -10
  76. data/spec/elements/compatibility_setting_spec.rb +41 -0
  77. data/spec/elements/compatibility_settings_spec.rb +8 -0
  78. data/spec/elements/content_part_spec.rb +2 -2
  79. data/spec/elements/control_spec.rb +5 -5
  80. data/spec/elements/deleted_text_spec.rb +2 -2
  81. data/spec/elements/drawingml/blip_fill_spec.rb +8 -3
  82. data/spec/elements/drawingml/extents_spec.rb +4 -4
  83. data/spec/elements/drawingml/head_end_spec.rb +16 -13
  84. data/spec/elements/drawingml/no_autofit_spec.rb +8 -0
  85. data/spec/elements/drawingml/non_visual_drawing_properties_spec.rb +6 -6
  86. data/spec/elements/drawingml/non_visual_shape_drawing_properties_spec.rb +24 -0
  87. data/spec/elements/drawingml/offset_spec.rb +14 -4
  88. data/spec/elements/drawingml/outline_spec.rb +20 -14
  89. data/spec/elements/drawingml/preset_geometry_spec.rb +1 -1
  90. data/spec/elements/drawingml/preset_text_warp_spec.rb +36 -0
  91. data/spec/elements/drawingml/shape_guide_spec.rb +7 -3
  92. data/spec/elements/drawingml/srgb_color_spec.rb +3 -4
  93. data/spec/elements/drawingml/tail_end_spec.rb +17 -14
  94. data/spec/elements/drawingml/transform_effect_spec.rb +48 -26
  95. data/spec/elements/markup_compatibility_choice_spec.rb +2 -2
  96. data/spec/elements/paragraph_spec.rb +25 -0
  97. data/spec/elements/symbol_spec.rb +4 -4
  98. data/spec/elements/text_spec.rb +1 -1
  99. data/spec/elements/textbox_content_spec.rb +8 -0
  100. data/spec/elements/vml/group_spec.rb +367 -375
  101. data/spec/elements/vml/rectangle_spec.rb +503 -513
  102. data/spec/elements/vml/rounded_rectangle_spec.rb +591 -463
  103. data/spec/elements/word_processing_drawing_effect_extent_spec.rb +32 -12
  104. data/spec/elements/word_processing_drawing_extent_spec.rb +4 -4
  105. data/spec/elements/word_processing_drawing_object_nv_properties_spec.rb +6 -6
  106. data/spec/elements/word_processing_drawing_simple_position_spec.rb +16 -6
  107. data/spec/elements/word_processing_shapes_body_properties_spec.rb +53 -44
  108. data/spec/elements/word_processing_shapes_shape_properties_spec.rb +6 -5
  109. data/spec/elements/word_processing_shapes_shape_spec.rb +2 -2
  110. data/spec/elements/word_processing_shapes_textual_content_spec.rb +23 -0
  111. data/spec/elements/{drawingml/wordprocessing_shape_group_spec.rb → wordprocessing_shape_group_spec.rb} +1 -1
  112. data/spec/properties/indentation_spec.rb +28 -0
  113. data/spec/properties/table_look_spec.rb +5 -0
  114. data/spec/properties/text_direction_spec.rb +5 -0
  115. data/spec/properties/vertical_merge_spec.rb +22 -0
  116. data/spec/support/data/elements/paragraph_with_section_properties_element.xml +12 -0
  117. data/spec/support/data/parts/empty_header_part.xml +1 -1
  118. data/spec/support/data/parts/header_with_children_part.xml +1 -1
  119. metadata +76 -27
  120. checksums.yaml +0 -7
@@ -6,7 +6,7 @@ module OpenXml
6
6
  namespace :wps
7
7
 
8
8
  attribute :description, expects: :string, displays_as: :descr
9
- attribute :hidden, expects: :true_or_false
9
+ attribute :hidden, expects: :boolean
10
10
  attribute :id, expects: :positive_integer
11
11
  attribute :object_name, expects: :string, displays_as: :name
12
12
  attribute :title, expects: :string
@@ -4,8 +4,7 @@ module OpenXml
4
4
  class WordProcessingShapesShape < Container
5
5
  tag :wsp
6
6
  namespace :wps
7
-
8
- attribute :normalEastAsianFlow, expects: :true_or_false
7
+ attribute :normal_east_asian_flow, expects: :boolean, displays_as: :normalEastAsianFlow
9
8
  end
10
9
  end
11
10
  end
@@ -5,17 +5,7 @@ module OpenXml
5
5
  tag :spPr
6
6
  namespace :wps
7
7
 
8
- attribute :bwMode, expects: :valid_colors
9
-
10
- private
11
-
12
- def valid_colors(value)
13
- raise ArgumentError unless ok_values.include? value
14
- end
15
-
16
- def ok_values
17
- %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white)
18
- end
8
+ attribute :bw_mode, displays_as: :bwMode, one_of: %i(auto black blackGray blackWhite clr gray grayWhite hidden invGray ltGray white)
19
9
 
20
10
  end
21
11
  end
@@ -0,0 +1,13 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class WordProcessingShapesTextualContent < Container
5
+ tag :txbx
6
+ namespace :wps
7
+
8
+ attribute :id, expects: :positive_integer
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module OpenXml
2
- module DrawingML
2
+ module Docx
3
3
  module Elements
4
4
  class WordprocessingShapeGroup < OpenXml::Docx::Elements::Container
5
5
  tag :wgp
@@ -1,4 +1,5 @@
1
1
  require "openxml/package"
2
+ require "open-uri"
2
3
 
3
4
  module OpenXml
4
5
  module Docx
@@ -49,7 +50,7 @@ module OpenXml
49
50
  end
50
51
 
51
52
  def embed_truetype_font(path: nil, name: nil)
52
- File.open(path, "rb") do |source_font|
53
+ open(path, "rb") do |source_font|
53
54
  obfuscation_data = obfuscate_font source_font
54
55
  data = obfuscation_data[:bytes] << source_font.read
55
56
  destination_font_name = "font#{fonts.fonts.count + 1}.odttf"
@@ -70,14 +71,14 @@ module OpenXml
70
71
  return if path.nil?
71
72
  into_part = document unless into_part.respond_to?(:relationships)
72
73
 
73
- extension_match = path.match(/\.(?<extension>[^\.]+)$/)
74
+ extension_match = path.match(/\.(?<extension>[^\.]+?)(?:\?.+)?$/)
74
75
  content_type ||= extension_match[:extension] if extension_match
75
76
  return if content_type.nil?
76
77
 
77
78
  content_type = "jpeg" if content_type == "jpg"
78
79
  content_type = content_type.to_sym
79
80
 
80
- File.open(path, "rb") do |source_image|
81
+ open(path, "rb") do |source_image|
81
82
  destination_image_name = "image#{image_names.count + 1}.#{content_type}"
82
83
  add_part "word/media/#{destination_image_name}", OpenXml::Parts::UnparsedPart.new(source_image.read)
83
84
  image_names << destination_image_name
@@ -31,10 +31,15 @@ module OpenXml
31
31
  end
32
32
  end
33
33
 
34
+ def background
35
+ @background ||= OpenXml::Docx::Elements::Background.new
36
+ end
37
+
34
38
  def to_xml
35
39
  build_xml do |xml|
36
40
  xml.document(root_namespaces) {
37
41
  xml.parent.namespace = :w
42
+ background.to_xml(xml) unless @background.nil?
38
43
  xml["w"].body {
39
44
  children.each { |child| child.to_xml(xml) }
40
45
  current_section.to_xml(xml) unless current_section.nil?
@@ -4,7 +4,7 @@ module OpenXml
4
4
  class Header < OpenXml::Part
5
5
  include RootNamespaces
6
6
 
7
- use_namespaces :wpc, :mo, :mv, :o, :r, :m, :v, :wp14, :wp, :w10, :w14, :w15, :wpg, :wpi, :wne, :wps, :w, :mc, :a, :a14
7
+ use_namespaces :wpc, :mo, :mv, :o, :r, :m, :v, :wp14, :wp, :w10, :w14, :w15, :wpg, :wpi, :wne, :wps, :w, :mc, :a, :a14, :pic
8
8
  can_ignore :w14, :w15, :wp14, :a14
9
9
 
10
10
  attr_reader :children, :relationships
@@ -16,6 +16,7 @@ require "openxml/docx/properties/on_off_property"
16
16
  require "openxml/docx/properties/toggle_property"
17
17
  require "openxml/docx/properties/string_property"
18
18
  require "openxml/docx/properties/container_property"
19
+ require "openxml/docx/properties/transparent_container_property"
19
20
  require "openxml/docx/properties/style"
20
21
  Dir.glob("#{File.join(File.dirname(__FILE__), "properties", "*.rb")}").each do |file|
21
22
  require file
@@ -6,8 +6,8 @@ module OpenXml
6
6
 
7
7
  with_namespace :w do
8
8
  attribute :color, expects: :hex_color
9
- attribute :frame, expects: :true_or_false
10
- attribute :shadow, expects: :true_or_false
9
+ attribute :frame, expects: :boolean
10
+ attribute :shadow, expects: :boolean
11
11
  attribute :size, expects: :positive_integer, displays_as: :sz
12
12
  attribute :space, expects: :positive_integer
13
13
  attribute :theme_color, expects: :valid_theme_color
@@ -8,11 +8,17 @@ module OpenXml
8
8
  child_class :column
9
9
 
10
10
  with_namespace :w do
11
- attribute :equal_width, expects: :true_or_false
11
+ attribute :equal_width, expects: :boolean
12
12
  attribute :number, expects: :integer, displays_as: :num
13
- attribute :separator, expects: :true_or_false, displays_as: :sep
13
+ attribute :separator, expects: :boolean, displays_as: :sep
14
14
  attribute :space, expects: :integer
15
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
+
16
22
  end
17
23
  end
18
24
  end
@@ -5,18 +5,18 @@ module OpenXml
5
5
  tag :cnfStyle
6
6
 
7
7
  with_namespace :w do
8
- attribute :even_horizontal_band, expects: :true_or_false, displays_as: :evenHBand
9
- attribute :even_vertical_band, expects: :true_or_false, displays_as: :evenVBand
10
- attribute :first_column, expects: :true_or_false
11
- attribute :first_row, expects: :true_or_false
12
- attribute :first_row_first_column, expects: :true_or_false
13
- attribute :first_row_last_column, expects: :true_or_false
14
- attribute :last_column, expects: :true_or_false
15
- attribute :last_row, expects: :true_or_false
16
- attribute :last_row_first_column, expects: :true_or_false
17
- attribute :last_row_last_column, expects: :true_or_false
18
- attribute :odd_horizontal_band, expects: :true_or_false, displays_as: :oddHBand
19
- attribute :odd_vertical_band, expects: :true_or_false, displays_as: :oddVBand
8
+ attribute :even_horizontal_band, expects: :boolean, displays_as: :evenHBand
9
+ attribute :even_vertical_band, expects: :boolean, displays_as: :evenVBand
10
+ attribute :first_column, expects: :boolean
11
+ attribute :first_row, expects: :boolean
12
+ attribute :first_row_first_column, expects: :boolean
13
+ attribute :first_row_last_column, expects: :boolean
14
+ attribute :last_column, expects: :boolean
15
+ attribute :last_row, expects: :boolean
16
+ attribute :last_row_first_column, expects: :boolean
17
+ attribute :last_row_last_column, expects: :boolean
18
+ attribute :odd_horizontal_band, expects: :boolean, displays_as: :oddHBand
19
+ attribute :odd_vertical_band, expects: :boolean, displays_as: :oddVBand
20
20
  end
21
21
 
22
22
  end
@@ -7,14 +7,14 @@ module OpenXml
7
7
 
8
8
  class << self
9
9
  def child_class(*args)
10
- if args.any?
11
- prop_name = args.first.to_s.split(/_/).map(&:capitalize).join # LazyCamelCase
12
- child_class_obj = OpenXml::Docx::Properties.const_get prop_name
13
- @child_class = OpenXml::Docx::Properties.const_get prop_name
14
- end
10
+ @child_classes = args.map do |arg|
11
+ prop_name = arg.to_s.split(/_/).map(&:capitalize).join # LazyCamelCase
12
+ OpenXml::Docx::Properties.const_get prop_name
13
+ end unless args.empty?
15
14
 
16
- @child_class
15
+ @child_classes
17
16
  end
17
+ alias :child_classes :child_class
18
18
  end
19
19
 
20
20
  def initialize
@@ -48,15 +48,15 @@ module OpenXml
48
48
 
49
49
  def invalid_child_message
50
50
  class_name = self.class.to_s.split(/::/).last
51
- "#{class_name} must be instances of OpenXml::Docx::Properties::#{child_class}"
51
+ "#{class_name} must be instances of one of the following: #{child_classes}"
52
52
  end
53
53
 
54
54
  def valid_child?(child)
55
- child.is_a?(child_class)
55
+ child_classes.any? {|child_class| child.is_a?(child_class) }
56
56
  end
57
57
 
58
- def child_class
59
- self.class.child_class
58
+ def child_classes
59
+ self.class.child_classes
60
60
  end
61
61
 
62
62
  end
@@ -0,0 +1,12 @@
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
@@ -5,7 +5,7 @@ module OpenXml
5
5
  tag :framePr
6
6
 
7
7
  with_namespace :w do
8
- attribute :anchor_lock, expects: :true_or_false
8
+ attribute :anchor_lock, expects: :boolean
9
9
  attribute :drop_cap, one_of: %i(drop margin none)
10
10
  attribute :height, expects: :positive_integer, displays_as: :h
11
11
  attribute :height_rule, one_of: %i(atLeast auto exact), displays_as: :hRule
@@ -0,0 +1,12 @@
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
@@ -9,8 +9,12 @@ module OpenXml
9
9
  attribute :end_characters, expects: :integer, displays_as: :endChars
10
10
  attribute :hanging, expects: :integer
11
11
  attribute :hanging_characters, expects: :integer, displays_as: :hangingChars
12
- attribute :first_line, expects: :integer
12
+ attribute :first_line, expects: :integer, displays_as: :firstLine
13
13
  attribute :first_line_characters, expects: :integer, displays_as: :firstLineChars
14
+ attribute :left, expects: :integer, deprecated: true
15
+ attribute :left_characters, expects: :integer, displays_as: :leftChars, deprecated: true
16
+ attribute :right, expects: :integer, deprecated: true
17
+ attribute :right_characters, expects: :integer, displays_as: :rightChars, deprecated: true
14
18
  attribute :start, expects: :integer
15
19
  attribute :start_characters, expects: :integer, displays_as: :startChars
16
20
  end
@@ -8,11 +8,11 @@ module OpenXml
8
8
 
9
9
  with_namespace :w do
10
10
  attribute :count, expects: :positive_integer
11
- attribute :default_locked_state, expects: :true_or_false, displays_as: :defLockedState
12
- attribute :default_qformat, expects: :true_or_false, displays_as: :defQFormat
13
- attribute :default_semi_hidden, expects: :true_or_false, displays_as: :defSemiHidden
11
+ attribute :default_locked_state, expects: :boolean, displays_as: :defLockedState
12
+ attribute :default_qformat, expects: :boolean, displays_as: :defQFormat
13
+ attribute :default_semi_hidden, expects: :boolean, displays_as: :defSemiHidden
14
14
  attribute :default_ui_priority, expects: :integer, displays_as: :defUIPriority
15
- attribute :default_unhide_when_used, expects: :true_or_false, displays_as: :defUnhideWhenUsed
15
+ attribute :default_unhide_when_used, expects: :boolean, displays_as: :defUnhideWhenUsed
16
16
  end
17
17
 
18
18
 
@@ -5,12 +5,12 @@ module OpenXml
5
5
  tag :lsdException
6
6
 
7
7
  with_namespace :w do
8
- attribute :locked, expects: :true_or_false
8
+ attribute :locked, expects: :boolean
9
9
  attribute :style_name, expects: :string, displays_as: :name
10
- attribute :qFormat, expects: :true_or_false
11
- attribute :semi_hidden, expects: :true_or_false, displays_as: :semiHidden
10
+ attribute :qFormat, expects: :boolean
11
+ attribute :semi_hidden, expects: :boolean, displays_as: :semiHidden
12
12
  attribute :ui_priority, expects: :integer, displays_as: :uiPriority
13
- attribute :unhide_when_used, expects: :true_or_false, displays_as: :unhideWhenUsed
13
+ attribute :unhide_when_used, expects: :boolean, displays_as: :unhideWhenUsed
14
14
  end
15
15
 
16
16
 
@@ -0,0 +1,15 @@
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
+
6
+ module OpenXml
7
+ module Docx
8
+ module Properties
9
+ class Section < ContainerProperty
10
+ tag :sectPr
11
+ child_classes :page_size, :page_margins, :columns, :header_reference
12
+ end
13
+ end
14
+ end
15
+ end
@@ -6,8 +6,8 @@ module OpenXml
6
6
 
7
7
  with_namespace :w do
8
8
  attribute :color, expects: :hex_color
9
- attribute :frame, expects: :true_or_false
10
- attribute :shadow, expects: :true_or_false
9
+ attribute :frame, expects: :boolean
10
+ attribute :shadow, expects: :boolean
11
11
  attribute :space, expects: :positive_integer
12
12
  attribute :theme_color, expects: :valid_theme_color
13
13
  attribute :theme_shade, expects: :hex_digit
@@ -6,8 +6,8 @@ module OpenXml
6
6
 
7
7
  with_namespace :w do
8
8
  attribute :color, expects: :hex_color
9
- attribute :frame, expects: :true_or_false
10
- attribute :shadow, expects: :true_or_false
9
+ attribute :frame, expects: :boolean
10
+ attribute :shadow, expects: :boolean
11
11
  attribute :space, expects: :positive_integer
12
12
  attribute :theme_color, expects: :valid_theme_color
13
13
  attribute :theme_shade, expects: :hex_digit
@@ -5,12 +5,13 @@ module OpenXml
5
5
  tag :tblLook
6
6
 
7
7
  with_namespace :w do
8
- attribute :firstColumn, expects: :true_or_false
9
- attribute :firstRow, expects: :true_or_false
10
- attribute :lastColumn, expects: :true_or_false
11
- attribute :lastRow, expects: :true_or_false
12
- attribute :noHBand, expects: :true_or_false
13
- attribute :noVBand, expects: :true_or_false
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
14
15
  end
15
16
 
16
17
  end
@@ -4,7 +4,7 @@ module OpenXml
4
4
  class TextDirection < ValueProperty
5
5
 
6
6
  def ok_values
7
- %i(lr lrV rl rlV tb tbV)
7
+ %i(lr lrV rl rlV tb tbV btLr)
8
8
  end
9
9
 
10
10
  end
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,14 @@
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
@@ -8,7 +8,9 @@ module OpenXml
8
8
  property :columns
9
9
  property :document_grid
10
10
  property :footer_reference
11
+ property :footer_references
11
12
  property :header_reference
13
+ property :header_references
12
14
  property :line_numbering
13
15
  property :page_borders
14
16
  property :page_margins
@@ -6,8 +6,8 @@ module OpenXml
6
6
 
7
7
  attr_reader :paragraph, :character, :table, :type
8
8
 
9
- attribute :custom, expects: :true_or_false, displays_as: :customStyle, namespace: :w
10
- attribute :default, expects: :true_or_false, namespace: :w
9
+ attribute :custom, expects: :boolean, displays_as: :customStyle, namespace: :w
10
+ attribute :default, expects: :boolean, namespace: :w
11
11
  attribute :id, expects: :string, displays_as: :styleId, namespace: :w
12
12
  attribute :type, expects: :valid_style_type, namespace: :w
13
13
 
@@ -57,13 +57,17 @@ module OpenXml
57
57
  type == :character
58
58
  end
59
59
 
60
+ def table_style?
61
+ type == :table
62
+ end
63
+
60
64
  VALID_STYLE_TYPES = %i(character paragraph table)
61
65
 
62
66
  private
63
67
 
64
68
  def install_paragraph_properties
65
- @character = nil
66
69
  @table = nil
70
+ @character = OpenXml::Docx::Elements::Run.new
67
71
  @paragraph = OpenXml::Docx::Elements::Paragraph.new
68
72
  end
69
73
 
@@ -80,9 +84,17 @@ module OpenXml
80
84
  end
81
85
 
82
86
  def property_xml(xml)
83
- return paragraph.property_xml(xml) if paragraph_style?
84
- return character.property_xml(xml) if character_style?
85
- table.property_xml(xml)
87
+ style_property_xml(xml)
88
+
89
+ return table.property_xml(xml) if table_style?
90
+ character.property_xml(xml)
91
+ paragraph.property_xml(xml) if paragraph_style?
92
+ end
93
+
94
+ def style_property_xml(xml)
95
+ props = properties.keys.map(&method(:send)).compact
96
+ return if props.none?(&:render?)
97
+ props.each { |prop| prop.to_xml(xml) }
86
98
  end
87
99
 
88
100
  def valid_style_type(value)