ooxml_parser 0.16.0 → 0.19.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/picture/docx_blip/file_reference.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object/nokogiri_parsing_exception.rb +6 -0
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +7 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +28 -16
- 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/pptx_parser/pptx_data/presentation/slide_layout_file.rb +25 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_layouts_helper.rb +20 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_master_file.rb +25 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_masters_helper.rb +20 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +14 -0
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb +9 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 671e659de64bdde6bca41c908243249142b13c1befbc8eb3700bb349cecd763a
|
4
|
+
data.tar.gz: ddac347c46aaf664a93f7350f06a03926dcb3a1b9aa664e78916b75dec1ee306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38222b44da13b5cbc3fe2bbd0fb49b2cd8cd2e7ae2482586781a725d481c90144f39c0263d0c183db6094b11eebd065f57e9808a4c5dbe915a1854a436d97d33
|
7
|
+
data.tar.gz: 1e7e3c540f2e9a441a4e65209c3ee12fe920d2ee2e663af7fb4a52aedb8d68d956fe548384644ed1fa6b0c8c5ad59b739c800ecfc1ff0851a0ae343d661af886
|
@@ -35,7 +35,7 @@ module OoxmlParser
|
|
35
35
|
|
36
36
|
full_path_to_file = OOXMLDocumentObject.path_to_folder + OOXMLDocumentObject.root_subfolder + @path.gsub('..', '')
|
37
37
|
if File.exist?(full_path_to_file)
|
38
|
-
@content =
|
38
|
+
@content = File.binread(full_path_to_file)
|
39
39
|
else
|
40
40
|
warn "Couldn't find #{full_path_to_file} file on filesystem. Possible problem in original document"
|
41
41
|
end
|
@@ -4,6 +4,7 @@ require 'filemagic' unless Gem.win_platform?
|
|
4
4
|
require 'securerandom'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'zip'
|
7
|
+
require_relative 'ooxml_document_object/nokogiri_parsing_exception'
|
7
8
|
require_relative 'ooxml_document_object/ooxml_document_object_helper'
|
8
9
|
require_relative 'ooxml_document_object/ooxml_object_attribute_helper'
|
9
10
|
|
@@ -39,7 +40,12 @@ module OoxmlParser
|
|
39
40
|
|
40
41
|
# @return [Nokogiri::XML::Document] result of parsing xml via nokogiri
|
41
42
|
def parse_xml(xml_path)
|
42
|
-
Nokogiri::XML(File.open(xml_path), &:strict)
|
43
|
+
xml = Nokogiri::XML(File.open(xml_path), &:strict)
|
44
|
+
unless xml.errors.empty?
|
45
|
+
raise NokogiriParsingException,
|
46
|
+
"Nokogiri found errors in file: #{xml_path}. Errors: #{xml.errors}"
|
47
|
+
end
|
48
|
+
xml
|
43
49
|
end
|
44
50
|
|
45
51
|
class << self
|
@@ -15,10 +15,6 @@ module OoxmlParser
|
|
15
15
|
attr_reader :font_color
|
16
16
|
# @return [OoxmlSize] space size
|
17
17
|
attr_reader :space
|
18
|
-
# @return [string] name of font
|
19
|
-
attr_reader :font_name
|
20
|
-
# @return [Float] font size
|
21
|
-
attr_reader :font_size
|
22
18
|
# @return [Symbol] baseline of run
|
23
19
|
attr_reader :baseline
|
24
20
|
# @return [Hyperlink] hyperlink of run
|
@@ -79,14 +75,7 @@ module OoxmlParser
|
|
79
75
|
when 'strike'
|
80
76
|
@font_style.strike = value_to_symbol(value)
|
81
77
|
when 'baseline'
|
82
|
-
|
83
|
-
when -25_000, -30_000
|
84
|
-
@baseline = :subscript
|
85
|
-
when 30_000
|
86
|
-
@baseline = :superscript
|
87
|
-
when 0
|
88
|
-
@baseline = :baseline
|
89
|
-
end
|
78
|
+
@baseline = parse_baseline(value)
|
90
79
|
when 'cap'
|
91
80
|
@caps = value.value.to_sym
|
92
81
|
end
|
@@ -107,8 +96,6 @@ module OoxmlParser
|
|
107
96
|
@spacing = RunSpacing.new(parent: self).parse(node_child)
|
108
97
|
when 'color'
|
109
98
|
@color = OoxmlColor.new(parent: self).parse(node_child)
|
110
|
-
when 'solidFill'
|
111
|
-
@font_color = Color.new(parent: self).parse_color(node_child.xpath('*').first)
|
112
99
|
when 'latin'
|
113
100
|
@font_name = node_child.attribute('typeface').value
|
114
101
|
when 'b'
|
@@ -140,9 +127,34 @@ module OoxmlParser
|
|
140
127
|
end
|
141
128
|
end
|
142
129
|
@font_color = DocxColorScheme.new(parent: self).parse(node)
|
143
|
-
@font_name = root_object.default_font_typeface if @font_name.empty?
|
144
|
-
@font_size ||= root_object.default_font_size
|
145
130
|
self
|
146
131
|
end
|
132
|
+
|
133
|
+
# @return [Float] font size
|
134
|
+
def font_size
|
135
|
+
@font_size ||= root_object.default_font_size
|
136
|
+
end
|
137
|
+
|
138
|
+
# @return [String] name of font
|
139
|
+
def font_name
|
140
|
+
return @font_name unless @font_name.empty?
|
141
|
+
|
142
|
+
root_object.default_font_typeface
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
# @param value [Nokogiri::XML::Attr] nokogiri parameter to parse
|
148
|
+
# @return [Symbol] baseline value depending of type
|
149
|
+
def parse_baseline(value)
|
150
|
+
case value.value.to_i
|
151
|
+
when -25_000, -30_000
|
152
|
+
:subscript
|
153
|
+
when 30_000
|
154
|
+
:superscript
|
155
|
+
when 0
|
156
|
+
:baseline
|
157
|
+
end
|
158
|
+
end
|
147
159
|
end
|
148
160
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing SlideLayout files
|
5
|
+
class SlideLayoutFile < OOXMLDocumentObject
|
6
|
+
# @return [CommonSlideData] common slide data
|
7
|
+
attr_reader :common_slide_data
|
8
|
+
|
9
|
+
# Parse SlideLayoutFile
|
10
|
+
# @param file [String] path to file to parse
|
11
|
+
# @return [SlideLayoutFile] result of parsing
|
12
|
+
def parse(file)
|
13
|
+
OOXMLDocumentObject.add_to_xmls_stack(file.gsub(OOXMLDocumentObject.path_to_folder, ''))
|
14
|
+
doc = parse_xml(file)
|
15
|
+
doc.xpath('p:sldLayout/*').each do |node_child|
|
16
|
+
case node_child.name
|
17
|
+
when 'cSld'
|
18
|
+
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
OOXMLDocumentObject.xmls_stack.pop
|
22
|
+
self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# method to help to work with SlideLayouts
|
5
|
+
module SlideLayoutsHelper
|
6
|
+
# @return [Array<String>] list of slide layouts files
|
7
|
+
def slide_layouts_files
|
8
|
+
Dir["#{OOXMLDocumentObject.path_to_folder}ppt/slideLayouts/*.xml"]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Parse slide layouts file
|
14
|
+
def parse_slide_layouts
|
15
|
+
slide_layouts_files.each do |file|
|
16
|
+
@slide_layouts << SlideLayoutFile.new(parent: self).parse(file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# Class for parsing SlideMaster files
|
5
|
+
class SlideMasterFile < OOXMLDocumentObject
|
6
|
+
# @return [CommonSlideData] common slide data
|
7
|
+
attr_reader :common_slide_data
|
8
|
+
|
9
|
+
# Parse SlideMaster
|
10
|
+
# @param file [String] path to file to parse
|
11
|
+
# @return [SlideMasterFile] result of parsing
|
12
|
+
def parse(file)
|
13
|
+
OOXMLDocumentObject.add_to_xmls_stack(file.gsub(OOXMLDocumentObject.path_to_folder, ''))
|
14
|
+
doc = parse_xml(file)
|
15
|
+
doc.xpath('p:sldMaster/*').each do |node_child|
|
16
|
+
case node_child.name
|
17
|
+
when 'cSld'
|
18
|
+
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
OOXMLDocumentObject.xmls_stack.pop
|
22
|
+
self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OoxmlParser
|
4
|
+
# method to help to work with SlideMasters
|
5
|
+
module SlideMastersHelper
|
6
|
+
# @return [Array<String>] list of slide masters files
|
7
|
+
def slide_masters_files
|
8
|
+
Dir["#{OOXMLDocumentObject.path_to_folder}ppt/slideMasters/*.xml"]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Parse slide masters file
|
14
|
+
def parse_slide_masters
|
15
|
+
slide_masters_files.each do |file|
|
16
|
+
@slide_masters << SlideMasterFile.new(parent: self).parse(file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,12 +5,18 @@ require_relative 'presentation/presentation_comments'
|
|
5
5
|
require_relative 'presentation/presentation_helpers'
|
6
6
|
require_relative 'presentation/presentation_theme'
|
7
7
|
require_relative 'presentation/slide'
|
8
|
+
require_relative 'presentation/slide_master_file'
|
9
|
+
require_relative 'presentation/slide_masters_helper'
|
10
|
+
require_relative 'presentation/slide_layout_file'
|
11
|
+
require_relative 'presentation/slide_layouts_helper'
|
8
12
|
require_relative 'presentation/slide_size'
|
9
13
|
require_relative 'presentation/table_styles'
|
10
14
|
module OoxmlParser
|
11
15
|
# Basic class for all parsed pptx data
|
12
16
|
class Presentation < CommonDocumentStructure
|
13
17
|
include PresentationHelpers
|
18
|
+
include SlideLayoutsHelper
|
19
|
+
include SlideMastersHelper
|
14
20
|
attr_accessor :slides, :theme, :slide_size
|
15
21
|
# @return [Relationships] relationships of presentation
|
16
22
|
attr_accessor :relationships
|
@@ -20,10 +26,16 @@ module OoxmlParser
|
|
20
26
|
attr_reader :comment_authors
|
21
27
|
# @return [PresentationComments] comments of presentation
|
22
28
|
attr_reader :comments
|
29
|
+
# @return [Array<SlideMasterFile>] list of slide master
|
30
|
+
attr_reader :slide_masters
|
31
|
+
# @return [Array<SlideLayout>] list of slide layouts
|
32
|
+
attr_reader :slide_layouts
|
23
33
|
|
24
34
|
def initialize(params = {})
|
25
35
|
@slides = []
|
26
36
|
@comments = []
|
37
|
+
@slide_masters = []
|
38
|
+
@slide_layouts = []
|
27
39
|
super
|
28
40
|
end
|
29
41
|
|
@@ -56,6 +68,8 @@ module OoxmlParser
|
|
56
68
|
end
|
57
69
|
OOXMLDocumentObject.xmls_stack.pop
|
58
70
|
@relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}/ppt/_rels/presentation.xml.rels")
|
71
|
+
parse_slide_layouts
|
72
|
+
parse_slide_masters
|
59
73
|
self
|
60
74
|
end
|
61
75
|
end
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -25,6 +25,10 @@ module OoxmlParser
|
|
25
25
|
attr_reader :percent
|
26
26
|
# @return [Integer] Number of items in top/bottom rule
|
27
27
|
attr_reader :rank
|
28
|
+
# @return [Boolean] Specifies whether rule highlights values above average
|
29
|
+
attr_reader :above_average
|
30
|
+
# @return [Boolean] Specifies whether rule highlights values equal to average
|
31
|
+
attr_reader :equal_average
|
28
32
|
# @return [Integer] Number of standard deviations in above/below average rule
|
29
33
|
attr_reader :standard_deviation
|
30
34
|
# @return [String] Text value in text rule
|
@@ -43,6 +47,7 @@ module OoxmlParser
|
|
43
47
|
attr_reader :icon_set
|
44
48
|
|
45
49
|
def initialize(parent: nil)
|
50
|
+
@above_average = true
|
46
51
|
@formulas = []
|
47
52
|
super
|
48
53
|
end
|
@@ -71,6 +76,10 @@ module OoxmlParser
|
|
71
76
|
@percent = attribute_enabled?(value)
|
72
77
|
when 'rank'
|
73
78
|
@rank = value.value.to_i
|
79
|
+
when 'aboveAverage'
|
80
|
+
@above_average = attribute_enabled?(value)
|
81
|
+
when 'equalAverage'
|
82
|
+
@equal_average = attribute_enabled?(value)
|
74
83
|
when 'stdDev'
|
75
84
|
@standard_deviation = value.value.to_i
|
76
85
|
when 'text'
|
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.19.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-11-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -305,6 +305,7 @@ files:
|
|
305
305
|
- lib/ooxml_parser/common_parser/common_data/font_style.rb
|
306
306
|
- lib/ooxml_parser/common_parser/common_data/hyperlink.rb
|
307
307
|
- lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb
|
308
|
+
- lib/ooxml_parser/common_parser/common_data/ooxml_document_object/nokogiri_parsing_exception.rb
|
308
309
|
- lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb
|
309
310
|
- lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
|
310
311
|
- lib/ooxml_parser/common_parser/common_data/paragraph.rb
|
@@ -480,6 +481,10 @@ files:
|
|
480
481
|
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb
|
481
482
|
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb
|
482
483
|
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties/wheel.rb
|
484
|
+
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_layout_file.rb
|
485
|
+
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_layouts_helper.rb
|
486
|
+
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_master_file.rb
|
487
|
+
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_masters_helper.rb
|
483
488
|
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb
|
484
489
|
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb
|
485
490
|
- lib/ooxml_parser/pptx_parser/pptx_parser.rb
|
@@ -574,6 +579,7 @@ metadata:
|
|
574
579
|
documentation_uri: https://www.rubydoc.info/gems/ooxml_parser
|
575
580
|
homepage_uri: https://github.com/onlyoffice/ooxml_parser
|
576
581
|
source_code_uri: https://github.com/onlyoffice/ooxml_parser
|
582
|
+
rubygems_mfa_required: 'true'
|
577
583
|
post_install_message:
|
578
584
|
rdoc_options: []
|
579
585
|
require_paths:
|
@@ -589,7 +595,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
589
595
|
- !ruby/object:Gem::Version
|
590
596
|
version: '0'
|
591
597
|
requirements: []
|
592
|
-
rubygems_version: 3.2.
|
598
|
+
rubygems_version: 3.2.29
|
593
599
|
signing_key:
|
594
600
|
specification_version: 4
|
595
601
|
summary: OoxmlParser Gem
|