ooxml_parser 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +14 -0
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +15 -0
- data/lib/ooxml_parser/common_parser/parser.rb +2 -1
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/protection.rb +32 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/workbook_protection.rb +38 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/protected_range.rb +42 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_protection.rb +117 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/client_data.rb +27 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +13 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +12 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18fbe0fd1cdc17b4fa15edd44442ab0aab56a6620ba4539635b4e8c2d676b3c
|
4
|
+
data.tar.gz: de14faa95be23f0a4dc6fa9541adf184fed69bc769f837d30a2fd63321f7b765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65800c4573bb1859c02d5795c0e45b6bd50b07349aaeba24e3c1565e09022f0a25c3ddff43780cb7642b02c76343ad929e3304e4bb4a75d555158c47ff47537e
|
7
|
+
data.tar.gz: b67e977b6af0047b52d2dce951fc57335bb80758bfd0a5188a9afa30a343ac408bcd227d41d14e0481e2ff4c3ae10dda283160dcd72962994f193aa69d8f59f4
|
@@ -10,9 +10,16 @@ module OoxmlParser
|
|
10
10
|
# Class for parsing `sp`, `wsp` tags
|
11
11
|
class DocxShape < OOXMLDocumentObject
|
12
12
|
attr_accessor :non_visual_properties, :properties, :style, :body_properties, :text_body
|
13
|
+
# @return [True, False] Specifies if text in shape is locked when sheet is protected
|
14
|
+
attr_reader :locks_text
|
13
15
|
|
14
16
|
alias shape_properties properties
|
15
17
|
|
18
|
+
def initialize(parent: nil)
|
19
|
+
@locks_text = true
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
16
23
|
# @return [True, false] if structure contain any user data
|
17
24
|
def with_data?
|
18
25
|
return true if @text_body.nil?
|
@@ -27,6 +34,13 @@ module OoxmlParser
|
|
27
34
|
# @param node [Nokogiri::XML:Element] node to parse
|
28
35
|
# @return [DocxShape] result of parsing
|
29
36
|
def parse(node)
|
37
|
+
node.attributes.each do |key, value|
|
38
|
+
case key
|
39
|
+
when 'fLocksText'
|
40
|
+
@locks_text = attribute_enabled?(value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
30
44
|
node.xpath('*').each do |node_child|
|
31
45
|
case node_child.name
|
32
46
|
when 'nvSpPr'
|
@@ -4,6 +4,7 @@ require 'filemagic' unless Gem.win_platform?
|
|
4
4
|
require 'securerandom'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'zip'
|
7
|
+
require 'ooxml_decrypt'
|
7
8
|
require_relative 'ooxml_document_object/nokogiri_parsing_exception'
|
8
9
|
require_relative 'ooxml_document_object/ooxml_document_object_helper'
|
9
10
|
require_relative 'ooxml_document_object/ooxml_object_attribute_helper'
|
@@ -95,6 +96,20 @@ module OoxmlParser
|
|
95
96
|
file_path
|
96
97
|
end
|
97
98
|
|
99
|
+
# Decrypt file protected with password
|
100
|
+
# @param path [String] path to file
|
101
|
+
# @param password [String] password to file
|
102
|
+
# @return [String] path to decrypted file
|
103
|
+
def decrypt_file(path, password)
|
104
|
+
file_name = File.basename(path)
|
105
|
+
tmp_folder = Dir.mktmpdir('ruby-ooxml-parser')
|
106
|
+
decrypted_path = "#{tmp_folder}/#{file_name}"
|
107
|
+
binary_password = password.encode('utf-16le').bytes.pack('c*').encode('binary')
|
108
|
+
OoxmlDecrypt::EncryptedFile.decrypt_to_file(path, binary_password, decrypted_path)
|
109
|
+
|
110
|
+
decrypted_path
|
111
|
+
end
|
112
|
+
|
98
113
|
# Unzip specified file
|
99
114
|
# @param path_to_file [String] path to zip file
|
100
115
|
# @param destination [String] folder to extract
|
@@ -21,7 +21,8 @@ module OoxmlParser
|
|
21
21
|
# Base method to parse document of any type
|
22
22
|
# @param path_to_file [String] file
|
23
23
|
# @return [CommonDocumentStructure] structure of doc
|
24
|
-
def self.parse(path_to_file)
|
24
|
+
def self.parse(path_to_file, password: nil)
|
25
|
+
path_to_file = OOXMLDocumentObject.decrypt_file(path_to_file, password) if password
|
25
26
|
Parser.parse_format(path_to_file) do
|
26
27
|
format = Parser.recognize_folder_format
|
27
28
|
case format
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <protection> tag
|
5
|
+
class Protection < OOXMLDocumentObject
|
6
|
+
# @return [True, False] Specifies if cell is locked
|
7
|
+
attr_reader :locked
|
8
|
+
# @return [True, False] Specifies if formulas in cell are hidden
|
9
|
+
attr_reader :hidden
|
10
|
+
|
11
|
+
def initialize(parent: nil)
|
12
|
+
@locked = true
|
13
|
+
@hidden = false
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# Parse Protection data
|
18
|
+
# @param [Nokogiri::XML:Element] node with Protection data
|
19
|
+
# @return [Sheet] value of Protection
|
20
|
+
def parse(node)
|
21
|
+
node.attributes.each do |key, value|
|
22
|
+
case key
|
23
|
+
when 'locked'
|
24
|
+
@locked = attribute_enabled?(value)
|
25
|
+
when 'hidden'
|
26
|
+
@hidden = attribute_enabled?(value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'cell_style/alignment'
|
4
|
+
require_relative 'cell_style/protection'
|
4
5
|
module OoxmlParser
|
5
6
|
# Class for parsing `xf` object
|
6
7
|
class Xf < OOXMLDocumentObject
|
@@ -76,6 +77,8 @@ module OoxmlParser
|
|
76
77
|
attr_reader :fill_id
|
77
78
|
# @return [Integer] id of number format
|
78
79
|
attr_reader :number_format_id
|
80
|
+
# @return [Protection] Settings of cell protection
|
81
|
+
attr_reader :protection
|
79
82
|
|
80
83
|
def initialize(parent: nil)
|
81
84
|
@numerical_format = 'General'
|
@@ -115,6 +118,8 @@ module OoxmlParser
|
|
115
118
|
case node_child.name
|
116
119
|
when 'alignment'
|
117
120
|
@alignment.parse(node_child) if @apply_alignment
|
121
|
+
when 'protection'
|
122
|
+
@protection = Protection.new(parent: self).parse(node_child)
|
118
123
|
end
|
119
124
|
end
|
120
125
|
self
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <workbookProtection> tag
|
5
|
+
class WorkbookProtection < OOXMLDocumentObject
|
6
|
+
# @return [True, False] Specifies if workbook structure is protected
|
7
|
+
attr_reader :lock_structure
|
8
|
+
# @return [String] name of hashing algorithm
|
9
|
+
attr_reader :workbook_algorithm_name
|
10
|
+
# @return [String] hash value for the password
|
11
|
+
attr_reader :workbook_hash_value
|
12
|
+
# @return [String] salt value for the password
|
13
|
+
attr_reader :workbook_salt_value
|
14
|
+
# @return [Integer] number of times the hashing function shall be iteratively run
|
15
|
+
attr_reader :workbook_spin_count
|
16
|
+
|
17
|
+
# Parse WorkbookProtection data
|
18
|
+
# @param [Nokogiri::XML:Element] node with WorkbookProtection data
|
19
|
+
# @return [Sheet] value of WorkbookProtection
|
20
|
+
def parse(node)
|
21
|
+
node.attributes.each do |key, value|
|
22
|
+
case key
|
23
|
+
when 'lockStructure'
|
24
|
+
@lock_structure = attribute_enabled?(value)
|
25
|
+
when 'workbookAlgorithmName'
|
26
|
+
@workbook_algorithm_name = value.value.to_s
|
27
|
+
when 'workbookHashValue'
|
28
|
+
@workbook_hash_value = value.value.to_s
|
29
|
+
when 'workbookSaltValue'
|
30
|
+
@workbook_salt_value = value.value.to_s
|
31
|
+
when 'workbookSpinCount'
|
32
|
+
@workbook_spin_count = value.value.to_i
|
33
|
+
end
|
34
|
+
end
|
35
|
+
self
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <protectedRange> tag
|
5
|
+
class ProtectedRange < OOXMLDocumentObject
|
6
|
+
# @return [String] Name of hashing algorithm
|
7
|
+
attr_reader :algorithm_name
|
8
|
+
# @return [String] Hash value for the password
|
9
|
+
attr_reader :hash_value
|
10
|
+
# @return [String] Salt value for the password
|
11
|
+
attr_reader :salt_value
|
12
|
+
# @return [Integer] Number of times the hashing function shall be iteratively run
|
13
|
+
attr_reader :spin_count
|
14
|
+
# @return [String] Name of protected range
|
15
|
+
attr_accessor :name
|
16
|
+
# @return [String] Range reference
|
17
|
+
attr_reader :reference_sequence
|
18
|
+
|
19
|
+
# Parse ProtectedRange data
|
20
|
+
# @param [Nokogiri::XML:Element] node with ProtectedRange data
|
21
|
+
# @return [Sheet] value of ProtectedRange
|
22
|
+
def parse(node)
|
23
|
+
node.attributes.each do |key, value|
|
24
|
+
case key
|
25
|
+
when 'algorithmName'
|
26
|
+
@algorithm_name = value.value.to_s
|
27
|
+
when 'hashValue'
|
28
|
+
@hash_value = value.value.to_s
|
29
|
+
when 'saltValue'
|
30
|
+
@salt_value = value.value.to_s
|
31
|
+
when 'spinCount'
|
32
|
+
@spin_count = value.value.to_i
|
33
|
+
when 'name'
|
34
|
+
@name = value.value.to_s
|
35
|
+
when 'sqref'
|
36
|
+
@reference_sequence = value.value.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <sheetProtection> tag
|
5
|
+
class SheetProtection < OOXMLDocumentObject
|
6
|
+
# @return [String] Name of hashing algorithm
|
7
|
+
attr_reader :algorithm_name
|
8
|
+
# @return [String] Hash value for the password
|
9
|
+
attr_reader :hash_value
|
10
|
+
# @return [String] Salt value for the password
|
11
|
+
attr_reader :salt_value
|
12
|
+
# @return [Integer] Number of times the hashing function shall be iteratively run
|
13
|
+
attr_reader :spin_count
|
14
|
+
# @return [True, False] Specifies if sheet is protected
|
15
|
+
attr_reader :sheet
|
16
|
+
# @return [True, False] Specifies if using autofilter is not allowed on protected sheet
|
17
|
+
attr_reader :auto_filter
|
18
|
+
# @return [True, False] Specifies if deleting columns is not allowed on protected sheet
|
19
|
+
attr_reader :delete_columns
|
20
|
+
# @return [True, False] Specifies if deleting rows is not allowed on protected sheet
|
21
|
+
attr_reader :delete_rows
|
22
|
+
# @return [True, False] Specifies if formatting cells is not allowed on protected sheet
|
23
|
+
attr_reader :format_cells
|
24
|
+
# @return [True, False] Specifies if formatting columns is not allowed on protected sheet
|
25
|
+
attr_reader :format_columns
|
26
|
+
# @return [True, False] Specifies if formatting rows is not allowed on protected sheet
|
27
|
+
attr_reader :format_rows
|
28
|
+
# @return [True, False] Specifies if inserting columns is not allowed on protected sheet
|
29
|
+
attr_reader :insert_columns
|
30
|
+
# @return [True, False] Specifies if inserting rows is not allowed on protected sheet
|
31
|
+
attr_reader :insert_rows
|
32
|
+
# @return [True, False] Specifies if inserting hyperlinks is not allowed on protected sheet
|
33
|
+
attr_reader :insert_hyperlinks
|
34
|
+
# @return [True, False] Specifies if editing objects is not allowed on protected sheet
|
35
|
+
attr_reader :objects
|
36
|
+
# @return [True, False] Specifies if using pivot tables is not allowed on protected sheet
|
37
|
+
attr_reader :pivot_tables
|
38
|
+
# @return [True, False] Specifies if editing scenarios is not allowed on protected sheet
|
39
|
+
attr_reader :scenarios
|
40
|
+
# @return [True, False] Specifies if selecting locked cells is not allowed on protected sheet
|
41
|
+
attr_reader :select_locked_cells
|
42
|
+
# @return [True, False] Specifies if selecting unlocked cells is not allowed on protected sheet
|
43
|
+
attr_reader :select_unlocked_cells
|
44
|
+
# @return [True, False] Specifies if sorting is not allowed on protected sheet
|
45
|
+
attr_reader :sort
|
46
|
+
|
47
|
+
def initialize(parent: nil)
|
48
|
+
@objects = false
|
49
|
+
@scenarios = false
|
50
|
+
@select_locked_cells = false
|
51
|
+
@select_unlocked_cells = false
|
52
|
+
@auto_filter = true
|
53
|
+
@delete_columns = true
|
54
|
+
@delete_rows = true
|
55
|
+
@format_cells = true
|
56
|
+
@format_columns = true
|
57
|
+
@format_rows = true
|
58
|
+
@insert_columns = true
|
59
|
+
@insert_rows = true
|
60
|
+
@insert_hyperlinks = true
|
61
|
+
@pivot_tables = true
|
62
|
+
@sort = true
|
63
|
+
super
|
64
|
+
end
|
65
|
+
|
66
|
+
# Parse SheetProtection data
|
67
|
+
# @param [Nokogiri::XML:Element] node with SheetProtection data
|
68
|
+
# @return [Sheet] value of SheetProtection
|
69
|
+
def parse(node)
|
70
|
+
node.attributes.each do |key, value|
|
71
|
+
case key
|
72
|
+
when 'algorithmName'
|
73
|
+
@algorithm_name = value.value.to_s
|
74
|
+
when 'hashValue'
|
75
|
+
@hash_value = value.value.to_s
|
76
|
+
when 'saltValue'
|
77
|
+
@salt_value = value.value.to_s
|
78
|
+
when 'spinCount'
|
79
|
+
@spin_count = value.value.to_i
|
80
|
+
when 'sheet'
|
81
|
+
@sheet = attribute_enabled?(value)
|
82
|
+
when 'autoFilter'
|
83
|
+
@auto_filter = attribute_enabled?(value)
|
84
|
+
when 'deleteColumns'
|
85
|
+
@delete_columns = attribute_enabled?(value)
|
86
|
+
when 'deleteRows'
|
87
|
+
@delete_rows = attribute_enabled?(value)
|
88
|
+
when 'formatCells'
|
89
|
+
@format_cells = attribute_enabled?(value)
|
90
|
+
when 'formatColumns'
|
91
|
+
@format_columns = attribute_enabled?(value)
|
92
|
+
when 'formatRows'
|
93
|
+
@format_rows = attribute_enabled?(value)
|
94
|
+
when 'insertColumns'
|
95
|
+
@insert_columns = attribute_enabled?(value)
|
96
|
+
when 'insertRows'
|
97
|
+
@insert_rows = attribute_enabled?(value)
|
98
|
+
when 'insertHyperlinks'
|
99
|
+
@insert_hyperlinks = attribute_enabled?(value)
|
100
|
+
when 'objects'
|
101
|
+
@objects = attribute_enabled?(value)
|
102
|
+
when 'pivotTables'
|
103
|
+
@pivot_tables = attribute_enabled?(value)
|
104
|
+
when 'scenarios'
|
105
|
+
@scenarios = attribute_enabled?(value)
|
106
|
+
when 'selectLockedCells'
|
107
|
+
@select_locked_cells = attribute_enabled?(value)
|
108
|
+
when 'selectUnlockedCells'
|
109
|
+
@select_unlocked_cells = attribute_enabled?(value)
|
110
|
+
when 'sort'
|
111
|
+
@sort = attribute_enabled?(value)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
self
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <clientData> tag
|
5
|
+
class ClientData < OOXMLDocumentObject
|
6
|
+
# @return [True, False] Specifies if drawing is locked when sheet is protected
|
7
|
+
attr_reader :locks_with_sheet
|
8
|
+
|
9
|
+
def initialize(parent: nil)
|
10
|
+
@locks_with_sheet = true
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# Parse ClientData data
|
15
|
+
# @param [Nokogiri::XML:Element] node with ClientData data
|
16
|
+
# @return [Sheet] value of ClientData
|
17
|
+
def parse(node)
|
18
|
+
node.attributes.each do |key, value|
|
19
|
+
case key
|
20
|
+
when 'fLocksWithSheet'
|
21
|
+
@locks_with_sheet = attribute_enabled?(value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'xlsx_drawing/xlsx_drawing_position_parameters'
|
4
|
+
require_relative 'xlsx_drawing/client_data'
|
4
5
|
module OoxmlParser
|
5
6
|
# Data of spreadsheet drawing
|
6
7
|
class XlsxDrawing < OOXMLDocumentObject
|
@@ -11,6 +12,8 @@ module OoxmlParser
|
|
11
12
|
attr_accessor :to
|
12
13
|
# @return [GraphicFrame] graphic frame
|
13
14
|
attr_accessor :graphic_frame
|
15
|
+
# @return [ClientData] client data
|
16
|
+
attr_accessor :client_data
|
14
17
|
|
15
18
|
# Parse XlsxDrawing object
|
16
19
|
# @param node [Nokogiri::XML:Element] node to parse
|
@@ -32,6 +35,8 @@ module OoxmlParser
|
|
32
35
|
@graphic_frame = GraphicFrame.new(parent: self).parse(child_node)
|
33
36
|
when 'cxnSp'
|
34
37
|
@shape = ConnectionShape.new(parent: self).parse(child_node)
|
38
|
+
when 'clientData'
|
39
|
+
@client_data = ClientData.new(parent: self).parse(child_node)
|
35
40
|
end
|
36
41
|
end
|
37
42
|
self
|
@@ -11,6 +11,8 @@ require_relative 'worksheet/xlsx_column_properties'
|
|
11
11
|
require_relative 'worksheet/xlsx_drawing'
|
12
12
|
require_relative 'worksheet/xlsx_row'
|
13
13
|
require_relative 'worksheet/xlsx_header_footer'
|
14
|
+
require_relative 'worksheet/sheet_protection'
|
15
|
+
require_relative 'worksheet/protected_range'
|
14
16
|
module OoxmlParser
|
15
17
|
# Properties of worksheet
|
16
18
|
class Worksheet < OOXMLDocumentObject
|
@@ -33,6 +35,10 @@ module OoxmlParser
|
|
33
35
|
attr_reader :header_footer
|
34
36
|
# @return [Array<ConditionalFormatting>] list of conditional formattings
|
35
37
|
attr_reader :conditional_formattings
|
38
|
+
# @return [SheetProtection] protection of sheet
|
39
|
+
attr_reader :sheet_protection
|
40
|
+
# @return [Array<ProtectedRange>] list of protected ranges
|
41
|
+
attr_reader :protected_ranges
|
36
42
|
|
37
43
|
def initialize(parent: nil)
|
38
44
|
@columns = []
|
@@ -45,6 +51,7 @@ module OoxmlParser
|
|
45
51
|
@sheet_views = []
|
46
52
|
@table_parts = []
|
47
53
|
@conditional_formattings = []
|
54
|
+
@protected_ranges = []
|
48
55
|
super
|
49
56
|
end
|
50
57
|
|
@@ -134,6 +141,12 @@ module OoxmlParser
|
|
134
141
|
@header_footer = XlsxHeaderFooter.new(parent: self).parse(worksheet_node_child)
|
135
142
|
when 'conditionalFormatting'
|
136
143
|
@conditional_formattings << ConditionalFormatting.new(parent: self).parse(worksheet_node_child)
|
144
|
+
when 'sheetProtection'
|
145
|
+
@sheet_protection = SheetProtection.new(parent: self).parse(worksheet_node_child)
|
146
|
+
when 'protectedRanges'
|
147
|
+
worksheet_node_child.xpath('*').each do |protected_range_node|
|
148
|
+
@protected_ranges << ProtectedRange.new(parent: self).parse(protected_range_node)
|
149
|
+
end
|
137
150
|
end
|
138
151
|
end
|
139
152
|
parse_comments
|
@@ -4,6 +4,7 @@ require_relative 'workbook/chartsheet'
|
|
4
4
|
require_relative 'workbook/pivot_cache'
|
5
5
|
require_relative 'workbook/pivot_table_definition'
|
6
6
|
require_relative 'workbook/defined_name'
|
7
|
+
require_relative 'workbook/workbook_protection'
|
7
8
|
require_relative 'workbook/shared_string_table'
|
8
9
|
require_relative 'workbook/style_sheet'
|
9
10
|
require_relative 'workbook/worksheet'
|
@@ -30,6 +31,8 @@ module OoxmlParser
|
|
30
31
|
attr_accessor :pivot_table_definitions
|
31
32
|
# @return [Array<DefinedName>] list of defined names
|
32
33
|
attr_reader :defined_names
|
34
|
+
# @return [WorkbookProtection] protection of workbook structure
|
35
|
+
attr_reader :workbook_protection
|
33
36
|
|
34
37
|
def initialize(params = {})
|
35
38
|
@worksheets = []
|
@@ -135,6 +138,7 @@ module OoxmlParser
|
|
135
138
|
parse_pivot_cache
|
136
139
|
parse_pivot_table
|
137
140
|
parse_defined_names
|
141
|
+
parse_workbook_protection
|
138
142
|
OOXMLDocumentObject.xmls_stack.pop
|
139
143
|
self
|
140
144
|
end
|
@@ -166,5 +170,13 @@ module OoxmlParser
|
|
166
170
|
@defined_names << DefinedName.new(parent: self).parse(defined_name)
|
167
171
|
end
|
168
172
|
end
|
173
|
+
|
174
|
+
# Perform parsing of workbook protection
|
175
|
+
def parse_workbook_protection
|
176
|
+
workbook_protection = @doc.search('//xmlns:workbookProtection').first
|
177
|
+
return nil unless workbook_protection
|
178
|
+
|
179
|
+
@workbook_protection = WorkbookProtection.new(parent: self).parse(workbook_protection)
|
180
|
+
end
|
169
181
|
end
|
170
182
|
end
|
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.22.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:
|
13
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -26,6 +26,20 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: ooxml_decrypt
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: ruby-filemagic
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -514,6 +528,7 @@ files:
|
|
514
528
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
|
515
529
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb
|
516
530
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
|
531
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/protection.rb
|
517
532
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb
|
518
533
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/differential_formatting_records.rb
|
519
534
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb
|
@@ -526,6 +541,7 @@ files:
|
|
526
541
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb
|
527
542
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders/xlsx_border.rb
|
528
543
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/workbook_helpers.rb
|
544
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/workbook_protection.rb
|
529
545
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb
|
530
546
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb
|
531
547
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/author.rb
|
@@ -533,7 +549,9 @@ files:
|
|
533
549
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb
|
534
550
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/ole_objects.rb
|
535
551
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/page_setup.rb
|
552
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/protected_range.rb
|
536
553
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb
|
554
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_protection.rb
|
537
555
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb
|
538
556
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb
|
539
557
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/selection.rb
|
@@ -565,6 +583,7 @@ files:
|
|
565
583
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/worksheet_helper.rb
|
566
584
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb
|
567
585
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb
|
586
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/client_data.rb
|
568
587
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb
|
569
588
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer.rb
|
570
589
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer/header_footer_child.rb
|
@@ -597,7 +616,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
597
616
|
- !ruby/object:Gem::Version
|
598
617
|
version: '0'
|
599
618
|
requirements: []
|
600
|
-
rubygems_version: 3.
|
619
|
+
rubygems_version: 3.3.4
|
601
620
|
signing_key:
|
602
621
|
specification_version: 4
|
603
622
|
summary: OoxmlParser Gem
|