ooxml_parser 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) 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 +2 -21
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +51 -4
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +1 -1
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -1
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +1 -1
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -1
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +0 -4
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +0 -4
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +0 -4
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +0 -4
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +0 -4
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +1 -1
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.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.rb +1 -1
  25. 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
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +1 -1
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -1
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +13 -3
  29. 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
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +10 -3
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +1 -1
  32. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +1 -1
  33. data/lib/ooxml_parser/common_parser/common_data/color.rb +11 -77
  34. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +33 -3
  35. data/lib/ooxml_parser/common_parser/common_data/color/color_indexes.list +66 -0
  36. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +8 -2
  37. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +0 -33
  38. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +1 -1
  39. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +1 -1
  40. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +1 -1
  41. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +1 -1
  42. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +1 -1
  43. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +15 -4
  44. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +5 -1
  45. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +1 -1
  46. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +1 -1
  47. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +1 -1
  48. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +33 -9
  49. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +5 -3
  50. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +1 -1
  51. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +1 -1
  52. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +1 -1
  53. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +1 -1
  54. data/lib/ooxml_parser/common_parser/common_data/relationships.rb +1 -1
  55. data/lib/ooxml_parser/common_parser/common_data/table.rb +1 -1
  56. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +1 -1
  57. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +2 -2
  58. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +1 -1
  59. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -1
  60. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +1 -1
  61. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +2 -0
  62. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/grid_span.rb +1 -7
  63. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +1 -1
  64. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +1 -1
  65. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +1 -1
  66. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +1 -1
  67. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +1 -1
  68. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -3
  69. data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +1 -1
  70. data/lib/ooxml_parser/common_parser/common_document_structure.rb +1 -0
  71. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +15 -7
  72. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb +2 -2
  73. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +1 -1
  74. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb +2 -2
  75. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +1 -1
  76. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +1 -1
  77. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +1 -1
  78. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +5 -9
  79. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +1 -1
  80. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +1 -1
  81. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +1 -1
  82. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +1 -1
  83. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +1 -1
  84. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +1 -1
  85. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +1 -1
  86. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +1 -1
  87. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +1 -1
  88. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +1 -1
  89. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +38 -21
  90. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +1 -1
  91. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +1 -1
  92. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb +1 -1
  93. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +3 -3
  94. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +1 -1
  95. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +5 -8
  96. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +9 -3
  97. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +2 -2
  98. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +1 -1
  99. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +1 -1
  100. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +1 -1
  101. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +4 -1
  102. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +4 -2
  103. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +1 -0
  104. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +1 -1
  105. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +2 -1
  106. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -2
  107. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb +1 -1
  108. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb +1 -1
  109. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -0
  110. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -1
  111. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -3
  112. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +1 -1
  113. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +1 -1
  114. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -2
  115. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +1 -1
  116. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +1 -1
  117. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +1 -1
  118. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +1 -1
  119. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +1 -1
  120. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +1 -1
  121. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition_list.rb +1 -1
  122. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +1 -1
  123. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb +1 -1
  124. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +1 -1
  125. data/lib/ooxml_parser/version.rb +1 -1
  126. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +1 -1
  127. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb +1 -1
  128. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +1 -1
  129. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb +1 -1
  130. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb +5 -5
  131. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +1 -1
  132. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +1 -1
  133. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +1 -1
  134. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +1 -1
  135. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +1 -1
  136. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb +1 -1
  137. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +1 -1
  138. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +1 -1
  139. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/comment_list.rb +1 -1
  140. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +1 -1
  141. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
  142. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +1 -1
  143. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters.rb +1 -1
  144. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +1 -1
  145. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +1 -1
  146. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_columns.rb +1 -1
  147. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +1 -1
  148. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +1 -1
  149. metadata +10 -10
  150. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
@@ -8,10 +8,6 @@ module OoxmlParser
8
8
  # @return [Color] scheme color of FontReference
9
9
  attr_reader :scheme_color
10
10
 
11
- def initialize(parent: nil)
12
- @parent = parent
13
- end
14
-
15
11
  # Parse FontReference object
16
12
  # @param node [Nokogiri::XML:Element] node to parse
17
13
  # @return [FontReference] result of parsing
@@ -8,10 +8,6 @@ module OoxmlParser
8
8
  # @return [Color] scheme color of LineReference
9
9
  attr_reader :scheme_color
10
10
 
11
- def initialize(parent: nil)
12
- @parent = parent
13
- end
14
-
15
11
  # Parse LineReference object
16
12
  # @param node [Nokogiri::XML:Element] node to parse
17
13
  # @return [LineReference] result of parsing
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @paragraphs = []
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse TextBody object
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
  def initialize(parent: nil)
9
9
  @color = Color.new
10
10
  @type = :unknown
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse DocxColorScheme object
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
 
9
9
  def initialize(elements = [], parent: nil)
10
10
  @elements = elements
11
- @parent = parent
11
+ super(parent: parent)
12
12
  end
13
13
 
14
14
  # Parse DocxShapeLinePath object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(points = [], parent: nil)
9
9
  @points = points
10
- @parent = parent
10
+ super(parent: parent)
11
11
  end
12
12
 
13
13
  # Parse DocxShapeLineElement
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
 
9
9
  def initialize(paths_list = [], parent: nil)
10
10
  @paths_list = paths_list
11
- @parent = parent
11
+ super(parent: parent)
12
12
  end
13
13
 
14
14
  # Parse OOXMLCustomGeometry object
@@ -13,7 +13,7 @@ module OoxmlParser
13
13
 
14
14
  def initialize(parent: nil)
15
15
  @width = OoxmlSize.new(0)
16
- @parent = parent
16
+ super
17
17
  end
18
18
 
19
19
  # @return [Integer] stroke size of object
@@ -10,8 +10,18 @@ require_relative 'custom_geometry/ooxml_custom_geometry'
10
10
  module OoxmlParser
11
11
  # DOCX Shape Properties
12
12
  class DocxShapeProperties < OOXMLDocumentObject
13
- attr_accessor :shape_size, :preset_geometry, :fill_color, :line, :custom_geometry
14
- attr_accessor :blip_fill
13
+ # @return [DocxShapeSize] size of shape
14
+ attr_reader :shape_size
15
+ # @return [PresetGeometry] preset geometry of object
16
+ attr_reader :preset_geometry
17
+ # @return [DocxColor] color of object
18
+ attr_reader :fill_color
19
+ # @return [DocxShapeLine] line info
20
+ attr_reader :line
21
+ # @return [PresetGeometry] is some geometry custom
22
+ attr_reader :custom_geometry
23
+ # @return [BlipFill] BlipFill data
24
+ attr_reader :blip_fill
15
25
 
16
26
  alias transform shape_size
17
27
  alias fill fill_color
@@ -19,7 +29,7 @@ module OoxmlParser
19
29
 
20
30
  def initialize(parent: nil)
21
31
  @line = DocxShapeLine.new
22
- @parent = parent
32
+ super
23
33
  end
24
34
 
25
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
@@ -3,9 +3,16 @@
3
3
  module OoxmlParser
4
4
  # Docx Shape Size
5
5
  class DocxShapeSize < OOXMLDocumentObject
6
- attr_accessor :rotation, :offset, :extent
7
- attr_accessor :child_offset
8
- attr_accessor :child_extent
6
+ # @return [OoxmlSize] rotation info
7
+ attr_reader :rotation
8
+ # @return [OOXMLCoordinates] offset info
9
+ attr_reader :offset
10
+ # @return [OOXMLCoordinates] extent info
11
+ attr_reader :extent
12
+ # @return [OOXMLCoordinates] child offset
13
+ attr_reader :child_offset
14
+ # @return [OOXMLCoordinates] child extent
15
+ attr_reader :child_extent
9
16
  # @return [True, False] is image flipped horizontally
10
17
  attr_reader :flip_horizontal
11
18
  # @return [True, False] is image flipped vertically
@@ -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
@@ -12,79 +12,6 @@ module OoxmlParser
12
12
  # Class for Color in RGB
13
13
  class Color < OOXMLDocumentObject
14
14
  include ColorHelper
15
- # @return [Array] Deprecated Indexed colors
16
- # List of color duplicated from `OpenXML Sdk IndexedColors` class
17
- # See https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx
18
- COLOR_INDEXED =
19
- %w[
20
- 000000
21
- FFFFFF
22
- FF0000
23
- 00FF00
24
- 0000FF
25
- FFFF00
26
- FF00FF
27
- 00FFFF
28
- 000000
29
- FFFFFF
30
- FF0000
31
- 00FF00
32
- 0000FF
33
- FFFF00
34
- FF00FF
35
- 00FFFF
36
- 800000
37
- 008000
38
- 000080
39
- 808000
40
- 800080
41
- 008080
42
- C0C0C0
43
- 808080
44
- 9999FF
45
- 993366
46
- FFFFCC
47
- CCFFFF
48
- 660066
49
- FF8080
50
- 0066CC
51
- CCCCFF
52
- 000080
53
- FF00FF
54
- FFFF00
55
- 00FFFF
56
- 800080
57
- 800000
58
- 008080
59
- 0000FF
60
- 00CCFF
61
- CCFFFF
62
- CCFFCC
63
- FFFF99
64
- 99CCFF
65
- FF99CC
66
- CC99FF
67
- FFCC99
68
- 3366FF
69
- 33CCCC
70
- 99CC00
71
- FFCC00
72
- FF9900
73
- FF6600
74
- 666699
75
- 969696
76
- 003366
77
- 339966
78
- 003300
79
- 333300
80
- 993300
81
- 993366
82
- 333399
83
- 333333
84
- n/a
85
- n/a
86
- ].freeze
87
-
88
15
  # @return [Integer] Value of Red Part
89
16
  attr_accessor :red
90
17
  # @return [Integer] Value of Green Part
@@ -103,7 +30,7 @@ module OoxmlParser
103
30
 
104
31
  alias set_alpha_channel alpha_channel=
105
32
 
106
- attr_accessor :position
33
+ # @return [ColorProperties] properties of color
107
34
  attr_accessor :properties
108
35
 
109
36
  # Value of color if non selected
@@ -116,7 +43,7 @@ module OoxmlParser
116
43
  @red = new_red
117
44
  @green = new_green
118
45
  @blue = new_blue
119
- @parent = parent
46
+ super(parent: parent)
120
47
  end
121
48
 
122
49
  # @return [String] result of convert of object to string
@@ -224,7 +151,7 @@ module OoxmlParser
224
151
  # @return [Color] result of parsing
225
152
  def parse_scheme_color(scheme_color_node)
226
153
  color = root_object.theme.color_scheme[scheme_color_node.attribute('val').value.to_sym].color
227
- hls = HSLColor.rgb_to_hsl(color)
154
+ hls = color.to_hsl
228
155
  scheme_name = nil
229
156
  scheme_color_node.xpath('*').each do |scheme_color_node_child|
230
157
  case scheme_color_node_child.name
@@ -320,12 +247,19 @@ module OoxmlParser
320
247
  # @param index [Integer] index to get
321
248
  # @return [Color] color by it's index
322
249
  def get_rgb_by_color_index(index)
323
- color_by_index = COLOR_INDEXED[index]
250
+ color_by_index = color_indexes[index]
324
251
  return :unknown if color_by_index.nil?
325
252
 
326
253
  color_by_index == 'n/a' ? Color.new : Color.new.parse_hex_string(color_by_index)
327
254
  end
328
255
 
256
+ # @return [Array] Deprecated Indexed colors
257
+ # List of color duplicated from `OpenXML Sdk IndexedColors` class
258
+ # See https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx
259
+ def color_indexes
260
+ @color_indexes ||= File.readlines("#{__dir__}/color/color_indexes.list", chomp: true)
261
+ end
262
+
329
263
  # Parse color from string
330
264
  # @param str [String] string to parse
331
265
  # @return [Color] result of parsing
@@ -9,15 +9,16 @@ module OoxmlParser
9
9
  return self if %w[auto null].include?(hex_string)
10
10
 
11
11
  char_array = hex_string.split(//)
12
- if char_array.length == 3
12
+ case char_array.length
13
+ when 3
13
14
  @red = char_array[0].hex
14
15
  @green = char_array[1].hex
15
16
  @blue = char_array[2].hex
16
- elsif char_array.length == 6
17
+ when 6
17
18
  @red = (char_array[0] + char_array[1]).hex
18
19
  @green = (char_array[2] + char_array[3]).hex
19
20
  @blue = (char_array[4] + char_array[5]).hex
20
- elsif char_array.length == 8
21
+ when 8
21
22
  @alpha_channel = (char_array[0] + char_array[1]).hex
22
23
  @red = (char_array[2] + char_array[3]).hex
23
24
  @green = (char_array[4] + char_array[5]).hex
@@ -25,5 +26,34 @@ module OoxmlParser
25
26
  end
26
27
  self
27
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
28
58
  end
29
59
  end
@@ -0,0 +1,66 @@
1
+ 000000
2
+ FFFFFF
3
+ FF0000
4
+ 00FF00
5
+ 0000FF
6
+ FFFF00
7
+ FF00FF
8
+ 00FFFF
9
+ 000000
10
+ FFFFFF
11
+ FF0000
12
+ 00FF00
13
+ 0000FF
14
+ FFFF00
15
+ FF00FF
16
+ 00FFFF
17
+ 800000
18
+ 008000
19
+ 000080
20
+ 808000
21
+ 800080
22
+ 008080
23
+ C0C0C0
24
+ 808080
25
+ 9999FF
26
+ 993366
27
+ FFFFCC
28
+ CCFFFF
29
+ 660066
30
+ FF8080
31
+ 0066CC
32
+ CCCCFF
33
+ 000080
34
+ FF00FF
35
+ FFFF00
36
+ 00FFFF
37
+ 800080
38
+ 800000
39
+ 008080
40
+ 0000FF
41
+ 00CCFF
42
+ CCFFFF
43
+ CCFFCC
44
+ FFFF99
45
+ 99CCFF
46
+ FF99CC
47
+ CC99FF
48
+ FFCC99
49
+ 3366FF
50
+ 33CCCC
51
+ 99CC00
52
+ FFCC00
53
+ FF9900
54
+ FF6600
55
+ 666699
56
+ 969696
57
+ 003366
58
+ 339966
59
+ 003300
60
+ 333300
61
+ 993300
62
+ 993366
63
+ 333399
64
+ 333333
65
+ n/a
66
+ n/a
@@ -3,8 +3,14 @@
3
3
  module OoxmlParser
4
4
  # Class for color transformations
5
5
  class ColorProperties < OOXMLDocumentObject
6
- attr_accessor :alpha, :luminance_modulation, :luminance_offset
7
- attr_accessor :tint
6
+ # @return [Integer] alpha value of color
7
+ attr_reader :alpha
8
+ # @return [Float] luminance modulation value
9
+ attr_reader :luminance_modulation
10
+ # @return [Float] luminance offset value
11
+ attr_reader :luminance_offset
12
+ # @return [Float] tint value
13
+ attr_reader :tint
8
14
 
9
15
  # Parse ColorProperties object
10
16
  # @param node [Nokogiri::XML:Element] node to parse
@@ -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