ooxml_parser 0.37.1 → 0.39.0
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_legend.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +10 -11
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb +28 -27
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb +3 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb +5 -5
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_spacing.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +9 -1
- data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +2 -1
- data/lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb +12 -0
- data/lib/ooxml_parser/docx_parser/document_structure/comments_extended/comment_extended.rb +4 -0
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide/timing/time_node_list/time_node/common_timing.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/presentation/slide/slide_helper.rb +3 -2
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/user_protected_ranges.rb +32 -0
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension.rb +5 -0
- data/lib/ooxml_parser.rb +1 -0
- data/lib/truffleruby_patch.rb +12 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064ea9325ec10b0d22eeaf5774ffc480746f739ab78d5580eda00f05499e7111
|
4
|
+
data.tar.gz: 71aace963676dec9978977537985b8e9d834cca7ad8e6f7a4a5b24736694d287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0205f6ce29895ba3597afab6184ce8959515c4997dce7ffcbca329c98c6fc394eec73a5b0f05e66e0c5b240b41eefa4dba7fdc4b06c2dd6f0218cb273792840
|
7
|
+
data.tar.gz: de025b3b50f9dd8cf5151861d6767f799bb993e7de46afe003c60957f79d1a03223488d0e78a13605a29adcde415511c1d780d137924cdf43c4f08c2e12b8a03
|
@@ -16,7 +16,7 @@ module OoxmlParser
|
|
16
16
|
# If there is overlay - return :right_overlay
|
17
17
|
# @return [Symbol] overlay and position type
|
18
18
|
def position_with_overlay
|
19
|
-
return "#{@position}_overlay"
|
19
|
+
return :"#{@position}_overlay" if overlay
|
20
20
|
|
21
21
|
@position
|
22
22
|
end
|
@@ -4,9 +4,9 @@ module OoxmlParser
|
|
4
4
|
# Class for working with coordinates
|
5
5
|
class Coordinates
|
6
6
|
# @return [Regexp] regexp for row name
|
7
|
-
ROW_REGEXP = /[a-z]/i
|
7
|
+
ROW_REGEXP = /[a-z]/i
|
8
8
|
# @return [Regexp] regexp for column name
|
9
|
-
COLUMN_REGEXP = /\d
|
9
|
+
COLUMN_REGEXP = /\d/
|
10
10
|
|
11
11
|
attr_accessor :row, :column, :list
|
12
12
|
|
@@ -28,8 +28,9 @@ module OoxmlParser
|
|
28
28
|
sheet_name = 'Sheet1'
|
29
29
|
|
30
30
|
if arguments_string.include?('!')
|
31
|
-
|
32
|
-
|
31
|
+
split_by_exclamation = arguments_string.split('!', 2)
|
32
|
+
sheet_name = "#{split_by_exclamation[0]}!"
|
33
|
+
arguments_string = split_by_exclamation[1]
|
33
34
|
end
|
34
35
|
|
35
36
|
range = arguments_string.split(':')
|
@@ -71,12 +72,10 @@ module OoxmlParser
|
|
71
72
|
# @param arguments_string [String] string
|
72
73
|
# @return [Array] result
|
73
74
|
def parse_coordinates_array(arguments_string)
|
74
|
-
result = []
|
75
75
|
coord_array = arguments_string.split(',')
|
76
|
-
coord_array.
|
77
|
-
|
76
|
+
coord_array.map do |current_coord|
|
77
|
+
parser_coordinates_range(current_coord)
|
78
78
|
end
|
79
|
-
result
|
80
79
|
end
|
81
80
|
|
82
81
|
# This method check is argument contains coordinate
|
@@ -113,8 +112,8 @@ module OoxmlParser
|
|
113
112
|
# This method takes @column string
|
114
113
|
# and converts into integer
|
115
114
|
def column_number
|
116
|
-
@column.reverse.each_char.reduce(0) do |result, char|
|
117
|
-
result + ((char.downcase.ord - 96) * (26
|
115
|
+
@column.reverse.each_char.with_index.reduce(0) do |result, (char, idx)|
|
116
|
+
result + ((char.downcase.ord - 96) * (26**idx))
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
@@ -134,7 +133,7 @@ module OoxmlParser
|
|
134
133
|
|
135
134
|
# @return [String] result of convert of object to string
|
136
135
|
def to_s
|
137
|
-
"#{@column}#{@row} #{
|
136
|
+
"#{@column}#{@row} #{"list: #{@list}" if @list}"
|
138
137
|
end
|
139
138
|
|
140
139
|
def nil?
|
@@ -3,33 +3,7 @@
|
|
3
3
|
module OoxmlParser
|
4
4
|
# Module for helper methods for OOXMLDocumentObject
|
5
5
|
module OoxmlDocumentObjectHelper
|
6
|
-
# Convert
|
7
|
-
# @return [Hash]
|
8
|
-
def to_hash
|
9
|
-
result_hash = {}
|
10
|
-
instance_variables.each do |current_attribute|
|
11
|
-
next if current_attribute == :@parent
|
12
|
-
|
13
|
-
attribute_value = instance_variable_get(current_attribute)
|
14
|
-
next unless attribute_value
|
15
|
-
|
16
|
-
if attribute_value.is_a?(Array)
|
17
|
-
attribute_value.each_with_index do |object_element, index|
|
18
|
-
result_hash["#{current_attribute}_#{index}".to_sym] = object_element.to_hash
|
19
|
-
end
|
20
|
-
else
|
21
|
-
result_hash[current_attribute.to_sym] = if attribute_value.respond_to?(:to_hash)
|
22
|
-
attribute_value.to_hash
|
23
|
-
else
|
24
|
-
attribute_value.to_s
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
result_hash
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
6
|
+
# @return [Hash] Hash to Convert value to human readable symbol
|
33
7
|
VALUE_TO_SYMBOL_HASH = { l: :left,
|
34
8
|
ctr: :center,
|
35
9
|
r: :right,
|
@@ -98,6 +72,33 @@ module OoxmlParser
|
|
98
72
|
rnd: :round,
|
99
73
|
sq: :square }.freeze
|
100
74
|
|
75
|
+
# Convert object to hash
|
76
|
+
# @return [Hash]
|
77
|
+
def to_hash
|
78
|
+
result_hash = {}
|
79
|
+
instance_variables.each do |current_attribute|
|
80
|
+
next if current_attribute == :@parent
|
81
|
+
|
82
|
+
attribute_value = instance_variable_get(current_attribute)
|
83
|
+
next unless attribute_value
|
84
|
+
|
85
|
+
if attribute_value.is_a?(Array)
|
86
|
+
attribute_value.each_with_index do |object_element, index|
|
87
|
+
result_hash[:"#{current_attribute}_#{index}"] = object_element.to_hash
|
88
|
+
end
|
89
|
+
else
|
90
|
+
result_hash[current_attribute.to_sym] = if attribute_value.respond_to?(:to_hash)
|
91
|
+
attribute_value.to_hash
|
92
|
+
else
|
93
|
+
attribute_value.to_s
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
result_hash
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
101
102
|
# Convert value to human readable symbol
|
102
103
|
# @param [String] value to convert
|
103
104
|
# @return [Symbol]
|
@@ -46,10 +46,11 @@ module OoxmlParser
|
|
46
46
|
@i_level.value
|
47
47
|
end
|
48
48
|
|
49
|
+
# @param [Integer] i_level to find, current one by default
|
49
50
|
# @return [AbstractNumbering] level list of current numbering
|
50
|
-
def numbering_level_current
|
51
|
+
def numbering_level_current(i_level = ilvl)
|
51
52
|
abstruct_numbering.level_list.each do |current_ilvl|
|
52
|
-
return current_ilvl if current_ilvl.ilvl ==
|
53
|
+
return current_ilvl if current_ilvl.ilvl == i_level
|
53
54
|
end
|
54
55
|
nil
|
55
56
|
end
|
data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
CHANGED
@@ -19,11 +19,11 @@ module OoxmlParser
|
|
19
19
|
# @return [Symbol] type of border in visual editor
|
20
20
|
def border_visual_type
|
21
21
|
result = []
|
22
|
-
result << :left if @left.val == :single
|
23
|
-
result << :right if @right.val == :single
|
24
|
-
result << :top if @top.val == :single
|
25
|
-
result << :bottom if @bottom.val == :single
|
26
|
-
result << :inner if @between.val == :single
|
22
|
+
result << :left if @left && @left.val == :single
|
23
|
+
result << :right if @right && @right.val == :single
|
24
|
+
result << :top if @top && @top.val == :single
|
25
|
+
result << :bottom if @bottom && @bottom.val == :single
|
26
|
+
result << :inner if @between && @between.val == :single
|
27
27
|
return :none if result == []
|
28
28
|
return :all if result == %i[left right top bottom inner]
|
29
29
|
return :outer if result == %i[left right top bottom]
|
data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_spacing.rb
CHANGED
@@ -44,7 +44,7 @@ module OoxmlParser
|
|
44
44
|
# @return [Hash] hash with sorted values
|
45
45
|
# TODO: Totally redone parsing of spacing to remove this workaround
|
46
46
|
def sorted_attributes(node)
|
47
|
-
node.attributes.sort.reverse
|
47
|
+
node.attributes.sort.reverse!.to_h
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -20,9 +20,17 @@ module OoxmlParser
|
|
20
20
|
|
21
21
|
TABLE_STYLES_NAMES_HASH.each do |key, value|
|
22
22
|
define_method(key) do
|
23
|
+
found = nil
|
23
24
|
@table_style_properties_list.each do |table_style|
|
24
|
-
|
25
|
+
# Cannot just use return in block
|
26
|
+
# because of TruffleRuby bug (cause LocalJumpError)
|
27
|
+
# https://github.com/oracle/truffleruby/issues/2438
|
28
|
+
if table_style.type == value
|
29
|
+
found = table_style
|
30
|
+
break
|
31
|
+
end
|
25
32
|
end
|
33
|
+
found
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
@@ -3,8 +3,14 @@
|
|
3
3
|
module OoxmlParser
|
4
4
|
# Comment Data
|
5
5
|
class Comment < OOXMLDocumentObject
|
6
|
+
# @return [String] name of the author
|
7
|
+
attr_reader :author
|
8
|
+
# @return [String] date of the comment, in string, not parsed
|
9
|
+
attr_reader :date_string
|
6
10
|
# @return [Integer] id of comment
|
7
11
|
attr_reader :id
|
12
|
+
# @return [String] initials of the author
|
13
|
+
attr_reader :initials
|
8
14
|
# @return [Array<DocxParagraph>] array of paragraphs
|
9
15
|
attr_reader :paragraphs
|
10
16
|
|
@@ -20,8 +26,14 @@ module OoxmlParser
|
|
20
26
|
def parse(node)
|
21
27
|
node.attributes.each do |key, value|
|
22
28
|
case key
|
29
|
+
when 'author'
|
30
|
+
@author = value.value.to_s
|
31
|
+
when 'date'
|
32
|
+
@date_string = value.value.to_s
|
23
33
|
when 'id'
|
24
34
|
@id = value.value.to_i
|
35
|
+
when 'initials'
|
36
|
+
@initials = value.value.to_s
|
25
37
|
end
|
26
38
|
end
|
27
39
|
|
@@ -5,6 +5,8 @@ module OoxmlParser
|
|
5
5
|
class CommentExtended < OOXMLDocumentObject
|
6
6
|
# @return [Integer] id of paragraph
|
7
7
|
attr_accessor :paragraph_id
|
8
|
+
# @return [Integer] id of parent paragraph
|
9
|
+
attr_reader :parent_paragraph_id
|
8
10
|
# @return [True, False] is done?
|
9
11
|
attr_accessor :done
|
10
12
|
|
@@ -16,6 +18,8 @@ module OoxmlParser
|
|
16
18
|
case key
|
17
19
|
when 'paraId'
|
18
20
|
@paragraph_id = value.value.to_i
|
21
|
+
when 'paraIdParent'
|
22
|
+
@parent_paragraph_id = value.value.to_i
|
19
23
|
when 'done'
|
20
24
|
@done = attribute_enabled?(value.value)
|
21
25
|
end
|
@@ -37,7 +37,7 @@ module OoxmlParser
|
|
37
37
|
transform = transform_of_object(object)
|
38
38
|
return :left if transform.offset.x.zero?
|
39
39
|
return :center if OoxmlSize.new((slide_size.width.value / 2) - (transform.extents.x.value / 2)) == OoxmlSize.new(transform.offset.x.value)
|
40
|
-
return :right if OoxmlSize.new(
|
40
|
+
return :right if OoxmlSize.new(slide_size.width.value - transform.extents.x.value) == OoxmlSize.new(transform.offset.x.value)
|
41
41
|
|
42
42
|
:unknown
|
43
43
|
end
|
@@ -62,7 +62,8 @@ module OoxmlParser
|
|
62
62
|
def content_distribute(object, slide_size)
|
63
63
|
return %i[horizontally vertically] if content_horizontal_align(object, slide_size) == :center && content_vertical_align(object, slide_size) == :middle
|
64
64
|
return [:horizontally] if content_horizontal_align(object, slide_size) == :center
|
65
|
-
|
65
|
+
|
66
|
+
[:vertically] if content_vertical_align(object, slide_size) == :middle
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for `UserProtectedRanges` data
|
5
|
+
class UserProtectedRanges < OOXMLDocumentObject
|
6
|
+
# @return [Array<ProtectedRange>] list of UserProtectedRange grodateup
|
7
|
+
attr_reader :user_protected_ranges
|
8
|
+
|
9
|
+
def initialize(parent: nil)
|
10
|
+
@user_protected_ranges = []
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [UserProtectedRange] accessor
|
15
|
+
def [](key)
|
16
|
+
user_protected_ranges[key]
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parse UserProtectedRanges data
|
20
|
+
# @param [Nokogiri::XML:Element] node with UserProtectedRanges data
|
21
|
+
# @return [UserProtectedRange] value of UserProtectedRanges data
|
22
|
+
def parse(node)
|
23
|
+
node.xpath('*').each do |range_node|
|
24
|
+
case range_node.name
|
25
|
+
when 'userProtectedRange'
|
26
|
+
@user_protected_ranges << ProtectedRange.new(parent: self).parse(range_node)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -5,6 +5,7 @@ require_relative 'extension/sparkline_groups'
|
|
5
5
|
require_relative 'extension/x14_table'
|
6
6
|
require_relative 'extension/conditional_formattings'
|
7
7
|
require_relative 'extension/x14_data_field'
|
8
|
+
require_relative 'extension/user_protected_ranges'
|
8
9
|
module OoxmlParser
|
9
10
|
# Class for `ext` data
|
10
11
|
class Extension < OOXMLDocumentObject
|
@@ -18,6 +19,8 @@ module OoxmlParser
|
|
18
19
|
attr_reader :sparkline_groups
|
19
20
|
# @return [X14DataField] pivot data field in x14 namespace
|
20
21
|
attr_accessor :data_field
|
22
|
+
# @return [UserProtectedRanges] list of user protected ranges
|
23
|
+
attr_reader :user_protected_ranges
|
21
24
|
|
22
25
|
# Parse Extension data
|
23
26
|
# @param [Nokogiri::XML:Element] node with Extension data
|
@@ -35,6 +38,8 @@ module OoxmlParser
|
|
35
38
|
@sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
|
36
39
|
when 'dataField'
|
37
40
|
@data_field = X14DataField.new(parent: self).parse(column_node)
|
41
|
+
when 'userProtectedRanges'
|
42
|
+
@user_protected_ranges = UserProtectedRanges.new(parent: self).parse(column_node)
|
38
43
|
end
|
39
44
|
end
|
40
45
|
self
|
data/lib/ooxml_parser.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Monkey patch around
|
4
|
+
# https://github.com/oracle/truffleruby/commit/cc76155bf509587e1b2954e9de77c558c7c857f4
|
5
|
+
# Remove it as soon as TruffleRuby with fix is released
|
6
|
+
if defined?(Truffle)
|
7
|
+
# MonkeyPatch File stdlib class
|
8
|
+
class File < IO
|
9
|
+
# Monkey patch constant missing on TruffleRuby
|
10
|
+
SHARE_DELETE = 0
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooxml_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.39.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
8
8
|
- Pavel Lobashov
|
9
9
|
- Roman Zagudaev
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: nokogiri
|
@@ -453,6 +452,7 @@ files:
|
|
453
452
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group.rb
|
454
453
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group/sparklines.rb
|
455
454
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group/sparklines/sparkline.rb
|
455
|
+
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/user_protected_ranges.rb
|
456
456
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/x14_data_field.rb
|
457
457
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/x14_table.rb
|
458
458
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/table_columns.rb
|
@@ -469,6 +469,7 @@ files:
|
|
469
469
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row.rb
|
470
470
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb
|
471
471
|
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb
|
472
|
+
- lib/truffleruby_patch.rb
|
472
473
|
homepage: https://github.com/onlyoffice/ooxml_parser
|
473
474
|
licenses:
|
474
475
|
- AGPL-3.0
|
@@ -479,7 +480,6 @@ metadata:
|
|
479
480
|
homepage_uri: https://github.com/onlyoffice/ooxml_parser
|
480
481
|
source_code_uri: https://github.com/onlyoffice/ooxml_parser
|
481
482
|
rubygems_mfa_required: 'true'
|
482
|
-
post_install_message:
|
483
483
|
rdoc_options: []
|
484
484
|
require_paths:
|
485
485
|
- lib
|
@@ -487,15 +487,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
487
487
|
requirements:
|
488
488
|
- - ">="
|
489
489
|
- !ruby/object:Gem::Version
|
490
|
-
version: '
|
490
|
+
version: '3.1'
|
491
491
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
492
492
|
requirements:
|
493
493
|
- - ">="
|
494
494
|
- !ruby/object:Gem::Version
|
495
495
|
version: '0'
|
496
496
|
requirements: []
|
497
|
-
rubygems_version: 3.
|
498
|
-
signing_key:
|
497
|
+
rubygems_version: 3.6.9
|
499
498
|
specification_version: 4
|
500
499
|
summary: OoxmlParser Gem
|
501
500
|
test_files: []
|