ooxml_parser 0.8.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) 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 +7 -11
  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 +6 -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 +1 -1
  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 +14 -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 +5 -9
  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 +6 -10
  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_helper.rb +7 -0
  85. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +1 -1
  86. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +38 -21
  87. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +2 -2
  88. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +1 -1
  89. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb +1 -1
  90. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +1 -1
  91. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +1 -1
  92. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +5 -8
  93. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +1 -1
  94. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +2 -2
  95. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +1 -1
  96. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +1 -1
  97. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +1 -1
  98. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +1 -0
  99. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +1 -0
  100. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +1 -0
  101. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +1 -1
  102. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +2 -1
  103. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -2
  104. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb +1 -1
  105. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb +1 -1
  106. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -0
  107. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -1
  108. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +1 -1
  109. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +1 -1
  110. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +1 -1
  111. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -2
  112. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +1 -1
  113. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +1 -1
  114. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +1 -1
  115. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +1 -1
  116. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +1 -1
  117. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +1 -1
  118. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition_list.rb +1 -1
  119. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +1 -3
  120. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +1 -1
  121. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb +1 -1
  122. data/lib/ooxml_parser/version.rb +1 -1
  123. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +17 -3
  124. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +1 -1
  125. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +6 -0
  126. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields.rb +43 -0
  127. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb +37 -0
  128. 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
  129. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition.rb +114 -0
  130. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items.rb +43 -0
  131. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items/column_row_item.rb +22 -0
  132. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/location.rb +34 -0
  133. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields.rb +43 -0
  134. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field.rb +37 -0
  135. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb +43 -0
  136. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items/item.rb +26 -0
  137. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_table_style_info.rb +42 -0
  138. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb +1 -1
  139. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +1 -1
  140. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb +1 -1
  141. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb +5 -5
  142. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +1 -1
  143. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +1 -1
  144. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +1 -1
  145. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +1 -1
  146. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +1 -1
  147. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +1 -1
  148. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb +1 -1
  149. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +1 -1
  150. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +1 -1
  151. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/comment_list.rb +1 -1
  152. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +1 -1
  153. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
  154. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +1 -1
  155. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters.rb +1 -1
  156. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +1 -1
  157. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +1 -1
  158. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_columns.rb +1 -1
  159. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +1 -1
  160. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +1 -1
  161. metadata +111 -36
  162. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
@@ -29,7 +29,7 @@ module OoxmlParser
29
29
 
30
30
  def initialize(parent: nil)
31
31
  @line = DocxShapeLine.new
32
- @parent = parent
32
+ super
33
33
  end
34
34
 
35
35
  # Parse DocxShapeProperties object
@@ -9,7 +9,7 @@ module OoxmlParser
9
9
 
10
10
  def initialize(parent: nil)
11
11
  @shape_guides_list = []
12
- @parent = parent
12
+ super
13
13
  end
14
14
 
15
15
  # @return [Array, Column] accessor for relationship
@@ -10,7 +10,7 @@ module OoxmlParser
10
10
  def initialize(properties = OldDocxGroupProperties.new, parent: nil)
11
11
  @properties = properties
12
12
  @elements = []
13
- @parent = parent
13
+ super(parent: parent)
14
14
  end
15
15
 
16
16
  # Parse OldDocxGroup object
@@ -12,7 +12,7 @@ module OoxmlParser
12
12
  @size = size
13
13
  @val = val
14
14
  @space = space
15
- @parent = parent
15
+ super(parent: parent)
16
16
  end
17
17
 
18
18
  # @return [OoxmlSize] alias for sz
@@ -43,7 +43,7 @@ module OoxmlParser
43
43
  @red = new_red
44
44
  @green = new_green
45
45
  @blue = new_blue
46
- @parent = parent
46
+ super(parent: parent)
47
47
  end
48
48
 
49
49
  # @return [String] result of convert of object to string
@@ -94,13 +94,9 @@ module OoxmlParser
94
94
  # @return [True, False] result of comparision
95
95
  def ==(other)
96
96
  if other.is_a?(Color)
97
- if (@red == other.red) && (@green == other.green) && (@blue == other.blue)
98
- true
99
- elsif (none? && other.white?) || (white? && other.none?)
100
- true
101
- else
102
- false
103
- end
97
+ ((@red == other.red) && (@green == other.green) && (@blue == other.blue)) ||
98
+ (none? && other.white?) ||
99
+ (white? && other.none?)
104
100
  else
105
101
  false
106
102
  end
@@ -125,7 +121,7 @@ module OoxmlParser
125
121
  red = color_to_check.red
126
122
  green = color_to_check.green
127
123
  blue = color_to_check.blue
128
- (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
124
+ (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta
129
125
  end
130
126
 
131
127
  # Apply tint to color
@@ -151,7 +147,7 @@ module OoxmlParser
151
147
  # @return [Color] result of parsing
152
148
  def parse_scheme_color(scheme_color_node)
153
149
  color = root_object.theme.color_scheme[scheme_color_node.attribute('val').value.to_sym].color
154
- hls = HSLColor.rgb_to_hsl(color)
150
+ hls = color.to_hsl
155
151
  scheme_name = nil
156
152
  scheme_color_node.xpath('*').each do |scheme_color_node_child|
157
153
  case scheme_color_node_child.name
@@ -268,7 +264,7 @@ module OoxmlParser
268
264
  return Color.new(VALUE_FOR_NONE_COLOR, VALUE_FOR_NONE_COLOR, VALUE_FOR_NONE_COLOR) if str == 'none' || str == '' || str == 'transparent' || str.nil?
269
265
 
270
266
  split = if str.include?('RGB (') || str.include?('rgb(')
271
- str.gsub(/[(RGBrgb() )]/, '').split(',')
267
+ str.gsub(/[(RGBrgb) ]/, '').split(',')
272
268
  elsif str.include?('RGB ') || str.include?('rgb')
273
269
  str.gsub(/RGB |rgb/, '').split(', ')
274
270
  else
@@ -26,5 +26,34 @@ module OoxmlParser
26
26
  end
27
27
  self
28
28
  end
29
+
30
+ # Convert color to HSLColor
31
+ # @return [HSLColor]
32
+ def to_hsl
33
+ hls_color = HSLColor.new
34
+
35
+ min = [red, green, blue].min.to_f
36
+ max = [red, green, blue].max.to_f
37
+
38
+ delta = (max - min).to_f
39
+ hls_color.l = (min + max) / 255.0 / 2.0
40
+ hls_color.alpha_channel = alpha_channel.to_f / 255.0
41
+
42
+ unless max == min
43
+ hls_color.s = delta / (255.0 - (255.0 - max - min).abs)
44
+
45
+ hls_color.h = if max == red && green >= blue
46
+ 60.0 * (green - blue) / delta
47
+ elsif max == red && green < blue
48
+ 60.0 * (green - blue) / delta + 360.0
49
+ elsif max == green
50
+ 60.0 * (blue - red) / delta + 120.0
51
+ else
52
+ 60.0 * (red - green) / delta + 240.0
53
+ end
54
+ end
55
+
56
+ hls_color
57
+ end
29
58
  end
30
59
  end
@@ -19,39 +19,6 @@ module OoxmlParser
19
19
  @l = lightness
20
20
  end
21
21
 
22
- # Convert rgb color to hsl
23
- # @param rgb_color [Color] color to convert
24
- # @return [HSLColor] result of convert
25
- def self.rgb_to_hsl(rgb_color)
26
- hls_color = HSLColor.new
27
- red = rgb_color.red.to_f # / 255.0
28
- green = rgb_color.green.to_f # / 255.0
29
- blue = rgb_color.blue.to_f # / 255.0
30
-
31
- min = [red, green, blue].min.to_f
32
- max = [red, green, blue].max.to_f
33
-
34
- delta = (max - min).to_f
35
- hls_color.l = (min + max) / 255.0 / 2.0
36
- hls_color.alpha_channel = rgb_color.alpha_channel.to_f / 255.0
37
-
38
- unless max == min
39
- hls_color.s = delta / (255.0 - (255.0 - max - min).abs)
40
-
41
- hls_color.h = if max == red && green >= blue
42
- 60.0 * (green - blue) / delta
43
- elsif max == red && green < blue
44
- 60.0 * (green - blue) / delta + 360.0
45
- elsif max == green
46
- 60.0 * (blue - red) / delta + 120.0
47
- else
48
- 60.0 * (red - green) / delta + 240.0
49
- end
50
- end
51
-
52
- hls_color
53
- end
54
-
55
22
  # Chroma - The "colorfulness relative to the brightness of a similarly illuminated white".
56
23
  # @return [Color] result
57
24
  def to_rgb
@@ -10,7 +10,7 @@ module OoxmlParser
10
10
 
11
11
  def initialize(parent: nil)
12
12
  @path = ''
13
- @parent = parent
13
+ super
14
14
  end
15
15
 
16
16
  # Parse ImageFill object
@@ -11,7 +11,7 @@ module OoxmlParser
11
11
 
12
12
  def initialize(parent: nil)
13
13
  @gradient_stops = []
14
- @parent = parent
14
+ super
15
15
  end
16
16
 
17
17
  # Parse GradientColor object
@@ -15,7 +15,7 @@ module OoxmlParser
15
15
  # TODO: if no swap performed - incorrect color parsing. But don't know why it needed
16
16
  themes_array[0], themes_array[1] = themes_array[1], themes_array[0]
17
17
  themes_array[2], themes_array[3] = themes_array[3], themes_array[2]
18
- hls = HSLColor.rgb_to_hsl(themes_array[theme].color)
18
+ hls = themes_array[theme].color.to_hsl
19
19
  tint = 0 if tint.nil?
20
20
  hls.calculate_rgb_with_tint(tint)
21
21
  end
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
  def initialize(offset = nil, ratio = nil, parent: nil)
9
9
  @offset = offset
10
10
  @ratio = ratio
11
- @parent = parent
11
+ super(parent: parent)
12
12
  end
13
13
 
14
14
  # Parse Tile object
@@ -9,8 +9,8 @@ module OoxmlParser
9
9
  attr_accessor :content_types_list
10
10
 
11
11
  def initialize(parent: nil)
12
- @parent = parent
13
12
  @content_types_list = []
13
+ super
14
14
  end
15
15
 
16
16
  # @return [Array] accessor
@@ -34,5 +34,12 @@ module OoxmlParser
34
34
  end
35
35
  self
36
36
  end
37
+
38
+ # Get content definition by type
39
+ # @param [String] type of definition
40
+ # @return [Object] resulting objects
41
+ def by_type(type)
42
+ @content_types_list.select { |item| item.content_type == type }
43
+ end
37
44
  end
38
45
  end
@@ -23,8 +23,8 @@ module OoxmlParser
23
23
  end
24
24
  string = string.split('!').last
25
25
  if coordinates?(string)
26
- coordinates.row = string.scan(/[0-9]/).join('').to_i
27
- coordinates.column = string.scan(/[A-Z]/).join('')
26
+ coordinates.row = string.scan(/[0-9]/).join.to_i
27
+ coordinates.column = string.scan(/[A-Z]/).join
28
28
  end
29
29
  coordinates
30
30
  end
@@ -27,8 +27,8 @@ module OoxmlParser
27
27
  @url = link
28
28
  @tooltip = tooltip
29
29
  @coordinates = coordinates
30
- @parent = parent
31
30
  @runs = []
31
+ super(parent: parent)
32
32
  end
33
33
 
34
34
  alias link url
@@ -76,7 +76,7 @@ module OoxmlParser
76
76
  @action = :last_slide
77
77
  when 'ppaction://hlinksldjump'
78
78
  @action = :slide
79
- @url = OOXMLDocumentObject.get_link_from_rels(@id).scan(/\d+/).join('').to_i
79
+ @url = OOXMLDocumentObject.get_link_from_rels(@id).scan(/\d+/).join.to_i
80
80
  else
81
81
  if @id && !@id.empty?
82
82
  @action = :external_link
@@ -108,7 +108,7 @@ module OoxmlParser
108
108
 
109
109
  # @return [String] dir to base of file
110
110
  def dir
111
- OOXMLDocumentObject.path_to_folder + File.dirname(OOXMLDocumentObject.xmls_stack.last) + '/'
111
+ "#{OOXMLDocumentObject.path_to_folder}#{File.dirname(OOXMLDocumentObject.xmls_stack.last)}/"
112
112
  end
113
113
 
114
114
  # @return [String] path to current xml file
@@ -16,7 +16,7 @@ module OoxmlParser
16
16
  @runs = runs
17
17
  @formulas = formulas
18
18
  @runs = []
19
- @parent = parent
19
+ super(parent: parent)
20
20
  end
21
21
 
22
22
  alias characters runs
@@ -30,6 +30,8 @@ module OoxmlParser
30
30
  attr_accessor :contextual_spacing
31
31
  # @return [Symbol] The alignment or justification to be applied to a paragraph
32
32
  attr_accessor :justification
33
+ # @return [Shade] Shade property
34
+ attr_accessor :shade
33
35
 
34
36
  def initialize(numbering = NumberingProperties.new, parent: nil)
35
37
  @numbering = numbering
@@ -39,7 +41,7 @@ module OoxmlParser
39
41
  :multiple)
40
42
  @keep_next = false
41
43
  @tabs = []
42
- @parent = parent
44
+ super(parent: parent)
43
45
  end
44
46
 
45
47
  # Parse ParagraphProperties object
@@ -74,9 +76,7 @@ module OoxmlParser
74
76
  @numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
75
77
  when 'framePr'
76
78
  @frame_properties = FrameProperties.new(parent: self).parse(node_child)
77
- when 'tabs'
78
- @tabs = Tabs.new(parent: self).parse(node_child)
79
- when 'tabLst'
79
+ when 'tabs', 'tabLst'
80
80
  @tabs = Tabs.new(parent: self).parse(node_child)
81
81
  when 'ind'
82
82
  @indent = Indents.new(parent: self).parse(node_child)
@@ -88,6 +88,8 @@ module OoxmlParser
88
88
  @keep_next = true
89
89
  when 'sectPr'
90
90
  @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
91
+ when 'shd'
92
+ @shade = Shade.new(parent: self).parse(node_child)
91
93
  when 'spacing'
92
94
  @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
93
95
  when 'jc'
@@ -14,7 +14,7 @@ module OoxmlParser
14
14
  def initialize(properties = RunProperties.new, text = '', parent: nil)
15
15
  @properties = properties
16
16
  @text = text
17
- @parent = parent
17
+ super(parent: parent)
18
18
  end
19
19
 
20
20
  # Parse ParagraphRun object
@@ -56,7 +56,7 @@ module OoxmlParser
56
56
  @font_name = params.fetch(:font_name, '')
57
57
  @font_style = FontStyle.new
58
58
  @baseline = :baseline
59
- @parent = params[:parent]
59
+ super(parent: params[:parent])
60
60
  end
61
61
 
62
62
  # Parse RunProperties object
@@ -11,7 +11,7 @@ module OoxmlParser
11
11
 
12
12
  def initialize(parent: nil)
13
13
  @width = OoxmlSize.new(0)
14
- @parent = parent
14
+ super
15
15
  end
16
16
 
17
17
  # Parse Outline object
@@ -17,7 +17,7 @@ module OoxmlParser
17
17
  @value = value
18
18
  @color = color
19
19
  @fill = fill
20
- @parent = parent
20
+ super(parent: parent)
21
21
  end
22
22
 
23
23
  # @return [String] text representation
@@ -43,5 +43,18 @@ module OoxmlParser
43
43
  end
44
44
  self
45
45
  end
46
+
47
+ # Helper method to get background color
48
+ # @return [OoxmlParser::Color]
49
+ def to_background_color
50
+ return nil unless fill
51
+
52
+ background_color = fill
53
+ background_color.set_style(value) if value
54
+ background_color
55
+ end
56
+
57
+ extend Gem::Deprecate
58
+ deprecate :to_background_color, 'use shade direct methods', 2077, 1
46
59
  end
47
60
  end
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(ilvl = 0, parent: nil)
9
9
  @ilvl = ilvl
10
- @parent = parent
10
+ super(parent: parent)
11
11
  end
12
12
 
13
13
  # @return [AbstractNumbering] AbstractNumbering of current properties
@@ -33,14 +33,10 @@ module OoxmlParser
33
33
  other.line_rule = :multiple if other.line_rule == :auto
34
34
  self.line_rule = line_rule.to_sym if line_rule.instance_of?(String)
35
35
 
36
- if @before == other.before &&
37
- @after == other.after &&
38
- @line == other.line &&
39
- @line_rule.to_s == other.line_rule.to_s
40
- true
41
- else
42
- false
43
- end
36
+ @before == other.before &&
37
+ @after == other.after &&
38
+ @line == other.line &&
39
+ @line_rule.to_s == other.line_rule.to_s
44
40
  end
45
41
 
46
42
  # @return [String] result of convert of object to string
@@ -48,7 +44,7 @@ module OoxmlParser
48
44
  result_string = ''
49
45
  variables = instance_variables
50
46
  variables.each do |current_variable|
51
- result_string += current_variable.to_s.sub('@', '') + ': ' + instance_variable_get(current_variable).to_s + "\n"
47
+ result_string += "#{current_variable.to_s.sub('@', '')}: #{instance_variable_get(current_variable)}\n"
52
48
  end
53
49
  result_string
54
50
  end
@@ -9,7 +9,7 @@ module OoxmlParser
9
9
 
10
10
  def initialize(parent: nil)
11
11
  @tabs_array = []
12
- @parent = parent
12
+ super
13
13
  end
14
14
 
15
15
  # @return [Array, Column] accessor
@@ -9,7 +9,7 @@ module OoxmlParser
9
9
 
10
10
  def initialize(parent: nil)
11
11
  @relationship = []
12
- @parent = parent
12
+ super
13
13
  end
14
14
 
15
15
  # @return [Array, Column] accessor for relationship
@@ -12,7 +12,7 @@ module OoxmlParser
12
12
 
13
13
  def initialize(rows = [], parent: nil)
14
14
  @rows = rows
15
- @parent = parent
15
+ super(parent: parent)
16
16
  end
17
17
 
18
18
  alias table_properties properties