ooxml_parser 0.12.1 → 0.14.1
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/color/color_helper.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +5 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_stlye_ref.rb +27 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +5 -5
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +1 -7
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +1 -1
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +12 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/defined_name.rb +33 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations.rb +47 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb +88 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation/data_validation_formula.rb +22 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer.rb +64 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer/header_footer_child.rb +56 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bfd9bf403c49920d072ee03ff67f63a80384b427ba11b13e1284aaa7736ec00
|
4
|
+
data.tar.gz: 7c10534ec85dd9d710759aa243684e37e8bdde011290095d565caed696966330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c108a26a2a99b55af6e98206979d08a28b8ea05241b463b0a6efa2820798d1b4a4a7efb4d194e2980361569d8c6b10ba0d21bec41a3fbc6cb59c706367f8ac0
|
7
|
+
data.tar.gz: c4ca66efcd1b8d313fa2e4370f552531e2f7b9af1fa792c5e77b1a8e1566c655efff505ada827869fa92dfda06171e00e0edb1702f754a522a91d3cd460dd44d
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'paragrpah_properties/numbering_properties'
|
4
4
|
require_relative 'paragrpah_properties/paragraph_borders'
|
5
5
|
require_relative 'paragrpah_properties/paragraph_spacing'
|
6
|
+
require_relative 'paragrpah_properties/paragraph_stlye_ref'
|
6
7
|
require_relative 'paragrpah_properties/spacing'
|
7
8
|
require_relative 'paragrpah_properties/tabs'
|
8
9
|
module OoxmlParser
|
@@ -17,6 +18,8 @@ module OoxmlParser
|
|
17
18
|
attr_accessor :run_properties
|
18
19
|
# @return [Borders] borders of paragraph
|
19
20
|
attr_accessor :paragraph_borders
|
21
|
+
# @return [ParagraphStyleRef] Referenced Paragraph Style
|
22
|
+
attr_accessor :paragraph_style_ref
|
20
23
|
# @return [True, False] Specifies that the paragraph
|
21
24
|
# (or at least part of it) should be rendered on
|
22
25
|
# the same page as the next paragraph when possible
|
@@ -84,6 +87,8 @@ module OoxmlParser
|
|
84
87
|
@run_properties = RunProperties.new(parent: self).parse(node_child)
|
85
88
|
when 'pBdr'
|
86
89
|
@paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
|
90
|
+
when 'pStyle'
|
91
|
+
@paragraph_style_ref = ParagraphStyleRef.new(parent: self).parse(node_child)
|
87
92
|
when 'keepNext'
|
88
93
|
@keep_next = true
|
89
94
|
when 'sectPr'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing `pStyle` tags
|
5
|
+
class ParagraphStyleRef < OOXMLDocumentObject
|
6
|
+
# @return [Integer] value of ParagraphStyleRef
|
7
|
+
attr_reader :value
|
8
|
+
|
9
|
+
# Parse ParagraphStyleRef object
|
10
|
+
# @param node [Nokogiri::XML:Element] node to parse
|
11
|
+
# @return [ParagraphStyleRef] result of parsing
|
12
|
+
def parse(node)
|
13
|
+
node.attributes.each do |key, value|
|
14
|
+
case key
|
15
|
+
when 'val'
|
16
|
+
@value = value.value.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [ParagraphStyle] which was referenced
|
23
|
+
def referenced_style
|
24
|
+
root_object.document_style_by_id(value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -9,11 +9,11 @@ module OoxmlParser
|
|
9
9
|
# @return [String] result of convert of object to string
|
10
10
|
def to_s
|
11
11
|
"Table position left: #{left}, "\
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
"right: #{right}, "\
|
13
|
+
"top: #{top}, "\
|
14
|
+
"bottom #{bottom}, "\
|
15
|
+
"position x: #{position_x}, "\
|
16
|
+
"position y: #{position_y}"
|
17
17
|
end
|
18
18
|
|
19
19
|
# Parse TablePosition object
|
@@ -84,7 +84,7 @@ module OoxmlParser
|
|
84
84
|
|
85
85
|
# @return [True, false] if structure contain any user data
|
86
86
|
def with_data?
|
87
|
-
!nonempty_runs.empty? || paragraph_properties
|
87
|
+
!nonempty_runs.empty? || paragraph_properties&.section_properties
|
88
88
|
end
|
89
89
|
|
90
90
|
# Compare this object to other
|
@@ -269,11 +269,5 @@ module OoxmlParser
|
|
269
269
|
nil
|
270
270
|
end
|
271
271
|
deprecate :sdt, 'nonempty_runs[i]', 2020, 1
|
272
|
-
|
273
|
-
# @return [OoxmlParser::FrameProperties] Return frame properties
|
274
|
-
def frame_properties
|
275
|
-
paragraph_properties.frame_properties
|
276
|
-
end
|
277
|
-
deprecate :frame_properties, 'paragraph_properties.frame_properties', 2020, 1
|
278
272
|
end
|
279
273
|
end
|
@@ -26,7 +26,7 @@ module OoxmlParser
|
|
26
26
|
# @return [String] result of conversion
|
27
27
|
def to_s
|
28
28
|
"first line indent: #{@first_line_indent}, left indent: #{@left_indent}, "\
|
29
|
-
|
29
|
+
"right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Parse Indents
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'workbook/chartsheet'
|
4
4
|
require_relative 'workbook/pivot_cache'
|
5
5
|
require_relative 'workbook/pivot_table_definition'
|
6
|
+
require_relative 'workbook/defined_name'
|
6
7
|
require_relative 'workbook/shared_string_table'
|
7
8
|
require_relative 'workbook/style_sheet'
|
8
9
|
require_relative 'workbook/worksheet'
|
@@ -24,11 +25,14 @@ module OoxmlParser
|
|
24
25
|
attr_accessor :pivot_caches
|
25
26
|
# @return [Array<PivotTableDefintion>] list of pivot table defitions
|
26
27
|
attr_accessor :pivot_table_definitions
|
28
|
+
# @return [Array<DefinedName>] list of defined names
|
29
|
+
attr_reader :defined_names
|
27
30
|
|
28
31
|
def initialize(params = {})
|
29
32
|
@worksheets = []
|
30
33
|
@pivot_caches = []
|
31
34
|
@pivot_table_definitions = []
|
35
|
+
@defined_names = []
|
32
36
|
super
|
33
37
|
end
|
34
38
|
|
@@ -125,6 +129,7 @@ module OoxmlParser
|
|
125
129
|
end
|
126
130
|
parse_pivot_cache
|
127
131
|
parse_pivot_table
|
132
|
+
parse_defined_names
|
128
133
|
OOXMLDocumentObject.xmls_stack.pop
|
129
134
|
self
|
130
135
|
end
|
@@ -149,5 +154,12 @@ module OoxmlParser
|
|
149
154
|
@pivot_table_definitions << PivotTableDefinition.new(parent: self).parse(file.part_name)
|
150
155
|
end
|
151
156
|
end
|
157
|
+
|
158
|
+
# Perform parsing of defined names
|
159
|
+
def parse_defined_names
|
160
|
+
@doc.xpath('xmlns:workbook/xmlns:definedNames/xmlns:definedName').each do |defined_name|
|
161
|
+
@defined_names << DefinedName.new(parent: self).parse(defined_name)
|
162
|
+
end
|
163
|
+
end
|
152
164
|
end
|
153
165
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <definedName> tag
|
5
|
+
class DefinedName < OOXMLDocumentObject
|
6
|
+
# @return [String] Ranges to which defined name refers
|
7
|
+
attr_reader :range
|
8
|
+
# @return [String] Name
|
9
|
+
attr_reader :name
|
10
|
+
# @return [String] Id of sheet
|
11
|
+
attr_reader :local_sheet_id
|
12
|
+
# @return [Symbol] Specifies whether defined name is hidden
|
13
|
+
attr_reader :hidden
|
14
|
+
|
15
|
+
# Parse Defined Name data
|
16
|
+
# @param [Nokogiri::XML:Element] node with DefinedName data
|
17
|
+
# @return [DefinedName] value of DefinedName
|
18
|
+
def parse(node)
|
19
|
+
@range = node.text
|
20
|
+
node.attributes.each do |key, value|
|
21
|
+
case key
|
22
|
+
when 'name'
|
23
|
+
@name = value.value.to_s
|
24
|
+
when 'localSheetId'
|
25
|
+
@local_sheet_id = value.value.to_i
|
26
|
+
when 'hidden'
|
27
|
+
@hidden = attribute_enabled?(value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -10,6 +10,7 @@ require_relative 'worksheet/worksheet_helper'
|
|
10
10
|
require_relative 'worksheet/xlsx_column_properties'
|
11
11
|
require_relative 'worksheet/xlsx_drawing'
|
12
12
|
require_relative 'worksheet/xlsx_row'
|
13
|
+
require_relative 'worksheet/xlsx_header_footer'
|
13
14
|
module OoxmlParser
|
14
15
|
# Properties of worksheet
|
15
16
|
class Worksheet < OOXMLDocumentObject
|
@@ -28,6 +29,8 @@ module OoxmlParser
|
|
28
29
|
attr_reader :page_setup
|
29
30
|
# @return [ExtensionList] list of extensions
|
30
31
|
attr_accessor :extension_list
|
32
|
+
# @return [XlsxHeaderFooter] header and footer
|
33
|
+
attr_reader :header_footer
|
31
34
|
|
32
35
|
def initialize(parent: nil)
|
33
36
|
@columns = []
|
@@ -124,6 +127,8 @@ module OoxmlParser
|
|
124
127
|
@page_setup = PageSetup.new(parent: self).parse(worksheet_node_child)
|
125
128
|
when 'extLst'
|
126
129
|
@extension_list = ExtensionList.new(parent: self).parse(worksheet_node_child)
|
130
|
+
when 'headerFooter'
|
131
|
+
@header_footer = XlsxHeaderFooter.new(parent: self).parse(worksheet_node_child)
|
127
132
|
end
|
128
133
|
end
|
129
134
|
parse_comments
|
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'extension/data_validations'
|
3
4
|
require_relative 'extension/sparkline_groups'
|
4
5
|
require_relative 'extension/x14_table'
|
5
6
|
module OoxmlParser
|
6
7
|
# Class for `ext` data
|
7
8
|
class Extension < OOXMLDocumentObject
|
9
|
+
# @return [DataValidations] list of data validations
|
10
|
+
attr_accessor :data_validations
|
8
11
|
# @return [X14Table] table data in x14 namespace
|
9
12
|
attr_accessor :table
|
10
13
|
# @return [SparklineGroups] list of groups
|
@@ -16,6 +19,8 @@ module OoxmlParser
|
|
16
19
|
def parse(node)
|
17
20
|
node.xpath('*').each do |column_node|
|
18
21
|
case column_node.name
|
22
|
+
when 'dataValidations'
|
23
|
+
@data_validations = DataValidations.new(parent: self).parse(column_node)
|
19
24
|
when 'table'
|
20
25
|
@table = X14Table.new(parent: self).parse(column_node)
|
21
26
|
when 'sparklineGroups'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'data_validations/data_validation'
|
4
|
+
|
5
|
+
module OoxmlParser
|
6
|
+
# Class for `dataValidations` data
|
7
|
+
class DataValidations < OOXMLDocumentObject
|
8
|
+
# @return [Integer] count of validations
|
9
|
+
attr_reader :count
|
10
|
+
# @return [Array<DataValidation>] list of data validations
|
11
|
+
attr_reader :data_validations
|
12
|
+
# @return [Boolean] is prompts disabled
|
13
|
+
attr_reader :disable_prompts
|
14
|
+
|
15
|
+
def initialize(parent: nil)
|
16
|
+
@data_validations = []
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [SparklineGroup] accessor
|
21
|
+
def [](key)
|
22
|
+
data_validations[key]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Parse DataValidations data
|
26
|
+
# @param [Nokogiri::XML:Element] node with DataValidations data
|
27
|
+
# @return [DataValidations] value of DataValidations data
|
28
|
+
def parse(node)
|
29
|
+
node.attributes.each do |key, value|
|
30
|
+
case key
|
31
|
+
when 'count'
|
32
|
+
@count = value.value.to_i
|
33
|
+
when 'disablePrompts'
|
34
|
+
@disable_prompts = attribute_enabled?(value)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
node.xpath('*').each do |node_child|
|
39
|
+
case node_child.name
|
40
|
+
when 'dataValidation'
|
41
|
+
@data_validations << DataValidation.new(parent: self).parse(node_child)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
self
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'data_validation/data_validation_formula'
|
4
|
+
module OoxmlParser
|
5
|
+
# Class for `dataValidation` data
|
6
|
+
class DataValidation < OOXMLDocumentObject
|
7
|
+
# @return [Boolean] should blank entries be valid
|
8
|
+
attr_reader :allow_blank
|
9
|
+
# @return [String] Specifies the message text of the error alert
|
10
|
+
attr_reader :error
|
11
|
+
# @return [Symbol] Type of error
|
12
|
+
attr_reader :error_style
|
13
|
+
# @return [String] The text of the title bar of the error alert
|
14
|
+
attr_reader :error_title
|
15
|
+
# @return [DataValidationFormula] first formula of data validation
|
16
|
+
attr_reader :formula1
|
17
|
+
# @return [DataValidationFormula] second formula of data validation
|
18
|
+
attr_reader :formula2
|
19
|
+
# @return [Symbol] Input Method Editor (IME) mode
|
20
|
+
attr_reader :ime_mode
|
21
|
+
# @return [Symbol] Relational operator used with this data validation
|
22
|
+
attr_reader :operator
|
23
|
+
# @return [String] Message text of the input prompt
|
24
|
+
attr_reader :prompt
|
25
|
+
# @return [String] Text of the title bar of the input prompt
|
26
|
+
attr_reader :prompt_title
|
27
|
+
# @return [String] Ranges to which data validation is applied
|
28
|
+
attr_reader :reference_sequence
|
29
|
+
# @return [Symbol] Specifies whether to display the drop-down combo box
|
30
|
+
attr_reader :show_dropdown
|
31
|
+
# @return [Symbol] Specifies whether to display the input prompt
|
32
|
+
attr_reader :show_input_message
|
33
|
+
# @return [Symbol] Specifies whether to display error alert message
|
34
|
+
attr_reader :show_error_message
|
35
|
+
# @return [Symbol] Type of validation
|
36
|
+
attr_reader :type
|
37
|
+
# @return [String] UID of validation
|
38
|
+
attr_reader :uid
|
39
|
+
|
40
|
+
# Parse DataValidation data
|
41
|
+
# @param [Nokogiri::XML:Element] node with DataValidation data
|
42
|
+
# @return [DataValidation] value of DataValidation data
|
43
|
+
def parse(node)
|
44
|
+
node.attributes.each do |key, value|
|
45
|
+
case key
|
46
|
+
when 'allowBlank'
|
47
|
+
@allow_blank = attribute_enabled?(value)
|
48
|
+
when 'error'
|
49
|
+
@error = value.value.to_s
|
50
|
+
when 'errorStyle'
|
51
|
+
@error_style = value.value.to_sym
|
52
|
+
when 'errorTitle'
|
53
|
+
@error_title = value.value.to_s
|
54
|
+
when 'imeMode'
|
55
|
+
@ime_mode = value.value.to_sym
|
56
|
+
when 'operator'
|
57
|
+
@operator = value.value.to_sym
|
58
|
+
when 'type'
|
59
|
+
@type = value.value.to_sym
|
60
|
+
when 'prompt'
|
61
|
+
@prompt = value.value.to_s
|
62
|
+
when 'promptTitle'
|
63
|
+
@prompt_title = value.value.to_s
|
64
|
+
when 'showDropDown'
|
65
|
+
@show_dropdown = attribute_enabled?(value)
|
66
|
+
when 'showInputMessage'
|
67
|
+
@show_input_message = attribute_enabled?(value)
|
68
|
+
when 'showErrorMessage'
|
69
|
+
@show_error_message = attribute_enabled?(value)
|
70
|
+
when 'uid'
|
71
|
+
@uid = value.value.to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
node.xpath('*').each do |node_child|
|
76
|
+
case node_child.name
|
77
|
+
when 'formula1'
|
78
|
+
@formula1 = DataValidationFormula.new(parent: self).parse(node_child)
|
79
|
+
when 'formula2'
|
80
|
+
@formula2 = DataValidationFormula.new(parent: self).parse(node_child)
|
81
|
+
when 'sqref'
|
82
|
+
@reference_sequence = node_child.text
|
83
|
+
end
|
84
|
+
end
|
85
|
+
self
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for `x14:formula1` or `x14:formula2` data
|
5
|
+
class DataValidationFormula < OOXMLDocumentObject
|
6
|
+
# @return [Formula] value of formula
|
7
|
+
attr_reader :formula
|
8
|
+
|
9
|
+
# Parse DataValidationFormula data
|
10
|
+
# @param [Nokogiri::XML:Element] node with DataValidationFormula data
|
11
|
+
# @return [DataValidationFormula] value of DataValidationFormula data
|
12
|
+
def parse(node)
|
13
|
+
node.xpath('*').each do |node_child|
|
14
|
+
case node_child.name
|
15
|
+
when 'f'
|
16
|
+
@formula = Formula.new(parent: self).parse(node_child)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'xlsx_header_footer/header_footer_child'
|
4
|
+
module OoxmlParser
|
5
|
+
# Class for parsing <headerFooter> tag
|
6
|
+
class XlsxHeaderFooter < OOXMLDocumentObject
|
7
|
+
# @return [Symbol] Specifies whether to align header with margins
|
8
|
+
attr_reader :align_with_margins
|
9
|
+
# @return [Symbol] Specifies whether first header is different
|
10
|
+
attr_reader :different_first
|
11
|
+
# @return [Symbol] Specifies whether odd and even headers are different
|
12
|
+
attr_reader :different_odd_even
|
13
|
+
# @return [Symbol] Specifies whether to scale header with document
|
14
|
+
attr_reader :scale_with_document
|
15
|
+
# @return [String] odd header
|
16
|
+
attr_reader :odd_header
|
17
|
+
# @return [String] odd footer
|
18
|
+
attr_reader :odd_footer
|
19
|
+
# @return [String] even header
|
20
|
+
attr_reader :even_header
|
21
|
+
# @return [String] even footer
|
22
|
+
attr_reader :even_footer
|
23
|
+
# @return [String] first header
|
24
|
+
attr_reader :first_header
|
25
|
+
# @return [String] first footer
|
26
|
+
attr_reader :first_footer
|
27
|
+
|
28
|
+
# Parse Header Footer data
|
29
|
+
# @param node [Nokogiri::XML:Element] node to parse
|
30
|
+
# @return [XlsxHeaderFooter] result of parsing
|
31
|
+
def parse(node)
|
32
|
+
node.attributes.each do |key, value|
|
33
|
+
case key
|
34
|
+
when 'alignWithMargins'
|
35
|
+
@align_with_margins = attribute_enabled?(value)
|
36
|
+
when 'differentFirst'
|
37
|
+
@different_first = attribute_enabled?(value)
|
38
|
+
when 'differentOddEven'
|
39
|
+
@different_odd_even = attribute_enabled?(value)
|
40
|
+
when 'scaleWithDoc'
|
41
|
+
@scale_with_document = attribute_enabled?(value)
|
42
|
+
end
|
43
|
+
|
44
|
+
node.xpath('*').each do |node_child|
|
45
|
+
case node_child.name
|
46
|
+
when 'oddHeader'
|
47
|
+
@odd_header = HeaderFooterChild.new(parent: parent, type: odd_header).parse(node_child)
|
48
|
+
when 'oddFooter'
|
49
|
+
@odd_footer = HeaderFooterChild.new(parent: parent, type: odd_footer).parse(node_child)
|
50
|
+
when 'evenHeader'
|
51
|
+
@even_header = HeaderFooterChild.new(parent: parent, type: even_header).parse(node_child)
|
52
|
+
when 'evenFooter'
|
53
|
+
@even_footer = HeaderFooterChild.new(parent: parent, type: even_footer).parse(node_child)
|
54
|
+
when 'firstHeader'
|
55
|
+
@first_header = HeaderFooterChild.new(parent: parent, type: first_header).parse(node_child)
|
56
|
+
when 'firstFooter'
|
57
|
+
@first_footer = HeaderFooterChild.new(parent: parent, type: first_footer).parse(node_child)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
self
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing header or footer
|
5
|
+
class HeaderFooterChild < OOXMLDocumentObject
|
6
|
+
# @return [Symbol] type of header
|
7
|
+
attr_reader :type
|
8
|
+
# @return [String] raw text of header
|
9
|
+
attr_reader :raw_string
|
10
|
+
|
11
|
+
def initialize(type: nil, raw_string: nil, parent: nil)
|
12
|
+
@type = type
|
13
|
+
@raw_string = raw_string
|
14
|
+
super(parent: parent)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Parse HeaderFooterChild data
|
18
|
+
# @param node [Nokogiri::XML:Element] node to parse
|
19
|
+
# @return [HeaderFooterChild] result of parsing
|
20
|
+
def parse(node)
|
21
|
+
@raw_string = node.text
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] right part of header
|
26
|
+
def right
|
27
|
+
return @right if @right
|
28
|
+
|
29
|
+
right = @raw_string.match(/&R(.+)/)
|
30
|
+
return nil unless right
|
31
|
+
|
32
|
+
@right = right[1]
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] center part of header
|
36
|
+
def center
|
37
|
+
return @center if @center
|
38
|
+
|
39
|
+
center = @raw_string.split('&R').first.match(/&C(.+)/)
|
40
|
+
return nil unless center
|
41
|
+
|
42
|
+
@center = center[1]
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String] left part of header
|
46
|
+
def left
|
47
|
+
return @left if @left
|
48
|
+
|
49
|
+
left = @raw_string.gsub("&R#{right}", '')
|
50
|
+
left = left.gsub("&C#{center}", '')
|
51
|
+
return nil if left == ''
|
52
|
+
|
53
|
+
left.gsub('&L', '')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
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.14.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: 2021-
|
13
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -321,6 +321,7 @@ files:
|
|
321
321
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb
|
322
322
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
|
323
323
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb
|
324
|
+
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_stlye_ref.rb
|
324
325
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb
|
325
326
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing/line_spacing.rb
|
326
327
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb
|
@@ -485,6 +486,7 @@ files:
|
|
485
486
|
- lib/ooxml_parser/version.rb
|
486
487
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb
|
487
488
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb
|
489
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/defined_name.rb
|
488
490
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb
|
489
491
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb
|
490
492
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields.rb
|
@@ -534,6 +536,9 @@ files:
|
|
534
536
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters/custom_filter.rb
|
535
537
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb
|
536
538
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb
|
539
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations.rb
|
540
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb
|
541
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation/data_validation_formula.rb
|
537
542
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb
|
538
543
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group.rb
|
539
544
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/x14_table.rb
|
@@ -544,6 +549,8 @@ files:
|
|
544
549
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb
|
545
550
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb
|
546
551
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb
|
552
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer.rb
|
553
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_header_footer/header_footer_child.rb
|
547
554
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb
|
548
555
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb
|
549
556
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb
|
@@ -572,7 +579,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
572
579
|
- !ruby/object:Gem::Version
|
573
580
|
version: '0'
|
574
581
|
requirements: []
|
575
|
-
rubygems_version: 3.2.
|
582
|
+
rubygems_version: 3.2.22
|
576
583
|
signing_key:
|
577
584
|
specification_version: 4
|
578
585
|
summary: OoxmlParser Gem
|