ooxml_parser 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser.rb +1 -0
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +6 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +2 -2
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +0 -2
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -0
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +4 -1
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +1 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +4 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +0 -2
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -3
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -0
  14. 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 +0 -2
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -3
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +1 -3
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +1 -3
  19. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +3 -0
  20. data/lib/ooxml_parser/common_parser/common_data/color.rb +36 -4
  21. data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
  22. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +11 -0
  23. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +1 -0
  24. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +4 -0
  25. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +2 -0
  26. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_default.rb +3 -0
  27. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_override.rb +3 -0
  28. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +7 -0
  29. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +24 -2
  30. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +3 -0
  31. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +0 -8
  32. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +2 -0
  33. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +1 -0
  34. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +16 -13
  35. data/lib/ooxml_parser/common_parser/common_data/table.rb +2 -0
  36. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +3 -0
  37. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +7 -0
  38. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +1 -0
  39. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +4 -4
  40. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -7
  41. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +6 -0
  42. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +3 -0
  43. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -0
  44. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +27 -3
  45. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +3 -0
  46. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +2 -0
  47. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +22 -1
  48. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_end.rb +1 -1
  49. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/comment_range_start.rb +1 -0
  50. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +3 -0
  51. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +13 -3
  52. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +4 -1
  53. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +0 -2
  54. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +3 -0
  55. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +2 -0
  56. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +0 -2
  57. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +5 -0
  58. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +3 -0
  59. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +1 -0
  60. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -0
  61. data/lib/ooxml_parser/docx_parser/docx_parser.rb +3 -0
  62. data/lib/ooxml_parser/name.rb +1 -0
  63. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +2 -0
  64. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +3 -0
  65. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +3 -0
  66. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -0
  67. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +3 -0
  68. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +15 -1
  69. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +3 -0
  70. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +3 -0
  71. data/lib/ooxml_parser/version.rb +2 -1
  72. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +21 -2
  73. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +3 -0
  74. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb +41 -0
  75. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +37 -0
  76. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb +33 -0
  77. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb +26 -0
  78. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +2 -0
  79. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
  80. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +2 -0
  81. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +3 -0
  82. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
  83. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +4 -0
  84. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +4 -0
  85. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +3 -0
  86. metadata +64 -4
@@ -30,6 +30,9 @@ module OoxmlParser
30
30
  self
31
31
  end
32
32
 
33
+ # Parse list of timing nodes
34
+ # @param timing_list_node [Nokogiri::XML::Element] node to parse
35
+ # @return [Array<TimeNode>] list of nodes
33
36
  def self.parse_list(timing_list_node)
34
37
  timings = []
35
38
  timing_list_node.xpath('*').each do |time_node|
@@ -3,10 +3,12 @@
3
3
  module OoxmlParser
4
4
  # Methods to help working with slide data
5
5
  module SlideHelper
6
+ # @return [Array] list of not empty element on slide
6
7
  def nonempty_elements
7
8
  elements.reject { |cur_shape| cur_shape.text_body.paragraphs.first.characters.empty? }
8
9
  end
9
10
 
11
+ # @return [Array<GraphicFrame>] list GraphicFrame elements on slide
10
12
  def graphic_frames
11
13
  elements.select { |cur_element| cur_element.is_a?(GraphicFrame) }
12
14
  end
@@ -17,7 +19,7 @@ module OoxmlParser
17
19
  def transform_of_object(object)
18
20
  case object
19
21
  when :image
20
- elements.find { |e| e.is_a? Picture }.properties.transform
22
+ elements.find { |e| e.is_a? DocxPicture }.properties.transform
21
23
  when :chart
22
24
  elements.find { |e| e.is_a? GraphicFrame }.transform
23
25
  when :table
@@ -29,6 +31,10 @@ module OoxmlParser
29
31
  end
30
32
  end
31
33
 
34
+ # Get horizontal align of object on slide
35
+ # @param object [Symbol] object to get
36
+ # @param slide_size [SlideSize] size of slide
37
+ # @return [Symbol] type of align
32
38
  def content_horizontal_align(object, slide_size)
33
39
  transform = transform_of_object(object)
34
40
  return :left if transform.offset.x.zero?
@@ -38,6 +44,10 @@ module OoxmlParser
38
44
  :unknown
39
45
  end
40
46
 
47
+ # Get vertical align of object on slide
48
+ # @param object [Symbol] object to get
49
+ # @param slide_size [SlideSize] size of slide
50
+ # @return [Symbol] type of align
41
51
  def content_vertical_align(object, slide_size)
42
52
  transform = transform_of_object(object)
43
53
  return :top if transform.offset.y.zero?
@@ -47,6 +57,10 @@ module OoxmlParser
47
57
  :unknown
48
58
  end
49
59
 
60
+ # Get content distribution of object
61
+ # @param object [Symbol] object to get
62
+ # @param slide_size [SlideSize] size of slide
63
+ # @return [Array<Symbol>] type of align
50
64
  def content_distribute(object, slide_size)
51
65
  return %i[horizontally vertically] if content_horizontal_align(object, slide_size) == :center && content_vertical_align(object, slide_size) == :middle
52
66
  return [:horizontally] if content_horizontal_align(object, slide_size) == :center
@@ -7,6 +7,9 @@ module OoxmlParser
7
7
  class Transition < OOXMLDocumentObject
8
8
  attr_accessor :speed, :properties, :sound_action, :advance_on_click, :delay, :duration
9
9
 
10
+ # Parse Transition object
11
+ # @param node [Nokogiri::XML:Element] node to parse
12
+ # @return [Transition] result of parsing
10
13
  def parse(node)
11
14
  node.xpath('*').each do |node_child|
12
15
  @properties = TransitionProperties.new(parent: self).parse(node_child)
@@ -5,6 +5,9 @@ require_relative 'pptx_data/presentation.rb'
5
5
  module OoxmlParser
6
6
  # Basic class for parsing pptx
7
7
  class PptxParser
8
+ # Parse pptx file
9
+ # @param path_to_file [String] file path
10
+ # @return [Presentation] result of parse
8
11
  def self.parse_pptx(path_to_file)
9
12
  Parser.parse_format(path_to_file) do
10
13
  Presentation.new.parse
@@ -3,6 +3,7 @@
3
3
  module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.6.0'
6
+ # [String] Version of Gem
7
+ STRING = '0.7.0'
7
8
  end
8
9
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'workbook/chartsheet'
4
+ require_relative 'workbook/pivot_cache'
4
5
  require_relative 'workbook/shared_string_table'
5
6
  require_relative 'workbook/style_sheet'
6
7
  require_relative 'workbook/worksheet'
@@ -18,12 +19,20 @@ module OoxmlParser
18
19
  attr_accessor :style_sheet
19
20
  # @return [SharedStringTable] styles of book
20
21
  attr_accessor :shared_strings_table
22
+ # @return [Array<PivotCache>] list of pivot caches
23
+ attr_accessor :pivot_caches
21
24
 
22
25
  def initialize(params = {})
23
26
  @worksheets = []
27
+ @pivot_caches = []
24
28
  super
25
29
  end
26
30
 
31
+ # Return cell by coordinates
32
+ # @param column [String, Integer] number or numeric digit of column
33
+ # @param row [Integer] row to find
34
+ # @param sheet [Integer] number of sheet
35
+ # @return [XlsxCell] result
27
36
  def cell(column, row, sheet = 0)
28
37
  column = Coordinates.new(row, column).column_number unless StringHelper.numeric?(column.to_s)
29
38
 
@@ -88,6 +97,8 @@ module OoxmlParser
88
97
  @shared_strings_table = SharedStringTable.new(parent: self).parse(shared_string_file)
89
98
  end
90
99
 
100
+ # Parse content of Workbook
101
+ # @return [XLSXWorkbook]
91
102
  def parse
92
103
  @content_types = ContentTypes.new(parent: self).parse
93
104
  @relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}xl/_rels/workbook.xml.rels")
@@ -95,10 +106,10 @@ module OoxmlParser
95
106
  OOXMLDocumentObject.xmls_stack = []
96
107
  OOXMLDocumentObject.root_subfolder = 'xl/'
97
108
  OOXMLDocumentObject.add_to_xmls_stack('xl/workbook.xml')
98
- doc = Nokogiri::XML.parse(File.open(OOXMLDocumentObject.current_xml))
109
+ @doc = Nokogiri::XML.parse(File.open(OOXMLDocumentObject.current_xml))
99
110
  @theme = PresentationTheme.parse("xl/#{link_to_theme_xml}") if link_to_theme_xml
100
111
  @style_sheet = StyleSheet.new(parent: self).parse
101
- doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
112
+ @doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
102
113
  file = @relationships.target_by_id(sheet.attribute('id').value)
103
114
  if file.start_with?('worksheets')
104
115
  @worksheets << Worksheet.new(parent: self).parse(file)
@@ -107,6 +118,7 @@ module OoxmlParser
107
118
  @worksheets << Chartsheet.new(parent: self).parse(file)
108
119
  end
109
120
  end
121
+ parse_pivot_cache
110
122
  OOXMLDocumentObject.xmls_stack.pop
111
123
  self
112
124
  end
@@ -116,5 +128,12 @@ module OoxmlParser
116
128
  def link_to_theme_xml
117
129
  relationships.target_by_type('theme').first
118
130
  end
131
+
132
+ # Perform parsing of pivot cache
133
+ def parse_pivot_cache
134
+ @doc.xpath('xmlns:workbook/xmlns:pivotCaches/xmlns:pivotCache').each do |pivot_cache|
135
+ @pivot_caches << PivotCache.new(parent: self).parse(pivot_cache)
136
+ end
137
+ end
119
138
  end
120
139
  end
@@ -11,6 +11,9 @@ module OoxmlParser
11
11
  @parent = parent
12
12
  end
13
13
 
14
+ # Parse Chartsheet object
15
+ # @param file [String] file to parse
16
+ # @return [Chartsheet] result of parsing
14
17
  def parse(file)
15
18
  OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.root_subfolder + file)
16
19
  doc = parse_xml(OOXMLDocumentObject.current_xml)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pivot_cache/pivot_cache_definition'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <pivotCache> tag
7
+ class PivotCache < OOXMLDocumentObject
8
+ # @return [Integer] cacheId of pivot cache
9
+ attr_reader :cache_id
10
+ # @return [String] id of pivot cache
11
+ attr_reader :id
12
+ # @return [PivotCacheDefinition] parsed pivot cache definition
13
+ attr_reader :pivot_cache_definition
14
+
15
+ # Parse Pivot Cache data
16
+ # @param [Nokogiri::XML:Element] node with Pivot Cache data
17
+ # @return [PivotCache] value of PivotCache
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'cacheId'
22
+ @cache_id = value.value.to_i
23
+ when 'id'
24
+ @id = value.value.to_s
25
+ end
26
+ end
27
+ parse_pivot_cache_definition
28
+ self
29
+ end
30
+
31
+ private
32
+
33
+ # @return [PivotCacheDefinition] pivot cache definition for current pivot cache
34
+ def parse_pivot_cache_definition
35
+ definition_file = root_object.relationships.target_by_id(id)
36
+ full_file_path = "#{OOXMLDocumentObject.path_to_folder}/xl/#{definition_file}"
37
+ @pivot_cache_definition = PivotCacheDefinition.new(parent: root_object)
38
+ .parse(full_file_path)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pivot_cache_definition/cache_source'
4
+ module OoxmlParser
5
+ # Class for parsing <pivotCacheDefinition> file
6
+ class PivotCacheDefinition < OOXMLDocumentObject
7
+ # @return [String] id of pivot cache definition
8
+ attr_reader :id
9
+ # @return [CacheSource] source of pivot cache
10
+ attr_reader :cache_source
11
+
12
+ # Parse PivotCacheDefinition file
13
+ # @param file [String] path to file
14
+ # @return [PivotCacheDefinition]
15
+ def parse(file)
16
+ return nil unless File.exist?(file)
17
+
18
+ document = parse_xml(file)
19
+ node = document.xpath('*').first
20
+
21
+ node.attributes.each do |key, value|
22
+ case key
23
+ when 'id'
24
+ @id = value.value.to_s
25
+ end
26
+ end
27
+
28
+ node.xpath('*').each do |node_child|
29
+ case node_child.name
30
+ when 'cacheSource'
31
+ @cache_source = CacheSource.new(parent: self).parse(node_child)
32
+ end
33
+ end
34
+ self
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cache_source/worksheet_source'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <cacheSource> file
7
+ class CacheSource < OOXMLDocumentObject
8
+ # @return [String] type
9
+ attr_reader :type
10
+ # @return [WorksheetSource] source of worksheet data
11
+ attr_reader :worksheet_source
12
+
13
+ # Parse `<cacheSource>` tag
14
+ # # @param [Nokogiri::XML:Element] node with CacheSource data
15
+ # @return [CacheSource]
16
+ def parse(node)
17
+ node.attributes.each do |key, value|
18
+ case key
19
+ when 'type'
20
+ @type = value.value.to_s
21
+ end
22
+ end
23
+
24
+ node.xpath('*').each do |node_child|
25
+ case node_child.name
26
+ when 'worksheetSource'
27
+ @worksheet_source = WorksheetSource.new(parent: self).parse(node_child)
28
+ end
29
+ end
30
+ self
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <worksheetSource> file
5
+ class WorksheetSource < OOXMLDocumentObject
6
+ # @return [String] ref of cells
7
+ attr_reader :ref
8
+ # @return [String] sheet name
9
+ attr_reader :sheet
10
+
11
+ # Parse `<worksheetSource>` tag
12
+ # # @param [Nokogiri::XML:Element] node with WorksheetSource data
13
+ # @return [WorksheetSource]
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'ref'
18
+ @ref = value.value.to_s
19
+ when 'sheet'
20
+ @sheet = value.value.to_s
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -26,6 +26,8 @@ module OoxmlParser
26
26
  @parent = parent
27
27
  end
28
28
 
29
+ # Parse StyleSheet object
30
+ # @return [StyleSheet] result of parsing
29
31
  def parse
30
32
  doc = parse_xml("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/styles.xml")
31
33
  doc.root.xpath('*').each do |node_child|
@@ -4,6 +4,7 @@ require_relative 'cell_style/alignment'
4
4
  module OoxmlParser
5
5
  # Class for parsing `xf` object
6
6
  class Xf < OOXMLDocumentObject
7
+ # [Array<String,nil>] list of predefined format values
7
8
  ALL_FORMAT_VALUE = ['General',
8
9
  '0',
9
10
  '0.00',
@@ -119,18 +120,22 @@ module OoxmlParser
119
120
  self
120
121
  end
121
122
 
123
+ # @return [Font] font of object
122
124
  def font
123
125
  root_object.style_sheet.fonts[@font_id]
124
126
  end
125
127
 
128
+ # @return [XlsxBorder] border of object
126
129
  def borders
127
130
  root_object.style_sheet.borders.borders_array[@border_id] if @apply_border
128
131
  end
129
132
 
133
+ # @return [Fill] fill color of object
130
134
  def fill_color
131
135
  root_object.style_sheet.fills[@fill_id] if @apply_fill
132
136
  end
133
137
 
138
+ # @return [String] numerical format of object
134
139
  def numerical_format
135
140
  return @numerical_format unless @apply_number_format
136
141
 
@@ -40,6 +40,8 @@ module OoxmlParser
40
40
  self
41
41
  end
42
42
 
43
+ # Convert Fill to color
44
+ # @return [OoxmlColor] result
43
45
  def to_color
44
46
  pattern_fill.foreground_color
45
47
  end
@@ -13,6 +13,9 @@ module OoxmlParser
13
13
  @parent = parent
14
14
  end
15
15
 
16
+ # Parse Font object
17
+ # @param node [Nokogiri::XML:Element] node to parse
18
+ # @return [Font] result of parsing
16
19
  def parse(node)
17
20
  @font_style = FontStyle.new
18
21
  node.xpath('*').each do |node_child|
@@ -42,6 +42,8 @@ module OoxmlParser
42
42
  @parent = parent
43
43
  end
44
44
 
45
+ # Perform parsing of relationships
46
+ # @return [nil]
45
47
  def parse_relationships
46
48
  OOXMLDocumentObject.add_to_xmls_stack("#{OOXMLDocumentObject.root_subfolder}/worksheets/_rels/#{@xml_name}.rels")
47
49
  @relationships = Relationships.new(parent: self).parse_file(OOXMLDocumentObject.current_xml) if File.exist?(OOXMLDocumentObject.current_xml)
@@ -67,6 +69,9 @@ module OoxmlParser
67
69
  end
68
70
  end
69
71
 
72
+ # Parse data of Worksheet
73
+ # @param path_to_xml_file [String] path to file to parse
74
+ # @return [Worksheet] parsed worksheet
70
75
  def parse(path_to_xml_file)
71
76
  @xml_name = File.basename path_to_xml_file
72
77
  parse_relationships
@@ -16,6 +16,7 @@ module OoxmlParser
16
16
  @parent = parent
17
17
  end
18
18
 
19
+ # @return [Array<ExcelComment>] list of comments
19
20
  def comments
20
21
  comment_list.comments
21
22
  end
@@ -23,6 +24,9 @@ module OoxmlParser
23
24
  extend Gem::Deprecate
24
25
  deprecate :comments, 'comment_list.comments', 2020, 1
25
26
 
27
+ # Parse file with ExcelComments
28
+ # @param file [String] file to parse
29
+ # @return [ExcelComments] object with data
26
30
  def parse(file)
27
31
  doc = parse_xml(file)
28
32
  node = doc.xpath('*').first
@@ -38,6 +38,10 @@ module OoxmlParser
38
38
  self
39
39
  end
40
40
 
41
+ # Parse list of XlsxColumnProperties
42
+ # @param columns_width_node [Nokogiri::XML:Element] node to parse
43
+ # @param parent [OOXMLDocumentObject] parent of result objects
44
+ # @return [Array<XlsxColumnProperties>] list of XlsxColumnProperties
41
45
  def self.parse_list(columns_width_node, parent: nil)
42
46
  columns = []
43
47
  columns_width_node.xpath('xmlns:col').each do |col_node|
@@ -5,6 +5,9 @@ require_relative 'xlsx_data/view_model/workbook'
5
5
  module OoxmlParser
6
6
  # Basic class for parsing xlsx
7
7
  class XlsxParser
8
+ # Parse xlsx file
9
+ # @param path_to_file [String] file path
10
+ # @return [XLSXWorkbook] result of parse
8
11
  def self.parse_xlsx(path_to_file)
9
12
  Parser.parse_format(path_to_file) do
10
13
  XLSXWorkbook.new.parse
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.6.0
4
+ version: 0.7.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: 2020-05-29 00:00:00.000000000 Z
13
+ date: 2020-07-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -74,6 +74,62 @@ dependencies:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '13.0'
77
+ - !ruby/object:Gem::Dependency
78
+ name: rubocop
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '='
82
+ - !ruby/object:Gem::Version
83
+ version: 0.87.1
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.87.1
91
+ - !ruby/object:Gem::Dependency
92
+ name: rubocop-performance
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '='
96
+ - !ruby/object:Gem::Version
97
+ version: 1.7.0
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 1.7.0
105
+ - !ruby/object:Gem::Dependency
106
+ name: rubocop-rake
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '='
110
+ - !ruby/object:Gem::Version
111
+ version: 0.5.1
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '='
117
+ - !ruby/object:Gem::Version
118
+ version: 0.5.1
119
+ - !ruby/object:Gem::Dependency
120
+ name: rubocop-rspec
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '='
124
+ - !ruby/object:Gem::Version
125
+ version: 1.42.0
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '='
131
+ - !ruby/object:Gem::Version
132
+ version: 1.42.0
77
133
  description: Parse OOXML files (docx, xlsx, pptx)
78
134
  email:
79
135
  - shockwavenn@gmail.com
@@ -365,6 +421,10 @@ files:
365
421
  - lib/ooxml_parser/version.rb
366
422
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb
367
423
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb
424
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb
425
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb
426
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb
427
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb
368
428
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb
369
429
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table/string_index.rb
370
430
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
@@ -429,14 +489,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
429
489
  requirements:
430
490
  - - ">="
431
491
  - !ruby/object:Gem::Version
432
- version: '2.3'
492
+ version: '2.4'
433
493
  required_rubygems_version: !ruby/object:Gem::Requirement
434
494
  requirements:
435
495
  - - ">="
436
496
  - !ruby/object:Gem::Version
437
497
  version: '0'
438
498
  requirements: []
439
- rubygems_version: 3.1.2
499
+ rubygems_version: 3.2.0.pre1
440
500
  signing_key:
441
501
  specification_version: 4
442
502
  summary: OoxmlParser Gem