ooxml_parser 0.35.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +5 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +72 -72
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +5 -5
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +3 -9
- data/lib/ooxml_parser/common_parser/common_data/color.rb +11 -3
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +2 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/{line_spacing.rb → spacing_valued_child.rb} +13 -4
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing.rb +9 -21
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_document_structure.rb +12 -2
- data/lib/ooxml_parser/docx_parser/document_structure/default_style_helper.rb +27 -27
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +1 -1
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph.rb +15 -24
- data/lib/ooxml_parser/docx_parser/document_structure/header_footer.rb +1 -1
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/note.rb +14 -7
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb +15 -2
- data/lib/ooxml_parser/docx_parser/document_structure.rb +13 -9
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{time_node → time_node_list/time_node}/common_timing.rb +3 -3
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{time_node.rb → time_node_list/time_node.rb} +0 -26
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list.rb +40 -0
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing.rb +2 -2
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/{xlsx_column_properties.rb → xlsx_columns/xlsx_column_properties.rb} +0 -13
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_columns.rb +28 -0
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet.rb +2 -2
- metadata +15 -153
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{animation_effect → time_node_list/animation_effect}/animation_effect.rb +0 -0
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{set_time_node → time_node_list/set_time_node}/behavior/behavior.rb +0 -0
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{set_time_node → time_node_list/set_time_node}/behavior/target_element.rb +0 -0
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{set_time_node → time_node_list/set_time_node}/set_time_node.rb +0 -0
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{time_node → time_node_list/time_node}/common_timing/codition_list/condition.rb +0 -0
- /data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/{time_node → time_node_list/time_node}/common_timing/condition_list.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d47597307e327f07be8d801416ae5cdfd75b7f02b3202fc5ba8cca94dcb67b5b
|
|
4
|
+
data.tar.gz: 69ebb6f5328aa6e5124258237c62aa03942bec04708915241ebc961ca331a187
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77709ddfb3e40812d73e3cf071f671ec88bbbf9a234efad1d197003aa703e1f7e42232902b32dc9fefbaf6653747dfad70e1948d9991d6b61821f80cf8ef1e51
|
|
7
|
+
data.tar.gz: 28efb15b174c9d646a192b0ce84cac2f1cbe9e77afc17de890f67f09ba3dd27ee51e1b2427f272ed77d6feb8f185860de81cb38cd4ddcd5b1c436d6e70e23439
|
|
@@ -67,7 +67,7 @@ module OoxmlParser
|
|
|
67
67
|
next unless val
|
|
68
68
|
next if val.xpath('c:numRef').empty?
|
|
69
69
|
|
|
70
|
-
@data << ChartCellsRange.new(parent: self).parse(val.xpath('c:numRef').first)
|
|
70
|
+
@data << ChartCellsRange.new(parent: self).parse(val.xpath('c:numRef').first)
|
|
71
71
|
when 'dLbls'
|
|
72
72
|
@display_labels = DisplayLabelsProperties.new(parent: self).parse(chart_props_node_child)
|
|
73
73
|
when 'varyColors'
|
|
@@ -86,77 +86,7 @@ module OoxmlParser
|
|
|
86
86
|
chart_xml.xpath('*').each do |chart_node|
|
|
87
87
|
case chart_node.name
|
|
88
88
|
when 'chartSpace'
|
|
89
|
-
chart_node
|
|
90
|
-
case chart_space_node_child.name
|
|
91
|
-
when 'AlternateContent'
|
|
92
|
-
@alternate_content = AlternateContent.new(parent: self).parse(chart_space_node_child)
|
|
93
|
-
when 'spPr'
|
|
94
|
-
@shape_properties = DocxShapeProperties.new(parent: self).parse(chart_space_node_child)
|
|
95
|
-
when 'chart'
|
|
96
|
-
chart_space_node_child.xpath('*').each do |chart_node_child|
|
|
97
|
-
case chart_node_child.name
|
|
98
|
-
when 'plotArea'
|
|
99
|
-
chart_node_child.xpath('*').each do |plot_area_node_child|
|
|
100
|
-
next unless type.empty?
|
|
101
|
-
|
|
102
|
-
case plot_area_node_child.name
|
|
103
|
-
when 'barChart'
|
|
104
|
-
@type = :bar
|
|
105
|
-
bar_dir_node = plot_area_node_child.xpath('c:barDir')
|
|
106
|
-
@type = :column if bar_dir_node.first.attribute('val').value == 'col'
|
|
107
|
-
parse_properties(plot_area_node_child)
|
|
108
|
-
when 'lineChart'
|
|
109
|
-
@type = :line
|
|
110
|
-
parse_properties(plot_area_node_child)
|
|
111
|
-
when 'areaChart'
|
|
112
|
-
@type = :area
|
|
113
|
-
parse_properties(plot_area_node_child)
|
|
114
|
-
when 'bubbleChart'
|
|
115
|
-
@type = :bubble
|
|
116
|
-
parse_properties(plot_area_node_child)
|
|
117
|
-
when 'doughnutChart'
|
|
118
|
-
@type = :doughnut
|
|
119
|
-
parse_properties(plot_area_node_child)
|
|
120
|
-
when 'pieChart'
|
|
121
|
-
@type = :pie
|
|
122
|
-
parse_properties(plot_area_node_child)
|
|
123
|
-
when 'scatterChart'
|
|
124
|
-
@type = :point
|
|
125
|
-
parse_properties(plot_area_node_child)
|
|
126
|
-
when 'radarChart'
|
|
127
|
-
@type = :radar
|
|
128
|
-
parse_properties(plot_area_node_child)
|
|
129
|
-
when 'stockChart'
|
|
130
|
-
@type = :stock
|
|
131
|
-
parse_properties(plot_area_node_child)
|
|
132
|
-
when 'surface3DChart'
|
|
133
|
-
@type = :surface_3d
|
|
134
|
-
parse_properties(plot_area_node_child)
|
|
135
|
-
when 'line3DChart'
|
|
136
|
-
@type = :line_3d
|
|
137
|
-
parse_properties(plot_area_node_child)
|
|
138
|
-
when 'bar3DChart'
|
|
139
|
-
@type = :bar_3d
|
|
140
|
-
parse_properties(plot_area_node_child)
|
|
141
|
-
when 'pie3DChart'
|
|
142
|
-
@type = :pie_3d
|
|
143
|
-
parse_properties(plot_area_node_child)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
parse_axis(chart_node_child)
|
|
147
|
-
@plot_area = PlotArea.new(parent: self).parse(chart_node_child)
|
|
148
|
-
when 'title'
|
|
149
|
-
@title = ChartAxisTitle.new(parent: self).parse(chart_node_child)
|
|
150
|
-
when 'legend'
|
|
151
|
-
@legend = ChartLegend.new(parent: self).parse(chart_node_child)
|
|
152
|
-
when 'view3D'
|
|
153
|
-
@view_3d = View3D.new(parent: self).parse(chart_node_child)
|
|
154
|
-
when 'pivotFmts'
|
|
155
|
-
@pivot_formats = PivotFormats.new(parent: self).parse(chart_node_child)
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
89
|
+
parse_chart_space(chart_node)
|
|
160
90
|
end
|
|
161
91
|
end
|
|
162
92
|
parse_relationships
|
|
@@ -166,6 +96,76 @@ module OoxmlParser
|
|
|
166
96
|
|
|
167
97
|
private
|
|
168
98
|
|
|
99
|
+
# Parse 'chartSpace' node
|
|
100
|
+
# @return [nil]
|
|
101
|
+
def parse_chart_space(chart_space_node)
|
|
102
|
+
chart_space_node.xpath('*').each do |chart_space_node_child|
|
|
103
|
+
case chart_space_node_child.name
|
|
104
|
+
when 'AlternateContent'
|
|
105
|
+
@alternate_content = AlternateContent.new(parent: self).parse(chart_space_node_child)
|
|
106
|
+
when 'spPr'
|
|
107
|
+
@shape_properties = DocxShapeProperties.new(parent: self).parse(chart_space_node_child)
|
|
108
|
+
when 'chart'
|
|
109
|
+
chart_space_node_child.xpath('*').each do |chart_node_child|
|
|
110
|
+
case chart_node_child.name
|
|
111
|
+
when 'plotArea'
|
|
112
|
+
chart_node_child.xpath('*').each do |plot_area_node_child|
|
|
113
|
+
next unless type.empty?
|
|
114
|
+
|
|
115
|
+
parse_chart_type(plot_area_node_child)
|
|
116
|
+
parse_properties(plot_area_node_child)
|
|
117
|
+
end
|
|
118
|
+
parse_axis(chart_node_child)
|
|
119
|
+
@plot_area = PlotArea.new(parent: self).parse(chart_node_child)
|
|
120
|
+
when 'title'
|
|
121
|
+
@title = ChartAxisTitle.new(parent: self).parse(chart_node_child)
|
|
122
|
+
when 'legend'
|
|
123
|
+
@legend = ChartLegend.new(parent: self).parse(chart_node_child)
|
|
124
|
+
when 'view3D'
|
|
125
|
+
@view_3d = View3D.new(parent: self).parse(chart_node_child)
|
|
126
|
+
when 'pivotFmts'
|
|
127
|
+
@pivot_formats = PivotFormats.new(parent: self).parse(chart_node_child)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Parse chart type and properties
|
|
135
|
+
# @return [nil]
|
|
136
|
+
def parse_chart_type(plot_area_node_child)
|
|
137
|
+
case plot_area_node_child.name
|
|
138
|
+
when 'barChart'
|
|
139
|
+
@type = :bar
|
|
140
|
+
bar_dir_node = plot_area_node_child.xpath('c:barDir')
|
|
141
|
+
@type = :column if bar_dir_node.first.attribute('val').value == 'col'
|
|
142
|
+
when 'lineChart'
|
|
143
|
+
@type = :line
|
|
144
|
+
when 'areaChart'
|
|
145
|
+
@type = :area
|
|
146
|
+
when 'bubbleChart'
|
|
147
|
+
@type = :bubble
|
|
148
|
+
when 'doughnutChart'
|
|
149
|
+
@type = :doughnut
|
|
150
|
+
when 'pieChart'
|
|
151
|
+
@type = :pie
|
|
152
|
+
when 'scatterChart'
|
|
153
|
+
@type = :point
|
|
154
|
+
when 'radarChart'
|
|
155
|
+
@type = :radar
|
|
156
|
+
when 'stockChart'
|
|
157
|
+
@type = :stock
|
|
158
|
+
when 'surface3DChart'
|
|
159
|
+
@type = :surface_3d
|
|
160
|
+
when 'line3DChart'
|
|
161
|
+
@type = :line_3d
|
|
162
|
+
when 'bar3DChart'
|
|
163
|
+
@type = :bar_3d
|
|
164
|
+
when 'pie3DChart'
|
|
165
|
+
@type = :pie_3d
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
169
|
# Perform parsing of axis info
|
|
170
170
|
# @param node [Nokogiri::XML:Element] node to parse
|
|
171
171
|
# @return [void]
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module OoxmlParser
|
|
4
4
|
# Class for working with TextBox (w:txbxContent)
|
|
5
|
-
class TextBox
|
|
5
|
+
class TextBox < OOXMLDocumentObject
|
|
6
6
|
# Parse TextBox List
|
|
7
7
|
# @param [Nokogiri::XML:Node] node with TextBox
|
|
8
8
|
# @return [Array] array of elements
|
|
9
|
-
def
|
|
9
|
+
def parse_list(node)
|
|
10
10
|
elements = []
|
|
11
11
|
text_box_content_node = node.xpath('w:txbxContent').first
|
|
12
12
|
|
|
13
13
|
text_box_content_node&.xpath('*')&.each_with_index do |textbox_element, i|
|
|
14
14
|
case textbox_element.name
|
|
15
15
|
when 'p'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
elements <<
|
|
16
|
+
textbox_paragraph = DocxParagraph.new
|
|
17
|
+
textbox_paragraph.spacing = Spacing.new(0, 0.35, 1.15, :multiple)
|
|
18
|
+
elements << textbox_paragraph.parse(textbox_element, i, parent: parent)
|
|
19
19
|
when 'tbl'
|
|
20
20
|
elements << Table.new(parent: parent).parse(textbox_element, i)
|
|
21
21
|
end
|
data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb
CHANGED
|
@@ -16,7 +16,7 @@ module OoxmlParser
|
|
|
16
16
|
node.xpath('*').each do |node_child|
|
|
17
17
|
case node_child.name
|
|
18
18
|
when 'textbox'
|
|
19
|
-
@text_box = TextBox.
|
|
19
|
+
@text_box = TextBox.new(parent: parent).parse_list(node_child)
|
|
20
20
|
when 'imagedata'
|
|
21
21
|
@file_reference = FileReference.new(parent: self).parse(node_child)
|
|
22
22
|
when 'fill'
|
|
@@ -5,12 +5,6 @@ module OoxmlParser
|
|
|
5
5
|
module ColorHelper
|
|
6
6
|
# @return [String] value for auto string
|
|
7
7
|
AUTO_STRING_VALUE = 'auto'
|
|
8
|
-
# @return [Regexp] regexp for hex string with 3 digits
|
|
9
|
-
REGEXP_THREE_DIGITS = /(.)(.)(.)/.freeze
|
|
10
|
-
# @return [Regexp] regexp for hex string with 6 digits
|
|
11
|
-
REGEXP_SIX_DIGITS = /(..)(..)(..)/.freeze
|
|
12
|
-
# @return [Regexp] regexp for hex string with 8 digits
|
|
13
|
-
REGEXP_EIGHT_DIGITS = /(..)(..)(..)(..)/.freeze
|
|
14
8
|
|
|
15
9
|
# Parse string in hex
|
|
16
10
|
# @param [String] hex_string with or without alpha-channel
|
|
@@ -19,11 +13,11 @@ module OoxmlParser
|
|
|
19
13
|
|
|
20
14
|
case hex_string.length
|
|
21
15
|
when 3
|
|
22
|
-
@red, @green, @blue = hex_string.
|
|
16
|
+
@red, @green, @blue = hex_string.chars.map(&:hex)
|
|
23
17
|
when 6
|
|
24
|
-
@red, @green, @blue = hex_string.
|
|
18
|
+
@red, @green, @blue = hex_string.unpack('A2A2A2').map(&:hex)
|
|
25
19
|
when 8
|
|
26
|
-
@alpha_channel, @red, @green, @blue = hex_string.
|
|
20
|
+
@alpha_channel, @red, @green, @blue = hex_string.unpack('A2A2A2A2').map(&:hex)
|
|
27
21
|
end
|
|
28
22
|
self
|
|
29
23
|
end
|
|
@@ -112,6 +112,16 @@ module OoxmlParser
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
# Check if other color is within delta with current color
|
|
116
|
+
# @param other [Color] color to compare
|
|
117
|
+
# @param delta [Integer] max delta for each of specters
|
|
118
|
+
# @return [True, False] result of comparison
|
|
119
|
+
def within_delta?(other, delta)
|
|
120
|
+
(red - other.red).abs < delta &&
|
|
121
|
+
(green - other.green).abs < delta &&
|
|
122
|
+
(blue - other.blue).abs < delta
|
|
123
|
+
end
|
|
124
|
+
|
|
115
125
|
# To compare color, which look alike
|
|
116
126
|
# @param [String or Color] color_to_check color to compare
|
|
117
127
|
# @param [Integer] delta max delta for each of specters
|
|
@@ -128,9 +138,7 @@ module OoxmlParser
|
|
|
128
138
|
return false if !none? && color_to_check.none?
|
|
129
139
|
return true if self == color_to_check
|
|
130
140
|
|
|
131
|
-
(
|
|
132
|
-
(green - color_to_check.green).abs < delta &&
|
|
133
|
-
(blue - color_to_check.blue).abs < delta
|
|
141
|
+
within_delta?(color_to_check, delta)
|
|
134
142
|
end
|
|
135
143
|
|
|
136
144
|
# Apply tint to color
|
|
@@ -47,6 +47,8 @@ module OoxmlParser
|
|
|
47
47
|
return true if value.to_s == 'true'
|
|
48
48
|
return false if value.to_s == '0'
|
|
49
49
|
return false if value.to_s == 'false'
|
|
50
|
+
|
|
51
|
+
raise ArgumentError, "Invalid value for boolean attribute: #{value}"
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
# @return [Nokogiri::XML::Document] result of parsing xml via nokogiri
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module OoxmlParser
|
|
4
|
-
# Class to describe spacing
|
|
5
|
-
class
|
|
4
|
+
# Class to describe spacing valued child
|
|
5
|
+
class SpacingValuedChild < OOXMLDocumentObject
|
|
6
6
|
# @return [ValuedChild] spacing percent
|
|
7
7
|
attr_reader :spacing_percent
|
|
8
8
|
# @return [ValuedChild] spacing point
|
|
@@ -15,14 +15,23 @@ module OoxmlParser
|
|
|
15
15
|
node.xpath('*').each do |node_child|
|
|
16
16
|
case node_child.name
|
|
17
17
|
when 'spcPct'
|
|
18
|
-
@spacing_percent = ValuedChild.new(:
|
|
18
|
+
@spacing_percent = ValuedChild.new(:float, parent: self).parse(node_child)
|
|
19
19
|
when 'spcPts'
|
|
20
|
-
@spacing_points = ValuedChild.new(:
|
|
20
|
+
@spacing_points = ValuedChild.new(:float, parent: self).parse(node_child)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
self
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
# Convert to OoxmlSize
|
|
27
|
+
# @return [OoxmlSize]
|
|
28
|
+
def to_ooxml_size
|
|
29
|
+
return OoxmlSize.new(@spacing_percent.value, :one_1000th_percent) if @spacing_percent
|
|
30
|
+
return OoxmlSize.new(@spacing_points.value, :spacing_point) if @spacing_points
|
|
31
|
+
|
|
32
|
+
raise 'Unknown spacing child type'
|
|
33
|
+
end
|
|
34
|
+
|
|
26
35
|
# @return [Symbol] rule used to determine line spacing
|
|
27
36
|
def rule
|
|
28
37
|
return :multiple if @spacing_percent
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @author Pavel.Lobashov
|
|
4
4
|
|
|
5
|
-
require_relative 'spacing/
|
|
5
|
+
require_relative 'spacing/spacing_valued_child'
|
|
6
6
|
module OoxmlParser
|
|
7
7
|
# Class to describe spacing
|
|
8
8
|
class Spacing
|
|
@@ -69,30 +69,18 @@ module OoxmlParser
|
|
|
69
69
|
# @param [Nokogiri::XML:Element] node with Spacing
|
|
70
70
|
# @return [Nothing]
|
|
71
71
|
def parse(node)
|
|
72
|
-
node.xpath('*').each do |
|
|
73
|
-
case
|
|
72
|
+
node.xpath('*').each do |node_child|
|
|
73
|
+
case node_child.name
|
|
74
74
|
when 'lnSpc'
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
@line_spacing = SpacingValuedChild.new(parent: self).parse(node_child)
|
|
76
|
+
self.line = @line_spacing.to_ooxml_size
|
|
77
77
|
self.line_rule = @line_spacing.rule
|
|
78
78
|
when 'spcBef'
|
|
79
|
-
|
|
79
|
+
@spacing_before = SpacingValuedChild.new(parent: self).parse(node_child)
|
|
80
|
+
self.before = @spacing_before.to_ooxml_size
|
|
80
81
|
when 'spcAft'
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Parse values of spacing number
|
|
87
|
-
# @param [Nokogiri::XML:Element] node with Spacing
|
|
88
|
-
# @return [Float] value of spacing number
|
|
89
|
-
def self.parse_spacing_value(node)
|
|
90
|
-
node.xpath('*').each do |spacing_node_child|
|
|
91
|
-
case spacing_node_child.name
|
|
92
|
-
when 'spcPct'
|
|
93
|
-
return OoxmlSize.new(spacing_node_child.attribute('val').value.to_f, :one_1000th_percent)
|
|
94
|
-
when 'spcPts'
|
|
95
|
-
return OoxmlSize.new(spacing_node_child.attribute('val').value.to_f, :spacing_point)
|
|
82
|
+
@spacing_after = SpacingValuedChild.new(parent: self).parse(node_child)
|
|
83
|
+
self.after = @spacing_after.to_ooxml_size
|
|
96
84
|
end
|
|
97
85
|
end
|
|
98
86
|
end
|
|
@@ -36,10 +36,10 @@ module OoxmlParser
|
|
|
36
36
|
when 'tcPr'
|
|
37
37
|
@properties = CellProperties.new(parent: self).parse(node_child)
|
|
38
38
|
when 'p'
|
|
39
|
-
@elements <<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
@elements << root_object.default_table_paragraph_style.dup.parse(node_child,
|
|
40
|
+
0,
|
|
41
|
+
root_object.default_table_run_style,
|
|
42
|
+
parent: self)
|
|
43
43
|
when 'sdt'
|
|
44
44
|
@elements << StructuredDocumentTag.new(parent: self).parse(node_child)
|
|
45
45
|
when 'tbl'
|
|
@@ -27,6 +27,7 @@ module OoxmlParser
|
|
|
27
27
|
@default_font_style = FontStyle.new
|
|
28
28
|
@unpacked_folder = params.fetch(:unpacked_folder, nil)
|
|
29
29
|
@xmls_stack = []
|
|
30
|
+
@relationships_cache = {}
|
|
30
31
|
super(parent: nil)
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -56,8 +57,17 @@ module OoxmlParser
|
|
|
56
57
|
rels_path = dir + "_rels/#{File.basename(@xmls_stack.last)}.rels"
|
|
57
58
|
raise LoadError, "Cannot find .rels file by path: #{rels_path}" unless File.exist?(rels_path)
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
cache_relationships(rels_path)
|
|
61
|
+
@relationships_cache[rels_path].target_by_id(id)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# Store relationships to cache
|
|
67
|
+
def cache_relationships(rels_path)
|
|
68
|
+
return if @relationships_cache.key?(rels_path)
|
|
69
|
+
|
|
70
|
+
@relationships_cache[rels_path] = Relationships.new.parse_file(rels_path)
|
|
61
71
|
end
|
|
62
72
|
end
|
|
63
73
|
end
|
|
@@ -9,19 +9,19 @@ module OoxmlParser
|
|
|
9
9
|
parse_default_style_paragraph_properties
|
|
10
10
|
parse_default_style_run_properties
|
|
11
11
|
parse_default_character_style
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
root_object.default_table_paragraph_style = root_object.default_paragraph_style.dup
|
|
13
|
+
root_object.default_table_paragraph_style.spacing = Spacing.new(0, 0, 1, :auto)
|
|
14
|
+
root_object.default_table_run_style = root_object.default_run_style.dup
|
|
15
15
|
parse_default_table_style
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Perform parsing styles.xml
|
|
19
19
|
def parse_styles
|
|
20
20
|
file = "#{root_object.unpacked_folder}/word/styles.xml"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
root_object.default_paragraph_style = DocxParagraph.new(parent: self)
|
|
22
|
+
root_object.default_table_paragraph_style = DocxParagraph.new(parent: self)
|
|
23
|
+
root_object.default_run_style = DocxParagraphRun.new(parent: self)
|
|
24
|
+
root_object.default_table_run_style = DocxParagraphRun.new(parent: self)
|
|
25
25
|
|
|
26
26
|
return unless File.exist?(file)
|
|
27
27
|
|
|
@@ -29,18 +29,18 @@ module OoxmlParser
|
|
|
29
29
|
@numbering = Numbering.new(parent: self).parse
|
|
30
30
|
|
|
31
31
|
if @styles&.document_defaults&.paragraph_properties_default
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
root_object.default_paragraph_style = DocxParagraph.new(parent: self)
|
|
33
|
+
.parse(@styles.document_defaults
|
|
34
|
+
.paragraph_properties_default
|
|
35
|
+
.raw_node, 0)
|
|
36
36
|
end
|
|
37
37
|
if @styles&.document_defaults&.run_properties_default&.run_properties
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
root_object.default_run_style = DocxParagraphRun.new(parent: self)
|
|
39
|
+
.parse_properties(@styles
|
|
40
|
+
.document_defaults
|
|
41
|
+
.run_properties_default
|
|
42
|
+
.run_properties
|
|
43
|
+
.raw_node)
|
|
44
44
|
end
|
|
45
45
|
parse_default_style
|
|
46
46
|
end
|
|
@@ -50,16 +50,16 @@ module OoxmlParser
|
|
|
50
50
|
def parse_default_style_paragraph_properties
|
|
51
51
|
return unless @styles&.default_style(:paragraph)&.paragraph_properties_node
|
|
52
52
|
|
|
53
|
-
DocxParagraph.new.parse_paragraph_style(@styles.default_style(:paragraph)
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
DocxParagraph.new(parent: self).parse_paragraph_style(@styles.default_style(:paragraph)
|
|
54
|
+
.paragraph_properties_node,
|
|
55
|
+
root_object.default_run_style)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def parse_default_style_run_properties
|
|
59
59
|
return unless @styles&.default_style(:paragraph)&.run_properties_node
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
root_object.default_run_style
|
|
62
|
+
.parse_properties(@styles.default_style(:paragraph)
|
|
63
63
|
.run_properties_node)
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -67,8 +67,8 @@ module OoxmlParser
|
|
|
67
67
|
def parse_default_character_style
|
|
68
68
|
return unless @styles&.default_style(:character)&.run_properties_node
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
root_object.default_run_style
|
|
71
|
+
.parse_properties(@styles.default_style(:character)
|
|
72
72
|
.run_properties_node)
|
|
73
73
|
end
|
|
74
74
|
|
|
@@ -76,9 +76,9 @@ module OoxmlParser
|
|
|
76
76
|
def parse_default_table_style
|
|
77
77
|
return unless @styles&.default_style(:table)&.run_properties_node
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
root_object.default_table_run_style
|
|
80
|
+
.parse_properties(@styles.default_style(:table)
|
|
81
|
+
.run_properties_node)
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -109,7 +109,6 @@ module OoxmlParser
|
|
|
109
109
|
custom_character_style = default_character_style.dup
|
|
110
110
|
custom_character_style.parent = self
|
|
111
111
|
char_number = 0
|
|
112
|
-
comments = []
|
|
113
112
|
node.attributes.each do |key, value|
|
|
114
113
|
case key
|
|
115
114
|
when 'paraId'
|
|
@@ -136,27 +135,26 @@ module OoxmlParser
|
|
|
136
135
|
@page_numbering = true if field_simple.page_numbering?
|
|
137
136
|
character_styles_array += field_simple.runs
|
|
138
137
|
when 'r'
|
|
139
|
-
|
|
138
|
+
run = custom_character_style.dup
|
|
140
139
|
node_child.xpath('w:instrText').each do |insrt_text|
|
|
141
140
|
@page_numbering = true if insrt_text.text.include?('PAGE')
|
|
142
141
|
end
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
character_styles_array << character_style.dup
|
|
146
|
-
character_styles_array.last.shape = character_style.shape if character_style.shape
|
|
142
|
+
run.parse(node_child, char_number, parent: self)
|
|
143
|
+
character_styles_array << run
|
|
147
144
|
char_number += 1
|
|
148
145
|
when 'hyperlink'
|
|
149
146
|
@hyperlink = Hyperlink.new(parent: self).parse(node_child)
|
|
150
|
-
character_style = default_character_style.dup
|
|
151
|
-
character_style.parent = self
|
|
152
|
-
if @hyperlink.id
|
|
153
|
-
character_style.link = Hyperlink.new(parent: character_style).parse(node_child)
|
|
154
|
-
elsif @hyperlink.anchor
|
|
155
|
-
character_style.link = @hyperlink.anchor
|
|
156
|
-
end
|
|
157
147
|
node_child.xpath('w:r').each do |r_tag|
|
|
158
|
-
|
|
159
|
-
|
|
148
|
+
hyperlink_run = default_character_style.dup
|
|
149
|
+
hyperlink_run.parent = self
|
|
150
|
+
if @hyperlink.id
|
|
151
|
+
@hyperlink.parent = hyperlink_run
|
|
152
|
+
hyperlink_run.link = @hyperlink
|
|
153
|
+
elsif @hyperlink.anchor
|
|
154
|
+
hyperlink_run.link = @hyperlink.anchor
|
|
155
|
+
end
|
|
156
|
+
hyperlink_run.parse(r_tag, char_number, parent: self)
|
|
157
|
+
character_styles_array << hyperlink_run
|
|
160
158
|
char_number += 1
|
|
161
159
|
end
|
|
162
160
|
node_child.xpath('w:fldSimple').each do |simple_field|
|
|
@@ -206,7 +204,7 @@ module OoxmlParser
|
|
|
206
204
|
@paragraph_style_ref = ParagraphStyleRef.new(parent: self).parse(node_child)
|
|
207
205
|
fill_style_data(default_char_style)
|
|
208
206
|
when 'ind'
|
|
209
|
-
@ind =
|
|
207
|
+
@ind = root_object.default_paragraph_style.instance_variable_get(:@ind).dup.parse(node_child)
|
|
210
208
|
when 'numPr'
|
|
211
209
|
@numbering = NumberingProperties.new(parent: self).parse(node_child)
|
|
212
210
|
when 'jc'
|
|
@@ -218,14 +216,7 @@ module OoxmlParser
|
|
|
218
216
|
@spacing = @spacing.fetch_from_valued_spacing(@valued_spacing)
|
|
219
217
|
when 'sectPr'
|
|
220
218
|
@sector_properties = PageProperties.new(parent: self).parse(node_child, self, default_char_style)
|
|
221
|
-
@section_break
|
|
222
|
-
when 'oddPage'
|
|
223
|
-
'Odd page'
|
|
224
|
-
when 'continuous'
|
|
225
|
-
'Current Page'
|
|
226
|
-
else
|
|
227
|
-
'Next Page'
|
|
228
|
-
end
|
|
219
|
+
@section_break ||= @sector_properties.section_break
|
|
229
220
|
end
|
|
230
221
|
end
|
|
231
222
|
@parent = parent
|
|
@@ -65,7 +65,7 @@ module OoxmlParser
|
|
|
65
65
|
|
|
66
66
|
paragraph_number = 0
|
|
67
67
|
footnote.xpath('w:p').each do |paragraph|
|
|
68
|
-
@elements <<
|
|
68
|
+
@elements << root_object.default_paragraph_style.dup.parse(paragraph, paragraph_number, root_object.default_run_style, parent: self)
|
|
69
69
|
paragraph_number += 1
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -5,11 +5,23 @@ module OoxmlParser
|
|
|
5
5
|
class Note < OOXMLDocumentObject
|
|
6
6
|
attr_accessor :type, :elements, :assigned_to
|
|
7
7
|
|
|
8
|
-
def initialize
|
|
8
|
+
def initialize(type: 'unknown')
|
|
9
9
|
@elements = []
|
|
10
|
+
@type = type
|
|
10
11
|
super(parent: nil)
|
|
11
12
|
end
|
|
12
13
|
|
|
14
|
+
# @return [String] xpath for note in xml object
|
|
15
|
+
def note_base_xpath
|
|
16
|
+
@note_base_xpath ||= if @type.include?('footer')
|
|
17
|
+
'//w:ftr'
|
|
18
|
+
elsif @type.include?('header')
|
|
19
|
+
'//w:hdr'
|
|
20
|
+
else
|
|
21
|
+
raise NameError, "Unknown note type: #{@type}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
13
25
|
# Parse note data
|
|
14
26
|
# @param params [Hash] data to parse
|
|
15
27
|
# @return [Note] result of parsing
|
|
@@ -18,12 +30,7 @@ module OoxmlParser
|
|
|
18
30
|
@assigned_to = params[:assigned_to]
|
|
19
31
|
@parent = params[:parent]
|
|
20
32
|
doc = parse_xml(file_path(params[:target]))
|
|
21
|
-
|
|
22
|
-
xpath_note = '//w:ftr'
|
|
23
|
-
elsif @type.include?('header')
|
|
24
|
-
xpath_note = '//w:hdr'
|
|
25
|
-
end
|
|
26
|
-
doc.search(xpath_note).each do |ftr|
|
|
33
|
+
doc.search(note_base_xpath).each do |ftr|
|
|
27
34
|
number = 0
|
|
28
35
|
ftr.xpath('*').each do |sub_element|
|
|
29
36
|
case sub_element.name
|
|
@@ -19,9 +19,10 @@ module OoxmlParser
|
|
|
19
19
|
# @return [True, False] Specifies whether the section should have a different header and footer for its first page
|
|
20
20
|
attr_reader :title_page
|
|
21
21
|
|
|
22
|
-
def initialize(parent: nil)
|
|
22
|
+
def initialize(parent: nil, type: nil)
|
|
23
23
|
@notes = []
|
|
24
|
-
|
|
24
|
+
@type = type
|
|
25
|
+
super(parent: parent)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
# Parse PageProperties data
|
|
@@ -87,5 +88,17 @@ module OoxmlParser
|
|
|
87
88
|
end
|
|
88
89
|
self
|
|
89
90
|
end
|
|
91
|
+
|
|
92
|
+
# @return [String] type of section break
|
|
93
|
+
def section_break
|
|
94
|
+
@section_break ||= case type
|
|
95
|
+
when 'oddPage'
|
|
96
|
+
'Odd page'
|
|
97
|
+
when 'continuous'
|
|
98
|
+
'Current Page'
|
|
99
|
+
else
|
|
100
|
+
'Next Page'
|
|
101
|
+
end
|
|
102
|
+
end
|
|
90
103
|
end
|
|
91
104
|
end
|
|
@@ -45,6 +45,14 @@ module OoxmlParser
|
|
|
45
45
|
attr_accessor :comments_document
|
|
46
46
|
# @return [CommentsExtended] extended comments
|
|
47
47
|
attr_accessor :comments_extended
|
|
48
|
+
# @return [DocxParagraph] default paragraph style
|
|
49
|
+
attr_accessor :default_paragraph_style
|
|
50
|
+
# @return [DocxParagraphRun] default run style
|
|
51
|
+
attr_accessor :default_run_style
|
|
52
|
+
# @return [DocxParagraph] default table paragraph style
|
|
53
|
+
attr_accessor :default_table_paragraph_style
|
|
54
|
+
# @return [DocxParagraphRun] default table run style
|
|
55
|
+
attr_accessor :default_table_run_style
|
|
48
56
|
|
|
49
57
|
def initialize(params = {})
|
|
50
58
|
@elements = []
|
|
@@ -162,8 +170,8 @@ module OoxmlParser
|
|
|
162
170
|
@content_types = ContentTypes.new(parent: self).parse
|
|
163
171
|
@root_subfolder = 'word/'
|
|
164
172
|
@comments = []
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
@default_paragraph_style = DocxParagraph.new
|
|
174
|
+
@default_run_style = DocxParagraphRun.new(parent: self)
|
|
167
175
|
@theme = PresentationTheme.new(parent: self).parse('word/theme/theme1.xml')
|
|
168
176
|
@relationships = Relationships.new(parent: self).parse_file("#{root_object.unpacked_folder}word/_rels/document.xml.rels")
|
|
169
177
|
parse_styles
|
|
@@ -180,7 +188,7 @@ module OoxmlParser
|
|
|
180
188
|
when 'p'
|
|
181
189
|
child = element.child
|
|
182
190
|
unless child.nil? && @elements.last.instance_of?(Table)
|
|
183
|
-
paragraph_style =
|
|
191
|
+
paragraph_style = default_paragraph_style.dup.parse(element, number, default_run_style, parent: self)
|
|
184
192
|
number += 1
|
|
185
193
|
@elements << paragraph_style.dup
|
|
186
194
|
end
|
|
@@ -196,8 +204,8 @@ module OoxmlParser
|
|
|
196
204
|
end
|
|
197
205
|
body.xpath('w:sectPr').each do |sect_pr|
|
|
198
206
|
@page_properties = PageProperties.new(parent: self).parse(sect_pr,
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
default_paragraph_style,
|
|
208
|
+
default_run_style)
|
|
201
209
|
@notes = page_properties.notes # keep copy of notes to compatibility with previous docx models
|
|
202
210
|
end
|
|
203
211
|
end
|
|
@@ -212,9 +220,5 @@ module OoxmlParser
|
|
|
212
220
|
@settings = DocumentSettings.new(parent: self).parse
|
|
213
221
|
self
|
|
214
222
|
end
|
|
215
|
-
|
|
216
|
-
class << self
|
|
217
|
-
attr_accessor :default_table_run_style, :default_table_paragraph_style, :default_paragraph_style, :default_run_style
|
|
218
|
-
end
|
|
219
223
|
end
|
|
220
224
|
end
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
require_relative 'common_timing/condition_list'
|
|
4
4
|
module OoxmlParser
|
|
5
5
|
# Class for data of CommonTiming
|
|
6
|
-
class CommonTiming
|
|
6
|
+
class CommonTiming < OOXMLDocumentObject
|
|
7
7
|
attr_accessor :id, :duration, :restart, :children, :start_conditions, :end_conditions
|
|
8
8
|
|
|
9
9
|
def initialize(parent: nil)
|
|
10
10
|
@children = []
|
|
11
11
|
@start_conditions = []
|
|
12
12
|
@end_conditions = []
|
|
13
|
-
|
|
13
|
+
super(parent: parent)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Parse CommonTiming object
|
|
@@ -35,7 +35,7 @@ module OoxmlParser
|
|
|
35
35
|
when 'endCondLst'
|
|
36
36
|
@end_conditions = ConditionList.new(parent: self).parse(node_child)
|
|
37
37
|
when 'childTnLst'
|
|
38
|
-
@children =
|
|
38
|
+
@children = TimeNodeList.new(parent: self).parse(node_child).elements
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
self
|
|
@@ -29,31 +29,5 @@ module OoxmlParser
|
|
|
29
29
|
end
|
|
30
30
|
self
|
|
31
31
|
end
|
|
32
|
-
|
|
33
|
-
# Parse list of timing nodes
|
|
34
|
-
# @param timing_list_node [Nokogiri::XML::Element] node to parse
|
|
35
|
-
# @return [Array<TimeNode>] list of nodes
|
|
36
|
-
def self.parse_list(timing_list_node)
|
|
37
|
-
timings = []
|
|
38
|
-
timing_list_node.xpath('*').each do |time_node|
|
|
39
|
-
case time_node.name
|
|
40
|
-
when 'par'
|
|
41
|
-
timings << TimeNode.new(:parallel, parent: timings).parse(time_node)
|
|
42
|
-
when 'seq'
|
|
43
|
-
timings << TimeNode.new(:sequence, parent: timings).parse(time_node)
|
|
44
|
-
when 'anim'
|
|
45
|
-
timings << TimeNode.new(:animate, parent: timings).parse(time_node)
|
|
46
|
-
when 'set'
|
|
47
|
-
timings << SetTimeNode.new(parent: timings).parse(time_node)
|
|
48
|
-
when 'animEffect'
|
|
49
|
-
timings << AnimationEffect.new(parent: timings).parse(time_node)
|
|
50
|
-
when 'video'
|
|
51
|
-
timings << :video
|
|
52
|
-
when 'audio'
|
|
53
|
-
timings << TimeNode.new(:audio, parent: timings).parse(time_node)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
timings
|
|
57
|
-
end
|
|
58
32
|
end
|
|
59
33
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'time_node_list/time_node'
|
|
4
|
+
module OoxmlParser
|
|
5
|
+
# Class for parsing TimeNodeList object <p:tnLst>
|
|
6
|
+
class TimeNodeList < OOXMLDocumentObject
|
|
7
|
+
# @return [Array<Object>] list of elements
|
|
8
|
+
attr_reader :elements
|
|
9
|
+
|
|
10
|
+
def initialize(parent: nil)
|
|
11
|
+
@elements = []
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Parse TimeNodeList
|
|
16
|
+
# @param node [Nokogiri::XML::Element] node to parse
|
|
17
|
+
# @return [TimeNodeList] value of TimeNodeList
|
|
18
|
+
def parse(node)
|
|
19
|
+
node.xpath('*').each do |node_child|
|
|
20
|
+
case node_child.name
|
|
21
|
+
when 'par'
|
|
22
|
+
@elements << TimeNode.new(:parallel, parent: self).parse(node_child)
|
|
23
|
+
when 'seq'
|
|
24
|
+
@elements << TimeNode.new(:sequence, parent: self).parse(node_child)
|
|
25
|
+
when 'anim'
|
|
26
|
+
@elements << TimeNode.new(:animate, parent: self).parse(node_child)
|
|
27
|
+
when 'set'
|
|
28
|
+
@elements << SetTimeNode.new(parent: self).parse(node_child)
|
|
29
|
+
when 'animEffect'
|
|
30
|
+
@elements << AnimationEffect.new(parent: self).parse(node_child)
|
|
31
|
+
when 'video'
|
|
32
|
+
@elements << :video
|
|
33
|
+
when 'audio'
|
|
34
|
+
@elements << TimeNode.new(:audio, parent: self).parse(node_child)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative 'timing/
|
|
3
|
+
require_relative 'timing/time_node_list'
|
|
4
4
|
module OoxmlParser
|
|
5
5
|
# Class for parsing `timing`
|
|
6
6
|
class Timing < OOXMLDocumentObject
|
|
@@ -20,7 +20,7 @@ module OoxmlParser
|
|
|
20
20
|
node.xpath('*').each do |node_child|
|
|
21
21
|
case node_child.name
|
|
22
22
|
when 'tnLst'
|
|
23
|
-
@time_node_list =
|
|
23
|
+
@time_node_list = TimeNodeList.new(parent: self).parse(node_child).elements
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
self
|
data/lib/ooxml_parser/version.rb
CHANGED
|
@@ -54,19 +54,6 @@ module OoxmlParser
|
|
|
54
54
|
deprecate :from, 'min', 2099, 1
|
|
55
55
|
deprecate :to, 'max', 2099, 1
|
|
56
56
|
|
|
57
|
-
# Parse list of XlsxColumnProperties
|
|
58
|
-
# @param columns_width_node [Nokogiri::XML:Element] node to parse
|
|
59
|
-
# @param parent [OOXMLDocumentObject] parent of result objects
|
|
60
|
-
# @return [Array<XlsxColumnProperties>] list of XlsxColumnProperties
|
|
61
|
-
def self.parse_list(columns_width_node, parent: nil)
|
|
62
|
-
columns = []
|
|
63
|
-
columns_width_node.xpath('xmlns:col').each do |col_node|
|
|
64
|
-
col = XlsxColumnProperties.new(parent: parent).parse(col_node)
|
|
65
|
-
columns << col
|
|
66
|
-
end
|
|
67
|
-
columns
|
|
68
|
-
end
|
|
69
|
-
|
|
70
57
|
private
|
|
71
58
|
|
|
72
59
|
# TODO: Currently width calculation use some magick number from old time ago
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'xlsx_columns/xlsx_column_properties'
|
|
4
|
+
module OoxmlParser
|
|
5
|
+
# Class for parsing XlsxColumns object <cols>
|
|
6
|
+
class XlsxColumns < OOXMLDocumentObject
|
|
7
|
+
# @return [Array<XlsxColumnProperties>] list of elements
|
|
8
|
+
attr_reader :elements
|
|
9
|
+
|
|
10
|
+
def initialize(parent: nil)
|
|
11
|
+
@elements = []
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Parse XlsxColumns
|
|
16
|
+
# @param node [Nokogiri::XML::Element] node to parse
|
|
17
|
+
# @return [XlsxColumns] value of TimeNodeList
|
|
18
|
+
def parse(node)
|
|
19
|
+
node.xpath('*').each do |node_child|
|
|
20
|
+
case node_child.name
|
|
21
|
+
when 'col'
|
|
22
|
+
@elements << XlsxColumnProperties.new(parent: parent).parse(node_child)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -7,7 +7,7 @@ require_relative 'worksheet/sheet_format_properties'
|
|
|
7
7
|
require_relative 'worksheet/sheet_view'
|
|
8
8
|
require_relative 'worksheet/table_part'
|
|
9
9
|
require_relative 'worksheet/worksheet_helper'
|
|
10
|
-
require_relative 'worksheet/
|
|
10
|
+
require_relative 'worksheet/xlsx_columns'
|
|
11
11
|
require_relative 'worksheet/xlsx_drawing'
|
|
12
12
|
require_relative 'worksheet/xlsx_row'
|
|
13
13
|
require_relative 'worksheet/xlsx_header_footer'
|
|
@@ -119,7 +119,7 @@ module OoxmlParser
|
|
|
119
119
|
@hyperlinks << Hyperlink.new(parent: self).parse(hyperlink_node).dup
|
|
120
120
|
end
|
|
121
121
|
when 'cols'
|
|
122
|
-
@columns =
|
|
122
|
+
@columns = XlsxColumns.new(parent: self).parse(worksheet_node_child).elements
|
|
123
123
|
when 'autoFilter'
|
|
124
124
|
@autofilter = Autofilter.new(parent: self).parse(worksheet_node_child)
|
|
125
125
|
when 'tableParts'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ooxml_parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.36.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ONLYOFFICE
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-
|
|
13
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: nokogiri
|
|
@@ -54,146 +54,6 @@ dependencies:
|
|
|
54
54
|
- - "~>"
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
56
|
version: '2'
|
|
57
|
-
- !ruby/object:Gem::Dependency
|
|
58
|
-
name: overcommit
|
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
|
60
|
-
requirements:
|
|
61
|
-
- - "~>"
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
version: '0'
|
|
64
|
-
type: :development
|
|
65
|
-
prerelease: false
|
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
-
requirements:
|
|
68
|
-
- - "~>"
|
|
69
|
-
- !ruby/object:Gem::Version
|
|
70
|
-
version: '0'
|
|
71
|
-
- !ruby/object:Gem::Dependency
|
|
72
|
-
name: parallel_tests
|
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
|
74
|
-
requirements:
|
|
75
|
-
- - "~>"
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
version: '4'
|
|
78
|
-
type: :development
|
|
79
|
-
prerelease: false
|
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
81
|
-
requirements:
|
|
82
|
-
- - "~>"
|
|
83
|
-
- !ruby/object:Gem::Version
|
|
84
|
-
version: '4'
|
|
85
|
-
- !ruby/object:Gem::Dependency
|
|
86
|
-
name: rake
|
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
|
88
|
-
requirements:
|
|
89
|
-
- - "~>"
|
|
90
|
-
- !ruby/object:Gem::Version
|
|
91
|
-
version: '13'
|
|
92
|
-
type: :development
|
|
93
|
-
prerelease: false
|
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
95
|
-
requirements:
|
|
96
|
-
- - "~>"
|
|
97
|
-
- !ruby/object:Gem::Version
|
|
98
|
-
version: '13'
|
|
99
|
-
- !ruby/object:Gem::Dependency
|
|
100
|
-
name: rspec
|
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
|
102
|
-
requirements:
|
|
103
|
-
- - "~>"
|
|
104
|
-
- !ruby/object:Gem::Version
|
|
105
|
-
version: '3'
|
|
106
|
-
type: :development
|
|
107
|
-
prerelease: false
|
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
109
|
-
requirements:
|
|
110
|
-
- - "~>"
|
|
111
|
-
- !ruby/object:Gem::Version
|
|
112
|
-
version: '3'
|
|
113
|
-
- !ruby/object:Gem::Dependency
|
|
114
|
-
name: rubocop
|
|
115
|
-
requirement: !ruby/object:Gem::Requirement
|
|
116
|
-
requirements:
|
|
117
|
-
- - "~>"
|
|
118
|
-
- !ruby/object:Gem::Version
|
|
119
|
-
version: '1'
|
|
120
|
-
type: :development
|
|
121
|
-
prerelease: false
|
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
123
|
-
requirements:
|
|
124
|
-
- - "~>"
|
|
125
|
-
- !ruby/object:Gem::Version
|
|
126
|
-
version: '1'
|
|
127
|
-
- !ruby/object:Gem::Dependency
|
|
128
|
-
name: rubocop-performance
|
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
|
130
|
-
requirements:
|
|
131
|
-
- - "~>"
|
|
132
|
-
- !ruby/object:Gem::Version
|
|
133
|
-
version: '1'
|
|
134
|
-
type: :development
|
|
135
|
-
prerelease: false
|
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
137
|
-
requirements:
|
|
138
|
-
- - "~>"
|
|
139
|
-
- !ruby/object:Gem::Version
|
|
140
|
-
version: '1'
|
|
141
|
-
- !ruby/object:Gem::Dependency
|
|
142
|
-
name: rubocop-rake
|
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
|
144
|
-
requirements:
|
|
145
|
-
- - "~>"
|
|
146
|
-
- !ruby/object:Gem::Version
|
|
147
|
-
version: '0'
|
|
148
|
-
type: :development
|
|
149
|
-
prerelease: false
|
|
150
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
151
|
-
requirements:
|
|
152
|
-
- - "~>"
|
|
153
|
-
- !ruby/object:Gem::Version
|
|
154
|
-
version: '0'
|
|
155
|
-
- !ruby/object:Gem::Dependency
|
|
156
|
-
name: rubocop-rspec
|
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
|
158
|
-
requirements:
|
|
159
|
-
- - "~>"
|
|
160
|
-
- !ruby/object:Gem::Version
|
|
161
|
-
version: '2'
|
|
162
|
-
type: :development
|
|
163
|
-
prerelease: false
|
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
165
|
-
requirements:
|
|
166
|
-
- - "~>"
|
|
167
|
-
- !ruby/object:Gem::Version
|
|
168
|
-
version: '2'
|
|
169
|
-
- !ruby/object:Gem::Dependency
|
|
170
|
-
name: simplecov
|
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
|
172
|
-
requirements:
|
|
173
|
-
- - "~>"
|
|
174
|
-
- !ruby/object:Gem::Version
|
|
175
|
-
version: '0'
|
|
176
|
-
type: :development
|
|
177
|
-
prerelease: false
|
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
179
|
-
requirements:
|
|
180
|
-
- - "~>"
|
|
181
|
-
- !ruby/object:Gem::Version
|
|
182
|
-
version: '0'
|
|
183
|
-
- !ruby/object:Gem::Dependency
|
|
184
|
-
name: yard
|
|
185
|
-
requirement: !ruby/object:Gem::Requirement
|
|
186
|
-
requirements:
|
|
187
|
-
- - ">="
|
|
188
|
-
- !ruby/object:Gem::Version
|
|
189
|
-
version: 0.9.20
|
|
190
|
-
type: :development
|
|
191
|
-
prerelease: false
|
|
192
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
193
|
-
requirements:
|
|
194
|
-
- - ">="
|
|
195
|
-
- !ruby/object:Gem::Version
|
|
196
|
-
version: 0.9.20
|
|
197
57
|
description: Parse OOXML files (docx, xlsx, pptx)
|
|
198
58
|
email:
|
|
199
59
|
- shockwavenn@gmail.com
|
|
@@ -318,7 +178,7 @@ files:
|
|
|
318
178
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_spacing.rb
|
|
319
179
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_style_ref.rb
|
|
320
180
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing.rb
|
|
321
|
-
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/
|
|
181
|
+
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb
|
|
322
182
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs.rb
|
|
323
183
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
|
|
324
184
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb
|
|
@@ -488,14 +348,15 @@ files:
|
|
|
488
348
|
- lib/ooxml_parser/pptx_parser/presentation/slide/presentation_notes.rb
|
|
489
349
|
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/shapes_grouping.rb
|
|
490
350
|
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing.rb
|
|
491
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/
|
|
492
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/
|
|
493
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/set_time_node/behavior/
|
|
494
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/set_time_node/
|
|
495
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/
|
|
496
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node
|
|
497
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node/common_timing
|
|
498
|
-
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node/common_timing/
|
|
351
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list.rb
|
|
352
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/animation_effect/animation_effect.rb
|
|
353
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/set_time_node/behavior/behavior.rb
|
|
354
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/set_time_node/behavior/target_element.rb
|
|
355
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/set_time_node/set_time_node.rb
|
|
356
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/time_node.rb
|
|
357
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/time_node/common_timing.rb
|
|
358
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/time_node/common_timing/codition_list/condition.rb
|
|
359
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/time_node/common_timing/condition_list.rb
|
|
499
360
|
- lib/ooxml_parser/pptx_parser/presentation/slide/slide_helper.rb
|
|
500
361
|
- lib/ooxml_parser/pptx_parser/presentation/slide/transition/transition.rb
|
|
501
362
|
- lib/ooxml_parser/pptx_parser/presentation/slide/transition/transition/sound_action.rb
|
|
@@ -591,7 +452,8 @@ files:
|
|
|
591
452
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/table_columns/table_column.rb
|
|
592
453
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/table_style_info.rb
|
|
593
454
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/worksheet_helper.rb
|
|
594
|
-
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/
|
|
455
|
+
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_columns.rb
|
|
456
|
+
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_columns/xlsx_column_properties.rb
|
|
595
457
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_drawing.rb
|
|
596
458
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_drawing/client_data.rb
|
|
597
459
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb
|
|
@@ -625,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
625
487
|
- !ruby/object:Gem::Version
|
|
626
488
|
version: '0'
|
|
627
489
|
requirements: []
|
|
628
|
-
rubygems_version: 3.4.
|
|
490
|
+
rubygems_version: 3.4.13
|
|
629
491
|
signing_key:
|
|
630
492
|
specification_version: 4
|
|
631
493
|
summary: OoxmlParser Gem
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|