ooxml_parser 0.8.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +55 -48
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/pivot_formats.rb +1 -1
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/plot_area/common_chart_data.rb +1 -1
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/number_string_cache.rb +1 -1
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +6 -10
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +1 -1
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +1 -1
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +4 -6
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +4 -4
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +1 -1
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +1 -1
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -1
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +1 -1
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -1
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +0 -4
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +0 -4
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +0 -4
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +0 -4
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +0 -4
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +1 -1
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -1
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb +1 -1
  24. 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
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +1 -1
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -1
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -1
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry/shape_adjust_value_list.rb +1 -1
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +1 -1
  30. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +1 -1
  31. data/lib/ooxml_parser/common_parser/common_data/color.rb +6 -6
  32. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +29 -0
  33. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +0 -33
  34. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +1 -1
  35. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +1 -1
  36. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +1 -1
  37. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +1 -1
  38. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +8 -1
  39. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +2 -2
  40. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +2 -2
  41. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +1 -1
  42. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +1 -1
  43. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +2 -4
  44. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +1 -1
  45. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +3 -3
  46. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +1 -1
  47. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +1 -1
  48. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +1 -1
  49. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +1 -1
  50. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +1 -1
  51. data/lib/ooxml_parser/common_parser/common_data/relationships.rb +1 -1
  52. data/lib/ooxml_parser/common_parser/common_data/table.rb +1 -1
  53. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +1 -5
  54. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +2 -2
  55. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +1 -1
  56. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -1
  57. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +1 -1
  58. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/grid_span.rb +1 -7
  59. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +1 -1
  60. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +1 -1
  61. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +1 -1
  62. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +1 -1
  63. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +1 -1
  64. data/lib/ooxml_parser/common_parser/common_data/underline.rb +1 -1
  65. data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +1 -1
  66. data/lib/ooxml_parser/common_parser/common_document_structure.rb +1 -0
  67. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +2 -2
  68. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb +2 -2
  69. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +1 -1
  70. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb +2 -2
  71. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +1 -1
  72. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +1 -1
  73. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +1 -1
  74. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +4 -4
  75. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +1 -1
  76. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +1 -1
  77. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +1 -1
  78. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +1 -1
  79. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +1 -1
  80. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +1 -1
  81. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +1 -1
  82. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +1 -1
  83. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +1 -1
  84. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +1 -1
  85. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +38 -21
  86. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +2 -2
  87. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +1 -1
  88. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb +1 -1
  89. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +1 -1
  90. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +1 -1
  91. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +5 -8
  92. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +1 -1
  93. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +2 -2
  94. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +1 -1
  95. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +1 -1
  96. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +1 -1
  97. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +1 -0
  98. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +1 -0
  99. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +1 -0
  100. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +1 -1
  101. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +2 -1
  102. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -2
  103. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb +1 -1
  104. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb +1 -1
  105. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -0
  106. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -1
  107. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +1 -1
  108. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +1 -1
  109. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +1 -1
  110. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -2
  111. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +1 -1
  112. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +1 -1
  113. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +1 -1
  114. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +1 -1
  115. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +1 -1
  116. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +1 -1
  117. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition_list.rb +1 -1
  118. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +1 -3
  119. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +1 -1
  120. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb +1 -1
  121. data/lib/ooxml_parser/version.rb +1 -1
  122. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +17 -3
  123. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +1 -1
  124. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +6 -0
  125. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields.rb +43 -0
  126. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb +37 -0
  127. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field/shared_items.rb +42 -0
  128. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition.rb +114 -0
  129. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items.rb +43 -0
  130. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items/column_row_item.rb +22 -0
  131. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/location.rb +34 -0
  132. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields.rb +43 -0
  133. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field.rb +37 -0
  134. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb +43 -0
  135. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items/item.rb +26 -0
  136. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_table_style_info.rb +42 -0
  137. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb +1 -1
  138. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +1 -1
  139. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb +1 -1
  140. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb +5 -5
  141. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +1 -1
  142. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +1 -1
  143. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +1 -1
  144. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +1 -1
  145. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +1 -1
  146. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +1 -1
  147. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb +1 -1
  148. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +1 -1
  149. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +1 -1
  150. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/comment_list.rb +1 -1
  151. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +1 -1
  152. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
  153. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +1 -1
  154. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters.rb +1 -1
  155. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +1 -1
  156. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +1 -1
  157. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_columns.rb +1 -1
  158. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +1 -1
  159. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +1 -1
  160. metadata +110 -35
  161. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cache_field/shared_items'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <cacheField> tag
7
+ class CacheField < OOXMLDocumentObject
8
+ # @return [String] name of field
9
+ attr_reader :name
10
+ # @return [Integer] number format id
11
+ attr_reader :number_format_id
12
+ # @return [SharedItems] shared items
13
+ attr_reader :shared_items
14
+
15
+ # Parse `<cacheField>` tag
16
+ # # @param [Nokogiri::XML:Element] node with WorksheetSource data
17
+ # @return [CacheField]
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'name'
22
+ @name = value.value.to_s
23
+ when 'numFmtId'
24
+ @number_format_id = value.value.to_i
25
+ end
26
+ end
27
+
28
+ node.xpath('*').each do |node_child|
29
+ case node_child.name
30
+ when 'sharedItems'
31
+ @shared_items = SharedItems.new(parent: self).parse(node_child)
32
+ end
33
+ end
34
+ self
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <sharedItems> tag
5
+ class SharedItems < OOXMLDocumentObject
6
+ # @return [True, False] is contains_semi_mixed_types
7
+ attr_reader :contains_semi_mixed_types
8
+ # @return [True, False] is contains_string
9
+ attr_reader :contains_string
10
+ # @return [True, False] is contains_number
11
+ attr_reader :contains_number
12
+ # @return [True, False] is contains_integer
13
+ attr_reader :contains_integer
14
+ # @return [Integer] min value
15
+ attr_reader :min_value
16
+ # @return [Integer] max value
17
+ attr_reader :max_value
18
+
19
+ # Parse `<sharedItems>` tag
20
+ # # @param [Nokogiri::XML:Element] node with WorksheetSource data
21
+ # @return [sharedItems]
22
+ def parse(node)
23
+ node.attributes.each do |key, value|
24
+ case key
25
+ when 'containsSemiMixedTypes'
26
+ @contains_semi_mixed_types = attribute_enabled?(value)
27
+ when 'containsString'
28
+ @contains_string = attribute_enabled?(value)
29
+ when 'containsNumber'
30
+ @contains_number = attribute_enabled?(value)
31
+ when 'containsInteger'
32
+ @contains_integer = attribute_enabled?(value)
33
+ when 'minValue'
34
+ @min_value = value.value.to_i
35
+ when 'maxValue'
36
+ @max_value = value.value.to_i
37
+ end
38
+ end
39
+ self
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pivot_table_definition/column_row_items'
4
+ require_relative 'pivot_table_definition/location'
5
+ require_relative 'pivot_table_definition/pivot_fields'
6
+ require_relative 'pivot_table_definition/pivot_table_style_info'
7
+
8
+ module OoxmlParser
9
+ # Class for parsing <PivotTableDefinition> tag
10
+ class PivotTableDefinition < OOXMLDocumentObject
11
+ # @return [String] name of table
12
+ attr_reader :name
13
+ # @return [Integer] id of cache
14
+ attr_reader :cache_id
15
+ # @return [True, False] should number formats be applied
16
+ attr_reader :apply_number_formats
17
+ # @return [True, False] should border formats be applied
18
+ attr_reader :apply_border_formats
19
+ # @return [True, False] should font formats be applied
20
+ attr_reader :apply_font_formats
21
+ # @return [True, False] should pattern formats be applied
22
+ attr_reader :apply_pattern_formats
23
+ # @return [True, False] should alignment formats be applied
24
+ attr_reader :apply_alignment_formats
25
+ # @return [True, False] should width height formats be applied
26
+ attr_reader :apply_width_height_formats
27
+ # @return [True, False] should auto formatting be used
28
+ attr_reader :use_auto_formatting
29
+ # @return [True, False] should item print titles
30
+ attr_reader :item_print_titles
31
+ # @return [String] data caption
32
+ attr_reader :data_caption
33
+ # @return [Integer] creation version
34
+ attr_reader :created_version
35
+ # @return [Integer] indent
36
+ attr_reader :indent
37
+ # @return [True, False] outline
38
+ attr_reader :outline
39
+ # @return [True, False] outline data
40
+ attr_reader :outline_data
41
+ # @return [True, False] is there multiple fields filters
42
+ attr_reader :multiple_field_filters
43
+ # @return [Location] location data
44
+ attr_reader :location
45
+ # @return [PivotFields] pivot fields
46
+ attr_reader :pivot_fields
47
+ # @return [ColumnRowItems] column items
48
+ attr_reader :column_items
49
+ # @return [ColumnRowItems] row items
50
+ attr_reader :row_items
51
+ # @return [PivotTableStyleInfo] style info
52
+ attr_reader :style_info
53
+
54
+ # Parse PivotTableDefinition object
55
+ # @param [String] file path
56
+ # @return [PivotTableDefinition] result of parsing
57
+ def parse(file)
58
+ doc = Nokogiri::XML.parse(File.open("#{OOXMLDocumentObject.path_to_folder}/#{file}"))
59
+ node = doc.xpath('//xmlns:pivotTableDefinition').first
60
+ node.attributes.each do |key, value|
61
+ case key
62
+ when 'name'
63
+ @name = value.value.to_s
64
+ when 'cacheId'
65
+ @cache_id = value.value.to_i
66
+ when 'applyNumberFormats'
67
+ @apply_number_formats = attribute_enabled?(value)
68
+ when 'applyBorderFormats'
69
+ @apply_border_formats = attribute_enabled?(value)
70
+ when 'applyFontFormats'
71
+ @apply_font_formats = attribute_enabled?(value)
72
+ when 'applyPatternFormats'
73
+ @apply_pattern_formats = attribute_enabled?(value)
74
+ when 'applyAlignmentFormats'
75
+ @apply_alignment_formats = attribute_enabled?(value)
76
+ when 'applyWidthHeightFormats'
77
+ @apply_width_height_formats = attribute_enabled?(value)
78
+ when 'useAutoFormatting'
79
+ @use_auto_formatting = attribute_enabled?(value)
80
+ when 'itemPrintTitles'
81
+ @item_print_titles = attribute_enabled?(value)
82
+ when 'dataCaption'
83
+ @data_caption = value.value.to_s
84
+ when 'createdVersion'
85
+ @created_version = value.value.to_i
86
+ when 'indent'
87
+ @indent = value.value.to_i
88
+ when 'outline'
89
+ @outline = attribute_enabled?(value)
90
+ when 'outlineData'
91
+ @outline_data = attribute_enabled?(value)
92
+ when 'multipleFieldFilters'
93
+ @multiple_field_filters = attribute_enabled?(value)
94
+ end
95
+ end
96
+
97
+ node.xpath('*').each do |node_child|
98
+ case node_child.name
99
+ when 'location'
100
+ @location = Location.new(parent: self).parse(node_child)
101
+ when 'pivotFields'
102
+ @pivot_fields = PivotFields.new(parent: self).parse(node_child)
103
+ when 'rowItems'
104
+ @row_items = ColumnRowItems.new(parent: self).parse(node_child)
105
+ when 'colItems'
106
+ @column_items = ColumnRowItems.new(parent: self).parse(node_child)
107
+ when 'pivotTableStyleInfo'
108
+ @style_info = PivotTableStyleInfo.new(parent: self).parse(node_child)
109
+ end
110
+ end
111
+ self
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'column_row_items/column_row_item'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <rowItems> and <colItems> tag
7
+ class ColumnRowItems < OOXMLDocumentObject
8
+ # @return [Integer] count of items
9
+ attr_reader :count
10
+ # @return [Array<RowColumnItem>] list of RowColumnItem object
11
+ attr_reader :items
12
+
13
+ def initialize(parent: nil)
14
+ @items = []
15
+ super
16
+ end
17
+
18
+ # @return [RowColumnItem] accessor
19
+ def [](key)
20
+ @items[key]
21
+ end
22
+
23
+ # Parse `<cacheField>` tag
24
+ # # @param [Nokogiri::XML:Element] node with WorksheetSource data
25
+ # @return [CacheField]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'i'
37
+ @items << ColumnRowItem.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <i> tag
5
+ class ColumnRowItem < OOXMLDocumentObject
6
+ # @return [Symbol] type of item
7
+ attr_reader :type
8
+
9
+ # Parse `<location>` tag
10
+ # @param [Nokogiri::XML:Element] node with location data
11
+ # @return [Location]
12
+ def parse(node)
13
+ node.attributes.each do |key, value|
14
+ case key
15
+ when 't'
16
+ @type = value.value.to_sym
17
+ end
18
+ end
19
+ self
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <location> tag
5
+ class Location < OOXMLDocumentObject
6
+ # @return [String] ref of location
7
+ attr_reader :ref
8
+ # @return [True, False] first header row
9
+ attr_reader :first_header_row
10
+ # @return [True, False] first data row
11
+ attr_reader :first_data_row
12
+ # @return [True, False] first data column
13
+ attr_reader :first_data_column
14
+
15
+ # Parse `<location>` tag
16
+ # @param [Nokogiri::XML:Element] node with location data
17
+ # @return [Location]
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'ref'
22
+ @ref = value.value.to_s
23
+ when 'firstHeaderRow'
24
+ @first_header_row = attribute_enabled?(value)
25
+ when 'firstDataRow'
26
+ @first_data_row = attribute_enabled?(value)
27
+ when 'firstDataCol'
28
+ @first_data_column = attribute_enabled?(value)
29
+ end
30
+ end
31
+ self
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pivot_fields/pivot_field'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <pivotFields> tag
7
+ class PivotFields < OOXMLDocumentObject
8
+ # @return [Integer] count
9
+ attr_reader :count
10
+ # @return [Array<PivotField>] list of PivotField object
11
+ attr_reader :pivot_field
12
+
13
+ def initialize(parent: nil)
14
+ @pivot_field = []
15
+ super
16
+ end
17
+
18
+ # @return [PivotField] accessor
19
+ def [](key)
20
+ @pivot_field[key]
21
+ end
22
+
23
+ # Parse `<pivotFields>` tag
24
+ # @param [Nokogiri::XML:Element] node with pivotFields data
25
+ # @return [PivotFields]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'pivotField'
37
+ @pivot_field << PivotField.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pivot_field/items'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <pivotField> tag
7
+ class PivotField < OOXMLDocumentObject
8
+ # @return [String] axis value
9
+ attr_reader :axis
10
+ # @return [True, False] should show all
11
+ attr_reader :show_all
12
+ # @return [Items] contain item
13
+ attr_reader :items
14
+
15
+ # Parse `<pivotField>` tag
16
+ # # @param [Nokogiri::XML:Element] node with PivotField data
17
+ # @return [PivotField]
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'axis'
22
+ @axis = value.value.to_s
23
+ when 'showAll'
24
+ @show_all = attribute_enabled?(value)
25
+ end
26
+ end
27
+
28
+ node.xpath('*').each do |node_child|
29
+ case node_child.name
30
+ when 'items'
31
+ @items = Items.new(parent: self).parse(node_child)
32
+ end
33
+ end
34
+ self
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'items/item'
4
+
5
+ module OoxmlParser
6
+ # Class for parsing <items> tag
7
+ class Items < OOXMLDocumentObject
8
+ # @return [Integer] count
9
+ attr_reader :count
10
+ # @return [Array<Item>] list of items
11
+ attr_reader :items
12
+
13
+ def initialize(parent: nil)
14
+ @items = []
15
+ super
16
+ end
17
+
18
+ # @return [Item] accessor
19
+ def [](key)
20
+ @items[key]
21
+ end
22
+
23
+ # Parse `<items>` tag
24
+ # @param [Nokogiri::XML:Element] node with items data
25
+ # @return [Items]
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
28
+ case key
29
+ when 'count'
30
+ @count = value.value.to_i
31
+ end
32
+ end
33
+
34
+ node.xpath('*').each do |node_child|
35
+ case node_child.name
36
+ when 'item'
37
+ @items << Item.new(parent: self).parse(node_child)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <item> tag
5
+ class Item < OOXMLDocumentObject
6
+ # @return [Integer] index of item
7
+ attr_reader :index
8
+ # @return [Symbol] type of item
9
+ attr_reader :type
10
+
11
+ # Parse `<item>` tag
12
+ # # @param [Nokogiri::XML:Element] node with Item data
13
+ # @return [item]
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'x'
18
+ @index = value.value.to_i
19
+ when 't'
20
+ @type = value.value.to_sym
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end