ooxml_parser 0.36.0 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8c7e158e72093d65c4d1b16f922e74a2247e56a59fee2f2927b78cc5f1db5f2
4
- data.tar.gz: c492e2f255c1333576ace90867e0ef05901737e84be8419eea65afdac7704fcc
3
+ metadata.gz: 87456a8bc9e65bfdc392bc011d85d926898a72fd1fd93b9df816ff9c17829e23
4
+ data.tar.gz: a1c31e373fe50d84c20a94921efa541b6aec385efb9985def44853c394a8f814
5
5
  SHA512:
6
- metadata.gz: b4e27b723b95306eb10460667885db44490f774bc386ae8dc73868ef3ad41ccf5c71c3b48cec2f0187a6fc56926eb9fd966180b141bf46706666dfe3c5934627
7
- data.tar.gz: 0b0fef55b19efde661e3c8440ba797fecc20c29465962d2cdd9daaf95c36b5149594d3376c6705a606ff8dac28cb9b9df5edb2abb77fa2b49e67af508025c40b
6
+ metadata.gz: bc5b0d1c069bd862ee61ee2043abe88e3862f509d12e3c5cdb1a3aabb6e40742ae4f16410911fd3a34d8babd21aa94c15bd4a072456b482f00e127a7c371a15d
7
+ data.tar.gz: 81cde9b66505385865c6a9c236e7c3bd49b7bb5265f260e8821675bff6e0df06c5b12fe190ba79d09f7c23c6158162d69963ba022a9746c7c67ed4880f991114
@@ -144,15 +144,15 @@ module OoxmlParser
144
144
  char_number += 1
145
145
  when 'hyperlink'
146
146
  @hyperlink = Hyperlink.new(parent: self).parse(node_child)
147
- hyperlink_run = default_character_style.dup
148
- hyperlink_run.parent = self
149
- if @hyperlink.id
150
- @hyperlink.parent = hyperlink_run
151
- hyperlink_run.link = @hyperlink
152
- elsif @hyperlink.anchor
153
- hyperlink_run.link = @hyperlink.anchor
154
- end
155
147
  node_child.xpath('w:r').each do |r_tag|
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
156
  hyperlink_run.parse(r_tag, char_number, parent: self)
157
157
  character_styles_array << hyperlink_run
158
158
  char_number += 1
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.36.0'
7
+ STRING = '0.37.0'
8
8
  end
9
9
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <dataField> tag
5
+ class DataField < OOXMLDocumentObject
6
+ # @return [Integer] index of the base field for the ShowDataAs calculation
7
+ attr_accessor :base_field
8
+ # @return [Integer] index of the base item for the ShowDataAs calculation
9
+ attr_accessor :base_item
10
+ # @return [Integer] index of the field in the pivotCacheRecords
11
+ attr_accessor :field
12
+ # @return [String] name of the data field
13
+ attr_reader :name
14
+ # @return [Integer] index of the number format applied to data field
15
+ attr_accessor :number_format_id
16
+ # @return [ExtensionList] list of extensions
17
+ attr_accessor :extension_list
18
+
19
+ # Parse `<dataField>` tag
20
+ # # @param [Nokogiri::XML:Element] node with DataField data
21
+ # @return [DataField]
22
+ def parse(node)
23
+ node.attributes.each do |key, value|
24
+ case key
25
+ when 'baseField'
26
+ @base_field = value.value.to_i
27
+ when 'baseItem'
28
+ @base_item = value.value.to_i
29
+ when 'fld'
30
+ @field = value.value.to_i
31
+ when 'name'
32
+ @name = value.value.to_s
33
+ when 'numFmtId'
34
+ @number_format_id = value.value.to_i
35
+ end
36
+ end
37
+
38
+ node.xpath('*').each do |node_child|
39
+ case node_child.name
40
+ when 'extLst'
41
+ @extension_list = ExtensionList.new(parent: self).parse(node_child)
42
+ end
43
+ end
44
+ self
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'data_fields/data_field'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <dataFields> tag
7
+ class DataFields < OOXMLDocumentObject
8
+ # @return [Integer] count
9
+ attr_reader :count
10
+ # @return [Array<DataField>] list of DataField object
11
+ attr_reader :data_field
12
+
13
+ def initialize(parent: nil)
14
+ @data_field = []
15
+ super
16
+ end
17
+
18
+ # @return [DataField] accessor
19
+ def [](key)
20
+ @data_field[key]
21
+ end
22
+
23
+ # Parse `<dataFields>` tag
24
+ # @param [Nokogiri::XML:Element] node with dataFields data
25
+ # @return [DataFields]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'dataField'
37
+ @data_field << DataField.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <pageField> tag
5
+ class PageField < OOXMLDocumentObject
6
+ # @return [Integer] index of the field
7
+ attr_accessor :field
8
+ # @return [Integer] index of the OLAP hierarchy
9
+ attr_reader :hierarchy
10
+
11
+ # Parse `<pageField>` tag
12
+ # # @param [Nokogiri::XML:Element] node with PageField data
13
+ # @return [PageField]
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'fld'
18
+ @field = value.value.to_i
19
+ when 'hier'
20
+ @hierarchy = value.value.to_i
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'page_fields/page_field'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <pageFields> tag
7
+ class PageFields < OOXMLDocumentObject
8
+ # @return [Integer] count
9
+ attr_reader :count
10
+ # @return [Array<PageField>] list of PageField object
11
+ attr_reader :page_field
12
+
13
+ def initialize(parent: nil)
14
+ @page_field = []
15
+ super
16
+ end
17
+
18
+ # @return [PageField] accessor
19
+ def [](key)
20
+ @page_field[key]
21
+ end
22
+
23
+ # Parse `<pageFields>` tag
24
+ # @param [Nokogiri::XML:Element] node with pageFields data
25
+ # @return [PageFields]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'pageField'
37
+ @page_field << PageField.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <field> tag
5
+ class Field < OOXMLDocumentObject
6
+ # @return [Integer] the index to a pivotField item value
7
+ attr_accessor :field_index
8
+
9
+ # Parse `<field>` tag
10
+ # # @param [Nokogiri::XML:Element] node with Field data
11
+ # @return [Field]
12
+ def parse(node)
13
+ node.attributes.each do |key, value|
14
+ case key
15
+ when 'x'
16
+ @field_index = value.value.to_i
17
+ end
18
+ end
19
+ self
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'row_fields/field'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <rowFields> tag
7
+ class RowFields < OOXMLDocumentObject
8
+ # @return [Integer] count
9
+ attr_reader :count
10
+ # @return [Array<Field>] list of Field object
11
+ attr_reader :fields
12
+
13
+ def initialize(parent: nil)
14
+ @fields = []
15
+ super
16
+ end
17
+
18
+ # @return [Field] accessor
19
+ def [](key)
20
+ @fields[key]
21
+ end
22
+
23
+ # Parse `<rowFields>` tag
24
+ # @param [Nokogiri::XML:Element] node with rowFields data
25
+ # @return [RowFields]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'field'
37
+ @fields << Field.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -4,6 +4,9 @@ require_relative 'pivot_table_definition/column_row_items'
4
4
  require_relative 'pivot_table_definition/location'
5
5
  require_relative 'pivot_table_definition/pivot_fields'
6
6
  require_relative 'pivot_table_definition/pivot_table_style_info'
7
+ require_relative 'pivot_table_definition/data_fields'
8
+ require_relative 'pivot_table_definition/page_fields'
9
+ require_relative 'pivot_table_definition/row_fields'
7
10
 
8
11
  module OoxmlParser
9
12
  # Class for parsing <PivotTableDefinition> tag
@@ -50,6 +53,14 @@ module OoxmlParser
50
53
  attr_reader :row_items
51
54
  # @return [PivotTableStyleInfo] style info
52
55
  attr_reader :style_info
56
+ # @return [DataFields] data fields
57
+ attr_reader :data_fields
58
+ # @return [PageFields] page fields
59
+ attr_reader :page_fields
60
+ # @return [RowFields] row fields
61
+ attr_reader :row_fields
62
+ # @return [RowFields] column fields
63
+ attr_reader :column_fields
53
64
 
54
65
  # Parse PivotTableDefinition object
55
66
  # @param [String] file path
@@ -106,6 +117,14 @@ module OoxmlParser
106
117
  @column_items = ColumnRowItems.new(parent: self).parse(node_child)
107
118
  when 'pivotTableStyleInfo'
108
119
  @style_info = PivotTableStyleInfo.new(parent: self).parse(node_child)
120
+ when 'dataFields'
121
+ @data_fields = DataFields.new(parent: self).parse(node_child)
122
+ when 'pageFields'
123
+ @page_fields = PageFields.new(parent: self).parse(node_child)
124
+ when 'rowFields'
125
+ @row_fields = RowFields.new(parent: self).parse(node_child)
126
+ when 'colFields'
127
+ @column_fields = RowFields.new(parent: self).parse(node_child)
109
128
  end
110
129
  end
111
130
  self
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for `x14:dataField` data
5
+ class X14DataField < OOXMLDocumentObject
6
+ # @return [Symbol] pivot show as type
7
+ attr_reader :pivot_show_as
8
+
9
+ # Parse X14DataField data
10
+ # @param [Nokogiri::XML:Element] node with X14DataField data
11
+ # @return [X14Table] value of X14DataField data
12
+ def parse(node)
13
+ node.attributes.each do |key, value|
14
+ case key
15
+ when 'pivotShowAs'
16
+ @pivot_show_as = value.value.to_sym
17
+ end
18
+ end
19
+ self
20
+ end
21
+ end
22
+ end
@@ -4,6 +4,7 @@ require_relative 'extension/data_validations'
4
4
  require_relative 'extension/sparkline_groups'
5
5
  require_relative 'extension/x14_table'
6
6
  require_relative 'extension/conditional_formattings'
7
+ require_relative 'extension/x14_data_field'
7
8
  module OoxmlParser
8
9
  # Class for `ext` data
9
10
  class Extension < OOXMLDocumentObject
@@ -15,6 +16,8 @@ module OoxmlParser
15
16
  attr_accessor :table
16
17
  # @return [SparklineGroups] list of groups
17
18
  attr_reader :sparkline_groups
19
+ # @return [X14DataField] pivot data field in x14 namespace
20
+ attr_accessor :data_field
18
21
 
19
22
  # Parse Extension data
20
23
  # @param [Nokogiri::XML:Element] node with Extension data
@@ -30,6 +33,8 @@ module OoxmlParser
30
33
  @table = X14Table.new(parent: self).parse(column_node)
31
34
  when 'sparklineGroups'
32
35
  @sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
36
+ when 'dataField'
37
+ @data_field = X14DataField.new(parent: self).parse(column_node)
33
38
  end
34
39
  end
35
40
  self
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.36.0
4
+ version: 0.37.0
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-05-10 00:00:00.000000000 Z
13
+ date: 2023-06-20 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
@@ -524,12 +384,18 @@ files:
524
384
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb
525
385
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/column_row_items.rb
526
386
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/column_row_items/column_row_item.rb
387
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields.rb
388
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb
527
389
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/location.rb
390
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/page_fields.rb
391
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/page_fields/page_field.rb
528
392
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields.rb
529
393
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field.rb
530
394
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
531
395
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items/item.rb
532
396
  - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_table_style_info.rb
397
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb
398
+ - lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields/field.rb
533
399
  - lib/ooxml_parser/xlsx_parser/workbook/shared_string_table.rb
534
400
  - lib/ooxml_parser/xlsx_parser/workbook/shared_string_table/string_index.rb
535
401
  - lib/ooxml_parser/xlsx_parser/workbook/sheet.rb
@@ -587,6 +453,7 @@ files:
587
453
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group.rb
588
454
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group/sparklines.rb
589
455
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group/sparklines/sparkline.rb
456
+ - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/x14_data_field.rb
590
457
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/x14_table.rb
591
458
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/table_columns.rb
592
459
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/table_columns/table_column.rb
@@ -627,7 +494,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
627
494
  - !ruby/object:Gem::Version
628
495
  version: '0'
629
496
  requirements: []
630
- rubygems_version: 3.4.13
497
+ rubygems_version: 3.4.14
631
498
  signing_key:
632
499
  specification_version: 4
633
500
  summary: OoxmlParser Gem