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.
- data/Gemfile.lock +1 -1
- data/examples/booklet-printing +55 -0
- data/lib/openxml/docx/attribute_builder.rb +11 -5
- data/lib/openxml/docx/elements/absolute_position_tab.rb +1 -1
- data/lib/openxml/docx/elements/background.rb +16 -0
- data/lib/openxml/docx/elements/book_fold_printing.rb +1 -1
- data/lib/openxml/docx/elements/book_fold_reverse_printing.rb +1 -1
- data/lib/openxml/docx/elements/compatibility_setting.rb +10 -0
- data/lib/openxml/docx/elements/compatibility_settings.rb +15 -0
- data/lib/openxml/docx/elements/embed_bold.rb +2 -10
- data/lib/openxml/docx/elements/embed_bold_italic.rb +2 -10
- data/lib/openxml/docx/elements/embed_italic.rb +2 -10
- data/lib/openxml/docx/elements/embed_regular.rb +3 -3
- data/lib/openxml/docx/elements/embed_system_fonts.rb +1 -1
- data/lib/openxml/docx/elements/embed_true_type_fonts.rb +1 -1
- data/lib/openxml/docx/elements/even_and_odd_headers.rb +11 -0
- data/lib/openxml/docx/elements/family.rb +1 -1
- data/lib/openxml/docx/elements/markup_compatibility_choice.rb +1 -1
- data/lib/openxml/docx/elements/paragraph.rb +1 -0
- data/lib/openxml/docx/elements/save_subset_fonts.rb +1 -1
- data/lib/openxml/docx/elements/table_cell.rb +1 -0
- data/lib/openxml/docx/elements/textbox_content.rb +9 -0
- data/lib/openxml/docx/elements/word_processing_drawing_anchor.rb +6 -6
- data/lib/openxml/docx/elements/word_processing_drawing_inline.rb +16 -0
- data/lib/openxml/docx/elements/word_processing_drawing_object_nv_properties.rb +1 -1
- data/lib/openxml/docx/elements/word_processing_drawing_wrap_polygon.rb +1 -1
- data/lib/openxml/docx/elements/word_processing_shapes_body_properties.rb +12 -12
- data/lib/openxml/docx/elements/word_processing_shapes_nv_drawing_properties.rb +1 -1
- data/lib/openxml/docx/elements/word_processing_shapes_shape.rb +1 -2
- data/lib/openxml/docx/elements/word_processing_shapes_shape_properties.rb +1 -11
- data/lib/openxml/docx/elements/word_processing_shapes_textual_contents.rb +13 -0
- data/lib/openxml/{drawingml → docx}/elements/wordprocessing_shape_group.rb +1 -1
- data/lib/openxml/docx/package.rb +4 -3
- data/lib/openxml/docx/parts/document.rb +5 -0
- data/lib/openxml/docx/parts/header.rb +1 -1
- data/lib/openxml/docx/properties.rb +1 -0
- data/lib/openxml/docx/properties/border.rb +2 -2
- data/lib/openxml/docx/properties/columns.rb +8 -2
- data/lib/openxml/docx/properties/conditional_formatting.rb +12 -12
- data/lib/openxml/docx/properties/container_property.rb +10 -10
- data/lib/openxml/docx/properties/footer_references.rb +12 -0
- data/lib/openxml/docx/properties/frame.rb +1 -1
- data/lib/openxml/docx/properties/header_references.rb +12 -0
- data/lib/openxml/docx/properties/indentation.rb +5 -1
- data/lib/openxml/docx/properties/latent_styles.rb +4 -4
- data/lib/openxml/docx/properties/latent_styles_exception.rb +4 -4
- data/lib/openxml/docx/properties/section.rb +15 -0
- data/lib/openxml/docx/properties/table_border.rb +2 -2
- data/lib/openxml/docx/properties/table_cell_border.rb +2 -2
- data/lib/openxml/docx/properties/table_look.rb +7 -6
- data/lib/openxml/docx/properties/text_direction.rb +1 -1
- data/lib/openxml/docx/properties/transparent_container_property.rb +14 -0
- data/lib/openxml/docx/properties/vertical_merge.rb +14 -0
- data/lib/openxml/docx/section.rb +2 -0
- data/lib/openxml/docx/style.rb +18 -6
- data/lib/openxml/docx/version.rb +1 -1
- data/lib/openxml/drawingml/elements/blip_fill.rb +1 -1
- data/lib/openxml/drawingml/elements/children_extents.rb +14 -0
- data/lib/openxml/drawingml/elements/children_offset.rb +14 -0
- data/lib/openxml/drawingml/elements/graphic_frame_locks.rb +6 -6
- data/lib/openxml/drawingml/elements/no_autofit.rb +10 -0
- data/lib/openxml/drawingml/elements/no_fill.rb +1 -1
- data/lib/openxml/drawingml/elements/non_visual_drawing_properties.rb +1 -1
- data/lib/openxml/drawingml/elements/non_visual_picture_drawing_properties.rb +1 -1
- data/lib/openxml/drawingml/elements/non_visual_shape_drawing_properties.rb +12 -0
- data/lib/openxml/drawingml/elements/picture_locks.rb +11 -11
- data/lib/openxml/drawingml/elements/preset_text_warp.rb +25 -0
- data/lib/openxml/vml/elements/group.rb +17 -37
- data/lib/openxml/vml/elements/rectangle.rb +29 -62
- data/lib/openxml/vml/elements/rounded_rectangle.rb +29 -61
- data/spec/elements/absolute_position_tab_spec.rb +21 -15
- data/spec/elements/background_spec.rb +52 -0
- data/spec/elements/bidi_embed_spec.rb +12 -4
- data/spec/elements/bidi_override_spec.rb +12 -4
- data/spec/elements/break_spec.rb +12 -10
- data/spec/elements/compatibility_setting_spec.rb +41 -0
- data/spec/elements/compatibility_settings_spec.rb +8 -0
- data/spec/elements/content_part_spec.rb +2 -2
- data/spec/elements/control_spec.rb +5 -5
- data/spec/elements/deleted_text_spec.rb +2 -2
- data/spec/elements/drawingml/blip_fill_spec.rb +8 -3
- data/spec/elements/drawingml/extents_spec.rb +4 -4
- data/spec/elements/drawingml/head_end_spec.rb +16 -13
- data/spec/elements/drawingml/no_autofit_spec.rb +8 -0
- data/spec/elements/drawingml/non_visual_drawing_properties_spec.rb +6 -6
- data/spec/elements/drawingml/non_visual_shape_drawing_properties_spec.rb +24 -0
- data/spec/elements/drawingml/offset_spec.rb +14 -4
- data/spec/elements/drawingml/outline_spec.rb +20 -14
- data/spec/elements/drawingml/preset_geometry_spec.rb +1 -1
- data/spec/elements/drawingml/preset_text_warp_spec.rb +36 -0
- data/spec/elements/drawingml/shape_guide_spec.rb +7 -3
- data/spec/elements/drawingml/srgb_color_spec.rb +3 -4
- data/spec/elements/drawingml/tail_end_spec.rb +17 -14
- data/spec/elements/drawingml/transform_effect_spec.rb +48 -26
- data/spec/elements/markup_compatibility_choice_spec.rb +2 -2
- data/spec/elements/paragraph_spec.rb +25 -0
- data/spec/elements/symbol_spec.rb +4 -4
- data/spec/elements/text_spec.rb +1 -1
- data/spec/elements/textbox_content_spec.rb +8 -0
- data/spec/elements/vml/group_spec.rb +367 -375
- data/spec/elements/vml/rectangle_spec.rb +503 -513
- data/spec/elements/vml/rounded_rectangle_spec.rb +591 -463
- data/spec/elements/word_processing_drawing_effect_extent_spec.rb +32 -12
- data/spec/elements/word_processing_drawing_extent_spec.rb +4 -4
- data/spec/elements/word_processing_drawing_object_nv_properties_spec.rb +6 -6
- data/spec/elements/word_processing_drawing_simple_position_spec.rb +16 -6
- data/spec/elements/word_processing_shapes_body_properties_spec.rb +53 -44
- data/spec/elements/word_processing_shapes_shape_properties_spec.rb +6 -5
- data/spec/elements/word_processing_shapes_shape_spec.rb +2 -2
- data/spec/elements/word_processing_shapes_textual_content_spec.rb +23 -0
- data/spec/elements/{drawingml/wordprocessing_shape_group_spec.rb → wordprocessing_shape_group_spec.rb} +1 -1
- data/spec/properties/indentation_spec.rb +28 -0
- data/spec/properties/table_look_spec.rb +5 -0
- data/spec/properties/text_direction_spec.rb +5 -0
- data/spec/properties/vertical_merge_spec.rb +22 -0
- data/spec/support/data/elements/paragraph_with_section_properties_element.xml +12 -0
- data/spec/support/data/parts/empty_header_part.xml +1 -1
- data/spec/support/data/parts/header_with_children_part.xml +1 -1
- metadata +76 -27
- 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: :
|
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
|
@@ -5,17 +5,7 @@ module OpenXml
|
|
5
5
|
tag :spPr
|
6
6
|
namespace :wps
|
7
7
|
|
8
|
-
attribute :bwMode,
|
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
|
data/lib/openxml/docx/package.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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: :
|
10
|
-
attribute :shadow, expects: :
|
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: :
|
11
|
+
attribute :equal_width, expects: :boolean
|
12
12
|
attribute :number, expects: :integer, displays_as: :num
|
13
|
-
attribute :separator, expects: :
|
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: :
|
9
|
-
attribute :even_vertical_band, expects: :
|
10
|
-
attribute :first_column, expects: :
|
11
|
-
attribute :first_row, expects: :
|
12
|
-
attribute :first_row_first_column, expects: :
|
13
|
-
attribute :first_row_last_column, expects: :
|
14
|
-
attribute :last_column, expects: :
|
15
|
-
attribute :last_row, expects: :
|
16
|
-
attribute :last_row_first_column, expects: :
|
17
|
-
attribute :last_row_last_column, expects: :
|
18
|
-
attribute :odd_horizontal_band, expects: :
|
19
|
-
attribute :odd_vertical_band, expects: :
|
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
|
-
|
11
|
-
prop_name =
|
12
|
-
|
13
|
-
|
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
|
-
@
|
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
|
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
|
59
|
-
self.class.
|
58
|
+
def child_classes
|
59
|
+
self.class.child_classes
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -5,7 +5,7 @@ module OpenXml
|
|
5
5
|
tag :framePr
|
6
6
|
|
7
7
|
with_namespace :w do
|
8
|
-
attribute :anchor_lock, expects: :
|
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
|
@@ -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: :
|
12
|
-
attribute :default_qformat, expects: :
|
13
|
-
attribute :default_semi_hidden, expects: :
|
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: :
|
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: :
|
8
|
+
attribute :locked, expects: :boolean
|
9
9
|
attribute :style_name, expects: :string, displays_as: :name
|
10
|
-
attribute :qFormat, expects: :
|
11
|
-
attribute :semi_hidden, expects: :
|
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: :
|
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: :
|
10
|
-
attribute :shadow, expects: :
|
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: :
|
10
|
-
attribute :shadow, expects: :
|
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: :
|
9
|
-
attribute :firstRow, expects: :
|
10
|
-
attribute :lastColumn, expects: :
|
11
|
-
attribute :lastRow, expects: :
|
12
|
-
attribute :noHBand, expects: :
|
13
|
-
attribute :noVBand, expects: :
|
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
|
data/lib/openxml/docx/section.rb
CHANGED
@@ -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
|
data/lib/openxml/docx/style.rb
CHANGED
@@ -6,8 +6,8 @@ module OpenXml
|
|
6
6
|
|
7
7
|
attr_reader :paragraph, :character, :table, :type
|
8
8
|
|
9
|
-
attribute :custom, expects: :
|
10
|
-
attribute :default, expects: :
|
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
|
-
|
84
|
-
|
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)
|