ooxml_parser 0.18.0 → 0.21.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/hyperlink.rb +17 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb +13 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +8 -2
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/sheet.rb +39 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/selection.rb +30 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +20 -3
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +6 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d49ee5c48167b1fec3d73c1f146b1f5039ad13591d91cd01076c2026a4da9d5
|
4
|
+
data.tar.gz: c903db5d14db5c9603c1a42b8c3a96666ea421ceb6264c3de142a23e6b4f4871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e1a32945ce66a7b668a734526a5cdb3f936a4ef78f0e88dfb3955e10505a21e7fae326cc3f515977bbee0b04e7cdd0d584963243b2c756de41f25c9be93514f
|
7
|
+
data.tar.gz: 1f01fbad38dd7c8ad7271d01fdc93ebb693f71ec0af1483bec680f3afbee8a6f32ded803cd01e889aba7c767de6bab3b6ce732a07ed5d771dff9faf95c023ffd
|
@@ -76,14 +76,29 @@ module OoxmlParser
|
|
76
76
|
@action = :last_slide
|
77
77
|
when 'ppaction://hlinksldjump'
|
78
78
|
@action = :slide
|
79
|
-
|
79
|
+
parse_url_for_slide_link
|
80
80
|
else
|
81
|
-
if
|
81
|
+
if meaningful_id?
|
82
82
|
@action = :external_link
|
83
83
|
@url = OOXMLDocumentObject.get_link_from_rels(@id)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
self
|
87
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# Check if id parameter has any information in it
|
92
|
+
# @return [Boolean] Can id be used
|
93
|
+
def meaningful_id?
|
94
|
+
@id && !@id.empty?
|
95
|
+
end
|
96
|
+
|
97
|
+
# Parse url for slide link
|
98
|
+
def parse_url_for_slide_link
|
99
|
+
return unless meaningful_id?
|
100
|
+
|
101
|
+
@url = OOXMLDocumentObject.get_link_from_rels(@id).scan(/\d+/).join.to_i
|
102
|
+
end
|
88
103
|
end
|
89
104
|
end
|
data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb
CHANGED
@@ -16,7 +16,7 @@ module OoxmlParser
|
|
16
16
|
# @param [Nokogiri::XML:Node] node with ParagraphSpacing
|
17
17
|
# @return [ParagraphSpacing] result of parsing
|
18
18
|
def parse(node)
|
19
|
-
node.
|
19
|
+
sorted_attributes(node).each do |key, value|
|
20
20
|
case key
|
21
21
|
when 'before'
|
22
22
|
@before = OoxmlSize.new(value.value.to_f)
|
@@ -34,5 +34,17 @@ module OoxmlParser
|
|
34
34
|
end
|
35
35
|
self
|
36
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# This is dirty workaround for situations
|
41
|
+
# Then @line_rule parsed after @line so getting
|
42
|
+
# @line value is totally screwed up
|
43
|
+
# @param [Nokogiri::XML:Node] node with ParagraphSpacing
|
44
|
+
# @return [Hash] hash with sorted values
|
45
|
+
# TODO: Totally redone parsing of spacing to remove this workaround
|
46
|
+
def sorted_attributes(node)
|
47
|
+
node.attributes.sort.reverse.to_h
|
48
|
+
end
|
37
49
|
end
|
38
50
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module OoxmlParser
|
4
4
|
# Class for parsing `snd` tags
|
5
5
|
class Sound < OOXMLDocumentObject
|
6
|
-
|
6
|
+
# @return [String] name of sound
|
7
|
+
attr_reader :name
|
7
8
|
# @return [FileReference] image structure
|
8
9
|
attr_accessor :file_reference
|
9
10
|
|
@@ -18,7 +19,12 @@ module OoxmlParser
|
|
18
19
|
# @return [Sound] result of parsing
|
19
20
|
def parse(node)
|
20
21
|
@file_reference = FileReference.new(parent: self).parse(node)
|
21
|
-
|
22
|
+
node.attributes.each do |key, value|
|
23
|
+
case key
|
24
|
+
when 'name'
|
25
|
+
@name = value.value.to_s
|
26
|
+
end
|
27
|
+
end
|
22
28
|
self
|
23
29
|
end
|
24
30
|
end
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing <sheet> tag
|
5
|
+
class Sheet < OOXMLDocumentObject
|
6
|
+
# @return [String] Name of sheet
|
7
|
+
attr_reader :name
|
8
|
+
# @return [Integer] SheetId of sheet
|
9
|
+
attr_reader :sheet_id
|
10
|
+
# @return [Symbol] Specifies if sheet is hidden
|
11
|
+
attr_reader :state
|
12
|
+
# @return [String] Id of sheet
|
13
|
+
attr_reader :id
|
14
|
+
|
15
|
+
def initialize(parent: nil)
|
16
|
+
@state = :visible
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# Parse Sheet data
|
21
|
+
# @param [Nokogiri::XML:Element] node with Sheet data
|
22
|
+
# @return [Sheet] value of Sheet
|
23
|
+
def parse(node)
|
24
|
+
node.attributes.each do |key, value|
|
25
|
+
case key
|
26
|
+
when 'name'
|
27
|
+
@name = value.value.to_s
|
28
|
+
when 'sheetId'
|
29
|
+
@sheet_id = value.value.to_i
|
30
|
+
when 'state'
|
31
|
+
@state = value.value.to_sym
|
32
|
+
when 'id'
|
33
|
+
@id = value.value.to_s
|
34
|
+
end
|
35
|
+
end
|
36
|
+
self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/selection.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for `selection` data
|
5
|
+
class Selection < OOXMLDocumentObject
|
6
|
+
# @return [Coordinates] Reference to the active cell
|
7
|
+
attr_reader :active_cell
|
8
|
+
# @return [Integer] Id of active cell
|
9
|
+
attr_reader :active_cell_id
|
10
|
+
# @return [String] Selected range
|
11
|
+
attr_reader :reference_sequence
|
12
|
+
|
13
|
+
# Parse Selection object
|
14
|
+
# @param node [Nokogiri::XML:Element] node to parse
|
15
|
+
# @return [Selection] result of parsing
|
16
|
+
def parse(node)
|
17
|
+
node.attributes.each do |key, value|
|
18
|
+
case key
|
19
|
+
when 'activeCell'
|
20
|
+
@active_cell = Coordinates.parse_coordinates_from_string(value.value)
|
21
|
+
when 'activeCellId'
|
22
|
+
@active_cell_id = value.value.to_i
|
23
|
+
when 'sqref'
|
24
|
+
@reference_sequence = value.value.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'sheet_view/pane'
|
4
|
+
require_relative 'sheet_view/selection'
|
4
5
|
module OoxmlParser
|
5
6
|
# Class for `sheetView` data
|
6
7
|
class SheetView < OOXMLDocumentObject
|
@@ -9,6 +10,14 @@ module OoxmlParser
|
|
9
10
|
attr_accessor :show_gridlines
|
10
11
|
# @return [True, False] Flag indicating whether the sheet should display row and column headings.
|
11
12
|
attr_accessor :show_row_column_headers
|
13
|
+
# @return [Coordinates] Reference to the top left cell
|
14
|
+
attr_reader :top_left_cell
|
15
|
+
# @return [Integer] Id of workbook view
|
16
|
+
attr_reader :workbook_view_id
|
17
|
+
# @return [Integer] Zoom scale
|
18
|
+
attr_reader :zoom_scale
|
19
|
+
# @return [Selection] Properties of selection
|
20
|
+
attr_reader :selection
|
12
21
|
|
13
22
|
def initialize(parent: nil)
|
14
23
|
@show_gridlines = true
|
@@ -20,12 +29,18 @@ module OoxmlParser
|
|
20
29
|
# @param node [Nokogiri::XML:Element] node to parse
|
21
30
|
# @return [SheetView] result of parsing
|
22
31
|
def parse(node)
|
23
|
-
node.attributes.
|
32
|
+
node.attributes.each do |key, value|
|
24
33
|
case key
|
25
34
|
when 'showGridLines'
|
26
|
-
@show_gridlines = attribute_enabled?(
|
35
|
+
@show_gridlines = attribute_enabled?(value)
|
27
36
|
when 'showRowColHeaders'
|
28
|
-
@show_row_column_headers = attribute_enabled?(
|
37
|
+
@show_row_column_headers = attribute_enabled?(value)
|
38
|
+
when 'topLeftCell'
|
39
|
+
@top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
|
40
|
+
when 'workbookViewId'
|
41
|
+
@workbook_view_id = value.value.to_i
|
42
|
+
when 'zoomScale'
|
43
|
+
@zoom_scale = value.value.to_i
|
29
44
|
end
|
30
45
|
end
|
31
46
|
|
@@ -33,6 +48,8 @@ module OoxmlParser
|
|
33
48
|
case node_child.name
|
34
49
|
when 'pane'
|
35
50
|
@pane = Pane.new(parent: self).parse(node_child)
|
51
|
+
when 'selection'
|
52
|
+
@selection = Selection.new(parent: self).parse(node_child)
|
36
53
|
end
|
37
54
|
end
|
38
55
|
self
|
@@ -7,12 +7,15 @@ require_relative 'workbook/defined_name'
|
|
7
7
|
require_relative 'workbook/shared_string_table'
|
8
8
|
require_relative 'workbook/style_sheet'
|
9
9
|
require_relative 'workbook/worksheet'
|
10
|
+
require_relative 'workbook/sheet'
|
10
11
|
require_relative 'workbook/workbook_helpers'
|
11
12
|
module OoxmlParser
|
12
13
|
# Class for storing XLSX Workbook
|
13
14
|
class XLSXWorkbook < CommonDocumentStructure
|
14
15
|
include WorkbookHelpers
|
15
16
|
attr_accessor :worksheets
|
17
|
+
# @return [Array<Sheet>] list of sheets
|
18
|
+
attr_reader :sheets
|
16
19
|
# @return [PresentationTheme] theme of Workbook
|
17
20
|
attr_accessor :theme
|
18
21
|
# @return [Relationships] rels of book
|
@@ -30,6 +33,7 @@ module OoxmlParser
|
|
30
33
|
|
31
34
|
def initialize(params = {})
|
32
35
|
@worksheets = []
|
36
|
+
@sheets = []
|
33
37
|
@pivot_caches = []
|
34
38
|
@pivot_table_definitions = []
|
35
39
|
@defined_names = []
|
@@ -119,10 +123,11 @@ module OoxmlParser
|
|
119
123
|
@theme = PresentationTheme.parse("xl/#{link_to_theme_xml}") if link_to_theme_xml
|
120
124
|
@style_sheet = StyleSheet.new(parent: self).parse
|
121
125
|
@doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
|
126
|
+
@sheets << Sheet.new(parent: self).parse(sheet)
|
122
127
|
file = @relationships.target_by_id(sheet.attribute('id').value)
|
123
128
|
if file.start_with?('worksheets')
|
124
129
|
@worksheets << Worksheet.new(parent: self).parse(file)
|
125
|
-
@worksheets.last.name =
|
130
|
+
@worksheets.last.name = @sheets.last.name
|
126
131
|
elsif file.start_with?('chartsheets')
|
127
132
|
@worksheets << Chartsheet.new(parent: self).parse(file)
|
128
133
|
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.21.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: 2021-
|
13
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -510,6 +510,7 @@ files:
|
|
510
510
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_table_style_info.rb
|
511
511
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb
|
512
512
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table/string_index.rb
|
513
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/sheet.rb
|
513
514
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
|
514
515
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb
|
515
516
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
|
@@ -535,6 +536,7 @@ files:
|
|
535
536
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb
|
536
537
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb
|
537
538
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb
|
539
|
+
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/selection.rb
|
538
540
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb
|
539
541
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb
|
540
542
|
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb
|
@@ -579,6 +581,7 @@ metadata:
|
|
579
581
|
documentation_uri: https://www.rubydoc.info/gems/ooxml_parser
|
580
582
|
homepage_uri: https://github.com/onlyoffice/ooxml_parser
|
581
583
|
source_code_uri: https://github.com/onlyoffice/ooxml_parser
|
584
|
+
rubygems_mfa_required: 'true'
|
582
585
|
post_install_message:
|
583
586
|
rdoc_options: []
|
584
587
|
require_paths:
|
@@ -594,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
594
597
|
- !ruby/object:Gem::Version
|
595
598
|
version: '0'
|
596
599
|
requirements: []
|
597
|
-
rubygems_version: 3.2.
|
600
|
+
rubygems_version: 3.2.32
|
598
601
|
signing_key:
|
599
602
|
specification_version: 4
|
600
603
|
summary: OoxmlParser Gem
|