ooxml_parser 0.33.0 → 0.34.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/alternate_content/drawing/docx_drawing.rb +9 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +6 -2
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +15 -9
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +2 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +14 -13
- data/lib/ooxml_parser/common_parser/common_data/color.rb +17 -13
- data/lib/ooxml_parser/common_parser/common_data/colors/color_alpha_channel.rb +19 -5
- data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +34 -12
- data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +4 -0
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +22 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb +22 -6
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +4 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_fonts.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +12 -3
- data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +14 -4
- data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +3 -2
- data/lib/ooxml_parser/common_parser/common_data/underline.rb +22 -1
- data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +21 -2
- data/lib/ooxml_parser/common_parser/parser/ooxml_file.rb +10 -0
- data/lib/ooxml_parser/docx_parser/document_structure/default_style_helper.rb +84 -0
- data/lib/ooxml_parser/docx_parser/document_structure/document_background.rb +6 -1
- data/lib/ooxml_parser/docx_parser/document_structure/document_style.rb +9 -3
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_formula/accent.rb +9 -2
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_formula/bar.rb +9 -3
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_formula/group_char.rb +25 -4
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_formula/matrix.rb +2 -1
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +21 -13
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/field_char.rb +22 -0
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb +3 -1
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb +1 -1
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_text_properties.rb +2 -2
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph.rb +25 -8
- data/lib/ooxml_parser/docx_parser/document_structure/header_footer.rb +14 -2
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb +2 -2
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/note.rb +10 -11
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties/header_footer_reference.rb +27 -0
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties/page_borders.rb +26 -0
- data/lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb +20 -12
- data/lib/ooxml_parser/docx_parser/document_structure/styles/document_defaults/paragraph_properties_default.rb +3 -0
- data/lib/ooxml_parser/docx_parser/document_structure/styles.rb +6 -0
- data/lib/ooxml_parser/docx_parser/document_structure.rb +2 -69
- data/lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/presentation/slide/graphic_frame/graphic_frame/chart_reference.rb +22 -0
- data/lib/ooxml_parser/pptx_parser/presentation/slide/graphic_frame/graphic_frame.rb +4 -1
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/location.rb +6 -6
- data/lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/protection.rb +2 -2
- data/lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb +5 -5
- data/lib/ooxml_parser/xlsx_parser/workbook/workbook_properties.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_view.rb +2 -2
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part.rb +9 -1
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_column_properties.rb +2 -2
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb +4 -4
- data/lib/ooxml_parser/xlsx_parser/workbook/worksheet.rb +2 -1
- data/lib/ooxml_parser/xlsx_parser/workbook.rb +1 -1
- metadata +9 -3
@@ -45,11 +45,23 @@ module OoxmlParser
|
|
45
45
|
# @param [Nokogiri::XML:Node] node with HeaderFooter
|
46
46
|
# @return [HeaderFooter] result of parsing
|
47
47
|
def parse(node)
|
48
|
-
|
48
|
+
node.attributes.each do |key, value|
|
49
|
+
case key
|
50
|
+
when 'id'
|
51
|
+
@id = value.value.to_i
|
52
|
+
end
|
53
|
+
end
|
49
54
|
parse_type(node)
|
50
55
|
doc = parse_xml(root_object.unpacked_folder + xml_path)
|
51
56
|
doc.search(xpath_for_search).each do |footnote|
|
52
|
-
|
57
|
+
footnote_id = nil
|
58
|
+
footnote.attributes.each do |key, value|
|
59
|
+
case key
|
60
|
+
when 'id'
|
61
|
+
footnote_id = value.value.to_i
|
62
|
+
end
|
63
|
+
end
|
64
|
+
next unless footnote_id == @id
|
53
65
|
|
54
66
|
paragraph_number = 0
|
55
67
|
footnote.xpath('w:p').each do |paragraph|
|
@@ -36,9 +36,9 @@ module OoxmlParser
|
|
36
36
|
when 'num'
|
37
37
|
@count = value.value.to_i
|
38
38
|
when 'sep'
|
39
|
-
@separator =
|
39
|
+
@separator = boolean_attribute_value(value)
|
40
40
|
when 'equalWidth'
|
41
|
-
@equal_width =
|
41
|
+
@equal_width = boolean_attribute_value(value)
|
42
42
|
when 'space'
|
43
43
|
@space = OoxmlSize.new(value.value.to_f)
|
44
44
|
end
|
@@ -13,15 +13,14 @@ module OoxmlParser
|
|
13
13
|
# Parse note data
|
14
14
|
# @param params [Hash] data to parse
|
15
15
|
# @return [Note] result of parsing
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if note.type.include?('footer')
|
16
|
+
def parse(params)
|
17
|
+
@type = params[:type]
|
18
|
+
@assigned_to = params[:assigned_to]
|
19
|
+
@parent = params[:parent]
|
20
|
+
doc = parse_xml(file_path(params[:target]))
|
21
|
+
if @type.include?('footer')
|
23
22
|
xpath_note = '//w:ftr'
|
24
|
-
elsif
|
23
|
+
elsif @type.include?('header')
|
25
24
|
xpath_note = '//w:hdr'
|
26
25
|
end
|
27
26
|
doc.search(xpath_note).each do |ftr|
|
@@ -29,15 +28,15 @@ module OoxmlParser
|
|
29
28
|
ftr.xpath('*').each do |sub_element|
|
30
29
|
case sub_element.name
|
31
30
|
when 'p'
|
32
|
-
|
31
|
+
@elements << params[:default_paragraph].dup.parse(sub_element, number, params[:default_character], parent: self)
|
33
32
|
number += 1
|
34
33
|
when 'tbl'
|
35
|
-
|
34
|
+
@elements << Table.new(parent: self).parse(sub_element, number)
|
36
35
|
number += 1
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
40
|
-
|
39
|
+
self
|
41
40
|
end
|
42
41
|
|
43
42
|
# @param target [String] name of target
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing `w:headerReference`,
|
5
|
+
# `w:footerReference` object
|
6
|
+
class HeaderFooterReference < OOXMLDocumentObject
|
7
|
+
# @return [String] id of reference
|
8
|
+
attr_accessor :id
|
9
|
+
# @return [String] type of reference
|
10
|
+
attr_accessor :type
|
11
|
+
|
12
|
+
# Parse HeaderFooterReference
|
13
|
+
# @param [Nokogiri::XML:Node] node with HeaderFooterReference
|
14
|
+
# @return [HeaderFooterReference] result of parsing
|
15
|
+
def parse(node)
|
16
|
+
node.attributes.each do |key, value|
|
17
|
+
case key
|
18
|
+
when 'id'
|
19
|
+
@id = value.to_s
|
20
|
+
when 'type'
|
21
|
+
@type = value.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties/page_borders.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing `w:pgBorders` PageBorders object
|
5
|
+
class PageBorders < OOXMLDocumentObject
|
6
|
+
# @return [Symbol] display value
|
7
|
+
attr_reader :display
|
8
|
+
# @return [Symbol] offset from value
|
9
|
+
attr_reader :offset_from
|
10
|
+
|
11
|
+
# Parse PageBorders
|
12
|
+
# @param [Nokogiri::XML:Node] node with PageBorders
|
13
|
+
# @return [PageBorders] result of parsing
|
14
|
+
def parse(node)
|
15
|
+
node.attributes.each do |key, value|
|
16
|
+
case key
|
17
|
+
when 'display'
|
18
|
+
@display = value.value.to_sym
|
19
|
+
when 'offsetFrom'
|
20
|
+
@offset_from = value.value.to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
self
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -6,6 +6,9 @@ require_relative 'page_size'
|
|
6
6
|
require_relative 'page_margins'
|
7
7
|
require_relative 'columns'
|
8
8
|
require_relative 'note'
|
9
|
+
require_relative 'page_properties/header_footer_reference'
|
10
|
+
require_relative 'page_properties/page_borders'
|
11
|
+
|
9
12
|
module OoxmlParser
|
10
13
|
# Class for data of PageProperties
|
11
14
|
class PageProperties < OOXMLDocumentObject
|
@@ -30,9 +33,10 @@ module OoxmlParser
|
|
30
33
|
when 'pgSz'
|
31
34
|
@size = PageSize.new.parse(pg_size_subnode)
|
32
35
|
when 'pgBorders'
|
36
|
+
page_borders_object = PageBorders.new(parent: self).parse(pg_size_subnode)
|
33
37
|
page_borders = Borders.new
|
34
|
-
page_borders.display =
|
35
|
-
page_borders.offset_from =
|
38
|
+
page_borders.display = page_borders_object.display if page_borders_object.display
|
39
|
+
page_borders.offset_from = page_borders_object.offset_from if page_borders_object.offset_from
|
36
40
|
pg_size_subnode.xpath('w:bottom').each do |bottom|
|
37
41
|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(bottom)
|
38
42
|
end
|
@@ -47,15 +51,18 @@ module OoxmlParser
|
|
47
51
|
end
|
48
52
|
@page_borders = page_borders
|
49
53
|
when 'type'
|
50
|
-
@
|
54
|
+
@type_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode)
|
55
|
+
@type = @type_object.value
|
51
56
|
when 'pgMar'
|
52
57
|
@margins = PageMargins.new(parent: self).parse(pg_size_subnode)
|
53
58
|
when 'pgNumType'
|
54
59
|
@num_type = pg_size_subnode.attribute('fmt').value unless pg_size_subnode.attribute('fmt').nil?
|
55
60
|
when 'formProt'
|
56
|
-
|
61
|
+
form_prot_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode)
|
62
|
+
@form_prot = form_prot_object.value
|
57
63
|
when 'textDirection'
|
58
|
-
|
64
|
+
text_directon_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode)
|
65
|
+
@text_direction = text_directon_object.value
|
59
66
|
when 'docGrid'
|
60
67
|
@document_grid = DocumentGrid.new(parent: self).parse(pg_size_subnode)
|
61
68
|
when 'titlePg'
|
@@ -63,14 +70,15 @@ module OoxmlParser
|
|
63
70
|
when 'cols'
|
64
71
|
@columns = Columns.new.parse(pg_size_subnode)
|
65
72
|
when 'headerReference', 'footerReference'
|
66
|
-
|
73
|
+
reference = HeaderFooterReference.new(parent: self).parse(pg_size_subnode)
|
74
|
+
target = root_object.get_link_from_rels(reference.id)
|
67
75
|
root_object.add_to_xmls_stack("word/#{target}")
|
68
|
-
note = Note.parse(default_paragraph: default_paragraph,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
76
|
+
note = Note.new.parse(default_paragraph: default_paragraph,
|
77
|
+
default_character: default_character,
|
78
|
+
target: target,
|
79
|
+
assigned_to: reference.type,
|
80
|
+
type: File.basename(target).sub('.xml', ''),
|
81
|
+
parent: self)
|
74
82
|
@notes << note
|
75
83
|
root_object.xmls_stack.pop
|
76
84
|
when 'footnotePr'
|
@@ -5,11 +5,14 @@ module OoxmlParser
|
|
5
5
|
class ParagraphPropertiesDefault < OOXMLDocumentObject
|
6
6
|
# @return [ParagraphProperties] properties of run
|
7
7
|
attr_accessor :paragraph_properties
|
8
|
+
# @return [Nokogiri::XML:Element] raw node of tag
|
9
|
+
attr_reader :raw_node
|
8
10
|
|
9
11
|
# Parse ParagraphPropertiesDefault object
|
10
12
|
# @param node [Nokogiri::XML:Element] node to parse
|
11
13
|
# @return [ParagraphPropertiesDefault] result of parsing
|
12
14
|
def parse(node)
|
15
|
+
@raw_node = node
|
13
16
|
node.xpath('*').each do |node_child|
|
14
17
|
case node_child.name
|
15
18
|
when 'pPr'
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'document_structure/comments'
|
4
4
|
require_relative 'document_structure/comments_extended'
|
5
|
+
require_relative 'document_structure/default_style_helper'
|
5
6
|
require_relative 'document_structure/docx_paragraph'
|
6
7
|
require_relative 'document_structure/document_background'
|
7
8
|
require_relative 'document_structure/document_properties'
|
@@ -15,6 +16,7 @@ require_relative 'document_structure/styles'
|
|
15
16
|
module OoxmlParser
|
16
17
|
# Basic class for DocumentStructure
|
17
18
|
class DocumentStructure < CommonDocumentStructure
|
19
|
+
include DefaultStyleHelper
|
18
20
|
include DocumentStyleHelper
|
19
21
|
include DocumentStructureHelpers
|
20
22
|
# @return [Array<OOXMLDocumentObject>] list of elements
|
@@ -211,75 +213,6 @@ module OoxmlParser
|
|
211
213
|
self
|
212
214
|
end
|
213
215
|
|
214
|
-
# Parse default style
|
215
|
-
# @return [void]
|
216
|
-
def parse_default_style
|
217
|
-
doc = parse_xml("#{root_object.unpacked_folder}word/styles.xml")
|
218
|
-
doc.search('//w:style').each do |style|
|
219
|
-
next if style.attribute('default').nil?
|
220
|
-
|
221
|
-
if (style.attribute('default').value == '1' ||
|
222
|
-
style.attribute('default').value == 'on' ||
|
223
|
-
style.attribute('default').value == 'true') &&
|
224
|
-
style.attribute('type').value == 'paragraph'
|
225
|
-
style.xpath('w:pPr').each do |paragraph_pr_tag|
|
226
|
-
DocumentStructure.default_paragraph_style = DocxParagraph.new.parse_paragraph_style(paragraph_pr_tag, DocumentStructure.default_run_style)
|
227
|
-
end
|
228
|
-
style.xpath('w:rPr').each do |character_pr_tag|
|
229
|
-
DocumentStructure.default_run_style.parse_properties(character_pr_tag)
|
230
|
-
end
|
231
|
-
elsif (style.attribute('default').value == '1' ||
|
232
|
-
style.attribute('default').value == 'on' ||
|
233
|
-
style.attribute('default').value == 'true') &&
|
234
|
-
style.attribute('type').value == 'character'
|
235
|
-
style.xpath('w:rPr').each do |character_pr_tag|
|
236
|
-
DocumentStructure.default_run_style.parse_properties(character_pr_tag)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
DocumentStructure.default_table_paragraph_style = DocumentStructure.default_paragraph_style.dup
|
241
|
-
DocumentStructure.default_table_paragraph_style.spacing = Spacing.new(0, 0, 1, :auto)
|
242
|
-
DocumentStructure.default_table_run_style = DocumentStructure.default_run_style.dup
|
243
|
-
doc.search('//w:style').each do |style|
|
244
|
-
next if style.attribute('default').nil?
|
245
|
-
next unless (style.attribute('default').value == '1' ||
|
246
|
-
style.attribute('default').value == 'on' ||
|
247
|
-
style.attribute('default').value == 'true') &&
|
248
|
-
style.attribute('type').value == 'table'
|
249
|
-
|
250
|
-
style.xpath('w:rPr').each do |table_character_pr_tag|
|
251
|
-
DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
# Perform parsing styles.xml
|
257
|
-
def parse_styles
|
258
|
-
file = "#{root_object.unpacked_folder}/word/styles.xml"
|
259
|
-
DocumentStructure.default_paragraph_style = DocxParagraph.new(parent: self)
|
260
|
-
DocumentStructure.default_table_paragraph_style = DocxParagraph.new(parent: self)
|
261
|
-
DocumentStructure.default_run_style = DocxParagraphRun.new(parent: self)
|
262
|
-
DocumentStructure.default_table_run_style = DocxParagraphRun.new(parent: self)
|
263
|
-
|
264
|
-
return unless File.exist?(file)
|
265
|
-
|
266
|
-
doc = parse_xml(file)
|
267
|
-
# TODO: Remove this old way parsing in favor of doc_structure.styles.document_defaults
|
268
|
-
doc.search('//w:docDefaults').each do |doc_defaults|
|
269
|
-
doc_defaults.xpath('w:pPrDefault').each do |p_pr_defaults|
|
270
|
-
DocumentStructure.default_paragraph_style = DocxParagraph.new(parent: self).parse(p_pr_defaults, 0)
|
271
|
-
end
|
272
|
-
doc_defaults.xpath('w:rPrDefault').each do |r_pr_defaults|
|
273
|
-
r_pr_defaults.xpath('w:rPr').each do |r_pr|
|
274
|
-
DocumentStructure.default_run_style = DocxParagraphRun.new(parent: self).parse_properties(r_pr)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
parse_default_style
|
279
|
-
@numbering = Numbering.new(parent: self).parse
|
280
|
-
@styles = Styles.new(parent: self).parse
|
281
|
-
end
|
282
|
-
|
283
216
|
class << self
|
284
217
|
attr_accessor :default_table_run_style, :default_table_paragraph_style, :default_paragraph_style, :default_run_style
|
285
218
|
end
|
data/lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb
CHANGED
@@ -28,7 +28,7 @@ module OoxmlParser
|
|
28
28
|
node.xpath('*').each do |node_child|
|
29
29
|
case node_child.name
|
30
30
|
when 'pos'
|
31
|
-
@position = OOXMLCoordinates.
|
31
|
+
@position = OOXMLCoordinates.new(parent: self).parse(node_child)
|
32
32
|
when 'text'
|
33
33
|
@text = node_child.text.to_s
|
34
34
|
end
|
data/lib/ooxml_parser/pptx_parser/presentation/slide/graphic_frame/graphic_frame/chart_reference.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing `c:chart` object
|
5
|
+
class ChartReference < OOXMLDocumentObject
|
6
|
+
# @return [String] id of the chart
|
7
|
+
attr_reader :id
|
8
|
+
|
9
|
+
# Parse ChartReference
|
10
|
+
# @param [Nokogiri::XML:Node] node with ChartReference
|
11
|
+
# @return [ChartReference] result of parsing
|
12
|
+
def parse(node)
|
13
|
+
node.attributes.each do |key, value|
|
14
|
+
case key
|
15
|
+
when 'id'
|
16
|
+
@id = value.value.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'graphic_frame/chart_reference'
|
4
|
+
|
3
5
|
module OoxmlParser
|
4
6
|
# Class for parsing `graphicFrame`
|
5
7
|
class GraphicFrame < OOXMLDocumentObject
|
@@ -30,7 +32,8 @@ module OoxmlParser
|
|
30
32
|
when 'tbl'
|
31
33
|
graphic_data << Table.new(parent: self).parse(graphic_node_child)
|
32
34
|
when 'chart'
|
33
|
-
|
35
|
+
@chart_reference = ChartReference.new(parent: self).parse(graphic_node_child)
|
36
|
+
root_object.add_to_xmls_stack(root_object.get_link_from_rels(@chart_reference.id))
|
34
37
|
graphic_data << Chart.new(parent: self).parse
|
35
38
|
root_object.xmls_stack.pop
|
36
39
|
when 'oleObj'
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -5,11 +5,11 @@ module OoxmlParser
|
|
5
5
|
class Location < OOXMLDocumentObject
|
6
6
|
# @return [String] ref of location
|
7
7
|
attr_reader :ref
|
8
|
-
# @return [
|
8
|
+
# @return [Integer] first header row
|
9
9
|
attr_reader :first_header_row
|
10
|
-
# @return [
|
10
|
+
# @return [Integer] first data row
|
11
11
|
attr_reader :first_data_row
|
12
|
-
# @return [
|
12
|
+
# @return [Integer] first data column
|
13
13
|
attr_reader :first_data_column
|
14
14
|
|
15
15
|
# Parse `<location>` tag
|
@@ -21,11 +21,11 @@ module OoxmlParser
|
|
21
21
|
when 'ref'
|
22
22
|
@ref = value.value.to_s
|
23
23
|
when 'firstHeaderRow'
|
24
|
-
@first_header_row =
|
24
|
+
@first_header_row = value.value.to_i
|
25
25
|
when 'firstDataRow'
|
26
|
-
@first_data_row =
|
26
|
+
@first_data_row = value.value.to_i
|
27
27
|
when 'firstDataCol'
|
28
|
-
@first_data_column =
|
28
|
+
@first_data_column = value.value.to_i
|
29
29
|
end
|
30
30
|
end
|
31
31
|
self
|
@@ -21,9 +21,9 @@ module OoxmlParser
|
|
21
21
|
node.attributes.each do |key, value|
|
22
22
|
case key
|
23
23
|
when 'locked'
|
24
|
-
@locked =
|
24
|
+
@locked = boolean_attribute_value(value)
|
25
25
|
when 'hidden'
|
26
|
-
@hidden =
|
26
|
+
@hidden = boolean_attribute_value(value)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
self
|
@@ -93,15 +93,15 @@ module OoxmlParser
|
|
93
93
|
node.attributes.each do |key, value|
|
94
94
|
case key
|
95
95
|
when 'applyFont'
|
96
|
-
@apply_font =
|
96
|
+
@apply_font = boolean_attribute_value(value)
|
97
97
|
when 'applyBorder'
|
98
|
-
@apply_border =
|
98
|
+
@apply_border = boolean_attribute_value(value)
|
99
99
|
when 'applyFill'
|
100
|
-
@apply_fill =
|
100
|
+
@apply_fill = boolean_attribute_value(value)
|
101
101
|
when 'applyNumberFormat'
|
102
|
-
@apply_number_format =
|
102
|
+
@apply_number_format = boolean_attribute_value(value)
|
103
103
|
when 'applyAlignment'
|
104
|
-
@apply_alignment =
|
104
|
+
@apply_alignment = boolean_attribute_value(value)
|
105
105
|
when 'fontId'
|
106
106
|
@font_id = value.value.to_i
|
107
107
|
when 'borderId'
|
@@ -32,9 +32,9 @@ module OoxmlParser
|
|
32
32
|
node.attributes.each do |key, value|
|
33
33
|
case key
|
34
34
|
when 'showGridLines'
|
35
|
-
@show_gridlines =
|
35
|
+
@show_gridlines = boolean_attribute_value(value)
|
36
36
|
when 'showRowColHeaders'
|
37
|
-
@show_row_column_headers =
|
37
|
+
@show_row_column_headers = boolean_attribute_value(value)
|
38
38
|
when 'topLeftCell'
|
39
39
|
@top_left_cell = Coordinates.new.parse_string(value.value)
|
40
40
|
when 'workbookViewId'
|
@@ -7,6 +7,8 @@ require_relative 'table_part/table_columns'
|
|
7
7
|
module OoxmlParser
|
8
8
|
# Class for `tablePart` data
|
9
9
|
class TablePart < OOXMLDocumentObject
|
10
|
+
# @return [String] id of table part
|
11
|
+
attr_reader :id
|
10
12
|
attr_accessor :name, :display_name, :reference, :autofilter, :columns
|
11
13
|
# @return [ExtensionList] list of extensions
|
12
14
|
attr_accessor :extension_list
|
@@ -19,7 +21,13 @@ module OoxmlParser
|
|
19
21
|
# @param node [Nokogiri::XML:Element] node to parse
|
20
22
|
# @return [TablePart] result of parsing
|
21
23
|
def parse(node)
|
22
|
-
|
24
|
+
node.attributes.each do |key, value|
|
25
|
+
case key
|
26
|
+
when 'id'
|
27
|
+
@id = value.value.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
link_to_table_part_xml = root_object.get_link_from_rels(@id)
|
23
31
|
doc = parse_xml(root_object.unpacked_folder + link_to_table_part_xml.gsub('..', 'xl'))
|
24
32
|
table_node = doc.xpath('xmlns:table').first
|
25
33
|
table_node.attributes.each do |key, value|
|
@@ -39,9 +39,9 @@ module OoxmlParser
|
|
39
39
|
when 'customWidth'
|
40
40
|
@custom_width = option_enabled?(node, 'customWidth')
|
41
41
|
when 'bestFit'
|
42
|
-
@best_fit =
|
42
|
+
@best_fit = boolean_attribute_value(value)
|
43
43
|
when 'hidden'
|
44
|
-
@hidden =
|
44
|
+
@hidden = boolean_attribute_value(value)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
self
|
@@ -32,13 +32,13 @@ module OoxmlParser
|
|
32
32
|
node.attributes.each do |key, value|
|
33
33
|
case key
|
34
34
|
when 'alignWithMargins'
|
35
|
-
@align_with_margins =
|
35
|
+
@align_with_margins = boolean_attribute_value(value)
|
36
36
|
when 'differentFirst'
|
37
|
-
@different_first =
|
37
|
+
@different_first = boolean_attribute_value(value)
|
38
38
|
when 'differentOddEven'
|
39
|
-
@different_odd_even =
|
39
|
+
@different_odd_even = boolean_attribute_value(value)
|
40
40
|
when 'scaleWithDoc'
|
41
|
-
@scale_with_document =
|
41
|
+
@scale_with_document = boolean_attribute_value(value)
|
42
42
|
end
|
43
43
|
|
44
44
|
node.xpath('*').each do |node_child|
|
@@ -107,7 +107,8 @@ module OoxmlParser
|
|
107
107
|
@merge << merge_node.attribute('ref').value.to_s
|
108
108
|
end
|
109
109
|
when 'drawing'
|
110
|
-
|
110
|
+
@drawing = DocxDrawing.new(parent: self).parse(worksheet_node_child)
|
111
|
+
path_to_drawing = root_object.get_link_from_rels(@drawing.id)
|
111
112
|
unless path_to_drawing.nil?
|
112
113
|
root_object.add_to_xmls_stack(path_to_drawing)
|
113
114
|
parse_drawing
|
@@ -129,7 +129,7 @@ module OoxmlParser
|
|
129
129
|
@style_sheet = StyleSheet.new(parent: self).parse
|
130
130
|
@doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
|
131
131
|
@sheets << Sheet.new(parent: self).parse(sheet)
|
132
|
-
file = @relationships.target_by_id(
|
132
|
+
file = @relationships.target_by_id(@sheets.last.id)
|
133
133
|
if file.start_with?('worksheets')
|
134
134
|
@worksheets << Worksheet.new(parent: self).parse(file)
|
135
135
|
@worksheets.last.name = @sheets.last.name
|
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.34.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: 2022-10
|
13
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -325,6 +325,7 @@ files:
|
|
325
325
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb
|
326
326
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb
|
327
327
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/position.rb
|
328
|
+
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_fonts.rb
|
328
329
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_spacing.rb
|
329
330
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_style.rb
|
330
331
|
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb
|
@@ -372,6 +373,7 @@ files:
|
|
372
373
|
- lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb
|
373
374
|
- lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
|
374
375
|
- lib/ooxml_parser/docx_parser/document_structure/comments_extended/comment_extended.rb
|
376
|
+
- lib/ooxml_parser/docx_parser/document_structure/default_style_helper.rb
|
375
377
|
- lib/ooxml_parser/docx_parser/document_structure/document_background.rb
|
376
378
|
- lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
|
377
379
|
- lib/ooxml_parser/docx_parser/document_structure/document_settings.rb
|
@@ -408,6 +410,7 @@ files:
|
|
408
410
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_helper.rb
|
409
411
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb
|
410
412
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb
|
413
|
+
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/field_char.rb
|
411
414
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/instruction_text.rb
|
412
415
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/object.rb
|
413
416
|
- lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/object/ole_object.rb
|
@@ -451,6 +454,8 @@ files:
|
|
451
454
|
- lib/ooxml_parser/docx_parser/document_structure/page_properties/note.rb
|
452
455
|
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb
|
453
456
|
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb
|
457
|
+
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties/header_footer_reference.rb
|
458
|
+
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties/page_borders.rb
|
454
459
|
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_size.rb
|
455
460
|
- lib/ooxml_parser/docx_parser/document_structure/styles.rb
|
456
461
|
- lib/ooxml_parser/docx_parser/document_structure/styles/document_defaults.rb
|
@@ -478,6 +483,7 @@ files:
|
|
478
483
|
- lib/ooxml_parser/pptx_parser/presentation/slide/common_slide_data/shape_tree.rb
|
479
484
|
- lib/ooxml_parser/pptx_parser/presentation/slide/connection_shape.rb
|
480
485
|
- lib/ooxml_parser/pptx_parser/presentation/slide/graphic_frame/graphic_frame.rb
|
486
|
+
- lib/ooxml_parser/pptx_parser/presentation/slide/graphic_frame/graphic_frame/chart_reference.rb
|
481
487
|
- lib/ooxml_parser/pptx_parser/presentation/slide/presentation_alternate_content.rb
|
482
488
|
- lib/ooxml_parser/pptx_parser/presentation/slide/presentation_notes.rb
|
483
489
|
- lib/ooxml_parser/pptx_parser/presentation/slide/slide/shapes_grouping.rb
|
@@ -619,7 +625,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
619
625
|
- !ruby/object:Gem::Version
|
620
626
|
version: '0'
|
621
627
|
requirements: []
|
622
|
-
rubygems_version: 3.3.
|
628
|
+
rubygems_version: 3.3.25
|
623
629
|
signing_key:
|
624
630
|
specification_version: 4
|
625
631
|
summary: OoxmlParser Gem
|