ooxml_parser 0.30.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +1 -1
  3. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +9 -4
  4. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/bullet_image.rb +22 -0
  5. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/numbering_properties.rb +1 -1
  6. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/paragraph_borders.rb +0 -0
  7. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/paragraph_spacing.rb +0 -0
  8. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties/paragraph_stlye_ref.rb → paragraph_properties/paragraph_style_ref.rb} +0 -0
  9. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/spacing/line_spacing.rb +0 -0
  10. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/spacing.rb +0 -0
  11. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/tabs/tab.rb +0 -0
  12. data/lib/ooxml_parser/common_parser/common_data/paragraph/{paragrpah_properties → paragraph_properties}/tabs.rb +0 -0
  13. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +9 -6
  14. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +4 -0
  15. data/lib/ooxml_parser/docx_parser/document_structure/numbering.rb +1 -1
  16. data/lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb +1 -1
  17. data/lib/ooxml_parser/pptx_parser/presentation/presentation_comments.rb +1 -1
  18. data/lib/ooxml_parser/version.rb +1 -1
  19. data/lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb +1 -1
  20. data/lib/ooxml_parser/xlsx_parser/workbook/workbook_properties.rb +27 -0
  21. data/lib/ooxml_parser/xlsx_parser/workbook.rb +13 -1
  22. metadata +12 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8264219a82e05f855d6e850703479fdfbb25b866ee5eb5705ac5171903fd7dd
4
- data.tar.gz: e5ef8d6182d11e432c97bc8d63a1632f270c443acf17803b6abafc502ae0681a
3
+ metadata.gz: 7cf7caeb2bfc8c48e6727c5a35c8514e07cf85fe2f528e742dd96be9473b3318
4
+ data.tar.gz: 07e1d21315c8dcd83664019f93cc1992926e176024420bd9fcdbc4de0837f9dd
5
5
  SHA512:
6
- metadata.gz: d666854752d50ce5a26dd6c36fa78b801e34de2938eb10e6247ca11832979eea3b23a8fc8a838e272b64df9e13f0947a747dbe322ac008ec797cd0a836c22519
7
- data.tar.gz: 81facb1e39faa54991524a2c3b3b613588c990d6cf02be6ac063b17c6971f0f08af0bc09a95cdae99a7a4eb50d1bb1a7278bc76377c0e496786b6f86335335f2
6
+ metadata.gz: 743b318ed40ff1805d7c6db6f32532dca25c6452be286808fcd52e5992e41bfa0a36de2574fcc828984f4dee095a75ba80cfc2221c49ef923db1880092ff9d83
7
+ data.tar.gz: 781db58bd859d241763049196327cfed403d3eb2fbb5288e9018a05eabab1f69b4115783e43166817e08e8e13485c25d1ada81db0cede73b82af38d52c4ca493
@@ -21,7 +21,7 @@ module OoxmlParser
21
21
  # Parse ContentTypes object
22
22
  # @return [ContentTypes] result of parsing
23
23
  def parse
24
- doc = Nokogiri::XML.parse(File.open("#{root_object.unpacked_folder}/[Content_Types].xml"))
24
+ doc = parse_xml("#{root_object.unpacked_folder}/[Content_Types].xml")
25
25
  node = doc.xpath('*').first
26
26
 
27
27
  node.xpath('*').each do |node_child|
@@ -3,6 +3,11 @@
3
3
  module OoxmlParser
4
4
  # Class for working with coordinates
5
5
  class Coordinates
6
+ # @return [Regexp] regexp for row name
7
+ ROW_REGEXP = /[a-z]/i.freeze
8
+ # @return [Regexp] regexp for column name
9
+ COLUMN_REGEXP = /\d/.freeze
10
+
6
11
  attr_accessor :row, :column, :list
7
12
 
8
13
  def initialize(row = nil, column = nil, list = nil)
@@ -30,10 +35,10 @@ module OoxmlParser
30
35
  range = arguments_string.split(':')
31
36
 
32
37
  difference = []
33
- symbols_from = range.first.scan(/[a-zA-z]/).join
34
- symbols_to = range.last.scan(/[a-zA-z]/).join
35
- digits_from = range.first.scan(/[0-9]/).join
36
- digits_to = range.last.scan(/[0-9]/).join
38
+ symbols_from = range.first.scan(ROW_REGEXP).join
39
+ symbols_to = range.last.scan(ROW_REGEXP).join
40
+ digits_from = range.first.scan(COLUMN_REGEXP).join
41
+ digits_to = range.last.scan(COLUMN_REGEXP).join
37
42
 
38
43
  difference[0] = [symbols_from, symbols_to] unless symbols_from == symbols_to
39
44
  difference[1] = [digits_from, digits_to] unless digits_from == digits_to
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <buBlip> tag
5
+ class BulletImage < OOXMLDocumentObject
6
+ # @return [FileReference] image structure
7
+ attr_reader :file_reference
8
+
9
+ # Parse BulletImage object
10
+ # @param node [Nokogiri::XML:Element] node to parse
11
+ # @return [BulletImage] result of parsing
12
+ def parse(node)
13
+ node.xpath('*').each do |node_child|
14
+ case node_child.name
15
+ when 'blip'
16
+ @file_reference = FileReference.new(parent: self).parse(node_child)
17
+ end
18
+ end
19
+ self
20
+ end
21
+ end
22
+ end
@@ -3,7 +3,7 @@
3
3
  module OoxmlParser
4
4
  # Class for parsing `numPr` tags
5
5
  class NumberingProperties < OOXMLDocumentObject
6
- attr_accessor :size, :font, :symbol, :start_at, :type, :ilvl, :numbering_properties
6
+ attr_accessor :size, :font, :symbol, :start_at, :type, :image, :ilvl, :numbering_properties
7
7
 
8
8
  def initialize(ilvl = 0, parent: nil)
9
9
  @ilvl = ilvl
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'paragrpah_properties/numbering_properties'
4
- require_relative 'paragrpah_properties/paragraph_borders'
5
- require_relative 'paragrpah_properties/paragraph_spacing'
6
- require_relative 'paragrpah_properties/paragraph_stlye_ref'
7
- require_relative 'paragrpah_properties/spacing'
8
- require_relative 'paragrpah_properties/tabs'
3
+ require_relative 'paragraph_properties/numbering_properties'
4
+ require_relative 'paragraph_properties/paragraph_borders'
5
+ require_relative 'paragraph_properties/paragraph_spacing'
6
+ require_relative 'paragraph_properties/paragraph_style_ref'
7
+ require_relative 'paragraph_properties/spacing'
8
+ require_relative 'paragraph_properties/tabs'
9
+ require_relative 'paragraph_properties/bullet_image'
9
10
  module OoxmlParser
10
11
  # Class for data for ParagraphProperties
11
12
  class ParagraphProperties < OOXMLDocumentObject
@@ -74,6 +75,8 @@ module OoxmlParser
74
75
  @numbering.font = node_child.attribute('typeface').value
75
76
  when 'buChar'
76
77
  @numbering.symbol = node_child.attribute('char').value
78
+ when 'buBlip'
79
+ @numbering.image = BulletImage.new(parent: self).parse(node_child)
77
80
  when 'buAutoNum'
78
81
  @numbering.type = node_child.attribute('type').value.to_sym
79
82
  @numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
@@ -47,6 +47,8 @@ module OoxmlParser
47
47
  attr_accessor :shade
48
48
  # @return [RunStyle] run style
49
49
  attr_accessor :run_style
50
+ # @return [ValuedChild] ligatures type
51
+ attr_reader :ligatures
50
52
 
51
53
  def initialize(params = {})
52
54
  @font_name = params.fetch(:font_name, '')
@@ -124,6 +126,8 @@ module OoxmlParser
124
126
  @shade = Shade.new(parent: self).parse(node_child)
125
127
  when 'rStyle'
126
128
  @run_style = RunStyle.new(parent: self).parse(node_child)
129
+ when 'ligatures'
130
+ @ligatures = ValuedChild.new(:symbol, parent: self).parse(node_child)
127
131
  end
128
132
  end
129
133
  @font_color = DocxColorScheme.new(parent: self).parse(node)
@@ -41,7 +41,7 @@ module OoxmlParser
41
41
  numbering_xml = "#{root_object.unpacked_folder}word/numbering.xml"
42
42
  return nil unless File.exist?(numbering_xml)
43
43
 
44
- node = parse_xml(File.open(numbering_xml))
44
+ node = parse_xml(numbering_xml)
45
45
  node.xpath('w:numbering/*').each do |numbering_child_node|
46
46
  case numbering_child_node.name
47
47
  when 'abstractNum'
@@ -18,7 +18,7 @@ module OoxmlParser
18
18
  def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml")
19
19
  return nil unless File.exist?(file)
20
20
 
21
- document = parse_xml(File.open(file))
21
+ document = parse_xml(file)
22
22
  node = document.xpath('*').first
23
23
 
24
24
  node.xpath('*').each do |node_child|
@@ -18,7 +18,7 @@ module OoxmlParser
18
18
  def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/comments/comment1.xml")
19
19
  return nil unless File.exist?(file)
20
20
 
21
- document = parse_xml(File.open(file))
21
+ document = parse_xml(file)
22
22
  node = document.xpath('*').first
23
23
 
24
24
  node.xpath('*').each do |node_child|
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.30.0'
7
+ STRING = '0.32.0'
8
8
  end
9
9
  end
@@ -55,7 +55,7 @@ module OoxmlParser
55
55
  # @param [String] file path
56
56
  # @return [PivotTableDefinition] result of parsing
57
57
  def parse(file)
58
- doc = Nokogiri::XML.parse(File.open("#{root_object.unpacked_folder}/#{file}"))
58
+ doc = parse_xml("#{root_object.unpacked_folder}/#{file}")
59
59
  node = doc.xpath('//xmlns:pivotTableDefinition').first
60
60
  node.attributes.each do |key, value|
61
61
  case key
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <workbookPr> tag
5
+ class WorkbookProperties < OOXMLDocumentObject
6
+ # @return [True, False] Specifies if 1904 date system is used in workbook
7
+ attr_reader :date1904
8
+
9
+ def initialize(parent: nil)
10
+ @date1904 = false
11
+ super
12
+ end
13
+
14
+ # Parse WorkbookProperties data
15
+ # @param [Nokogiri::XML:Element] node with WorkbookProperties data
16
+ # @return [WorkbookProperties] value of WorkbookProperties
17
+ def parse(node)
18
+ node.attributes.each do |key, value|
19
+ case key
20
+ when 'date1904'
21
+ @date1904 = attribute_enabled?(value)
22
+ end
23
+ end
24
+ self
25
+ end
26
+ end
27
+ end
@@ -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_properties'
7
8
  require_relative 'workbook/workbook_protection'
8
9
  require_relative 'workbook/shared_string_table'
9
10
  require_relative 'workbook/style_sheet'
@@ -31,6 +32,8 @@ module OoxmlParser
31
32
  attr_accessor :pivot_table_definitions
32
33
  # @return [Array<DefinedName>] list of defined names
33
34
  attr_reader :defined_names
35
+ # @return [WorkbookProperties] workbook properties
36
+ attr_reader :workbook_properties
34
37
  # @return [WorkbookProtection] protection of workbook structure
35
38
  attr_reader :workbook_protection
36
39
 
@@ -121,7 +124,7 @@ module OoxmlParser
121
124
  parse_shared_strings
122
125
  @root_subfolder = 'xl/'
123
126
  root_object.add_to_xmls_stack('xl/workbook.xml')
124
- @doc = Nokogiri::XML.parse(File.open(root_object.current_xml))
127
+ @doc = parse_xml(root_object.current_xml)
125
128
  @theme = PresentationTheme.new(parent: self).parse("xl/#{link_to_theme_xml}") if link_to_theme_xml
126
129
  @style_sheet = StyleSheet.new(parent: self).parse
127
130
  @doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
@@ -137,6 +140,7 @@ module OoxmlParser
137
140
  parse_pivot_cache
138
141
  parse_pivot_table
139
142
  parse_defined_names
143
+ parse_workbook_properties
140
144
  parse_workbook_protection
141
145
  root_object.xmls_stack.pop
142
146
  self
@@ -170,6 +174,14 @@ module OoxmlParser
170
174
  end
171
175
  end
172
176
 
177
+ # Perform parsing of workbook properties
178
+ def parse_workbook_properties
179
+ workbook_properties = @doc.search('//xmlns:workbookPr').first
180
+ return nil unless workbook_properties
181
+
182
+ @workbook_properties = WorkbookProperties.new(parent: self).parse(workbook_properties)
183
+ end
184
+
173
185
  # Perform parsing of workbook protection
174
186
  def parse_workbook_protection
175
187
  workbook_protection = @doc.search('//xmlns:workbookProtection').first
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.30.0
4
+ version: 0.32.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: 2022-09-09 00:00:00.000000000 Z
13
+ date: 2022-10-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -312,6 +312,15 @@ files:
312
312
  - lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
313
313
  - lib/ooxml_parser/common_parser/common_data/paragraph.rb
314
314
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb
315
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/bullet_image.rb
316
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb
317
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_borders.rb
318
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_spacing.rb
319
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/paragraph_style_ref.rb
320
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing.rb
321
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/line_spacing.rb
322
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs.rb
323
+ - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
315
324
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb
316
325
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb
317
326
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb
@@ -321,14 +330,6 @@ files:
321
330
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb
322
331
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/size.rb
323
332
  - lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/text.rb
324
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb
325
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
326
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb
327
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_stlye_ref.rb
328
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb
329
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing/line_spacing.rb
330
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb
331
- - lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
332
333
  - lib/ooxml_parser/common_parser/common_data/paragraph/text_field.rb
333
334
  - lib/ooxml_parser/common_parser/common_data/relationships.rb
334
335
  - lib/ooxml_parser/common_parser/common_data/relationships/relationship.rb
@@ -532,6 +533,7 @@ files:
532
533
  - lib/ooxml_parser/xlsx_parser/workbook/style_sheet/xlsx_borders.rb
533
534
  - lib/ooxml_parser/xlsx_parser/workbook/style_sheet/xlsx_borders/xlsx_border.rb
534
535
  - lib/ooxml_parser/xlsx_parser/workbook/workbook_helpers.rb
536
+ - lib/ooxml_parser/xlsx_parser/workbook/workbook_properties.rb
535
537
  - lib/ooxml_parser/xlsx_parser/workbook/workbook_protection.rb
536
538
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet.rb
537
539
  - lib/ooxml_parser/xlsx_parser/workbook/worksheet/excel_comments.rb