ooxml_parser 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -5
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/chart_style.rb +19 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text/math_paragraph.rb +18 -0
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text.rb +19 -0
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice.rb +20 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +20 -14
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/order.rb +20 -0
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_index.rb +20 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point/text_value.rb +15 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point.rb +31 -0
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point_count.rb +20 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache.rb +31 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference.rb +25 -0
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +23 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +39 -0
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/view_3d.rb +32 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +81 -74
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +20 -13
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +15 -14
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +15 -12
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +15 -10
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +22 -11
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing/doc_properties.rb +24 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +34 -20
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +9 -10
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +18 -25
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +4 -1
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +23 -20
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +15 -5
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +104 -0
  32. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative/picture_dimension.rb +17 -0
  33. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative_horizontal.rb +31 -0
  34. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative_vertical.rb +30 -0
  35. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +17 -16
  36. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +34 -0
  37. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +12 -15
  38. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +15 -10
  39. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb +38 -0
  40. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/non_visual_properties/shape_placeholder.rb +21 -0
  41. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/non_visual_properties.rb +29 -0
  42. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties.rb +22 -0
  43. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +29 -0
  44. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +26 -0
  45. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +27 -10
  46. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +7 -4
  47. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +20 -11
  48. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +18 -15
  49. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +11 -9
  50. 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 +39 -0
  51. 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 +15 -27
  52. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +13 -9
  53. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +20 -23
  54. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +27 -22
  55. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip/alpha_mod_fix.rb +19 -0
  56. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip.rb +21 -0
  57. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill.rb +24 -0
  58. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry/shape_adjust_value_list/shape_guide.rb +24 -0
  59. 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 +31 -0
  60. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry.rb +24 -0
  61. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +3 -3
  62. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +22 -13
  63. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +20 -12
  64. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +9 -8
  65. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +15 -13
  66. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +14 -12
  67. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +15 -12
  68. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +18 -14
  69. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +12 -11
  70. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +20 -24
  71. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +25 -0
  72. data/lib/ooxml_parser/common_parser/common_data/color.rb +48 -182
  73. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +15 -10
  74. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +1 -63
  75. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +17 -20
  76. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop/preset_color.rb +20 -0
  77. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +20 -7
  78. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +12 -11
  79. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +17 -17
  80. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +15 -9
  81. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +19 -16
  82. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +10 -6
  83. data/lib/ooxml_parser/common_parser/common_data/font_style.rb +1 -61
  84. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +33 -26
  85. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb +97 -0
  86. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +23 -37
  87. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +71 -23
  88. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/language.rb +20 -0
  89. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +11 -7
  90. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/position.rb +20 -0
  91. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_spacing.rb +20 -0
  92. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_style.rb +25 -0
  93. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +38 -0
  94. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/size.rb +20 -0
  95. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +92 -40
  96. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +12 -8
  97. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +37 -0
  98. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +53 -0
  99. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb +36 -0
  100. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +6 -6
  101. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tab_list/presentation_tab.rb +26 -0
  102. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tab_list.rb +36 -0
  103. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/paragraph_tab.rb +26 -0
  104. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +36 -0
  105. data/lib/ooxml_parser/common_parser/common_data/paragraph/text_field.rb +11 -8
  106. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +20 -12
  107. data/lib/ooxml_parser/common_parser/common_data/relationships/relationship.rb +13 -7
  108. data/lib/ooxml_parser/common_parser/common_data/relationships.rb +36 -4
  109. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +12 -8
  110. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +18 -19
  111. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +9 -8
  112. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_layout.rb +23 -0
  113. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +17 -14
  114. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +16 -23
  115. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +21 -40
  116. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_column_band_size.rb +23 -0
  117. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +42 -0
  118. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +50 -0
  119. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_row_band_size.rb +23 -0
  120. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +28 -23
  121. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties/vertical_merge.rb +20 -0
  122. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +71 -69
  123. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -10
  124. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +19 -17
  125. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +31 -48
  126. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line/line_join.rb +21 -0
  127. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +25 -19
  128. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties/table_row_height.rb +20 -0
  129. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +20 -10
  130. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +20 -16
  131. data/lib/ooxml_parser/common_parser/common_data/table/table_grid/grid_column.rb +20 -0
  132. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +27 -3
  133. data/lib/ooxml_parser/common_parser/common_data/table/table_properties/table_borders.rb +20 -13
  134. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +54 -37
  135. data/lib/ooxml_parser/common_parser/common_data/table.rb +23 -17
  136. data/lib/ooxml_parser/common_parser/common_data/underline.rb +13 -10
  137. data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +29 -0
  138. data/lib/ooxml_parser/common_parser/parser.rb +32 -4
  139. data/lib/ooxml_parser/configuration.rb +3 -13
  140. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +1 -1
  141. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +16 -16
  142. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +18 -13
  143. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +20 -0
  144. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_structure_helpers.rb +18 -0
  145. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb +37 -0
  146. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +43 -14
  147. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark.rb +21 -0
  148. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +19 -5
  149. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/argument_properties/argument_size.rb +20 -0
  150. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/argument_properties.rb +21 -0
  151. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +24 -4
  152. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +14 -5
  153. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +27 -6
  154. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +15 -5
  155. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +14 -5
  156. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +23 -7
  157. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +16 -6
  158. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +20 -6
  159. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +25 -0
  160. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run.rb +25 -0
  161. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +4 -3
  162. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +36 -3
  163. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties/nary_grow.rb +20 -0
  164. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties/nary_limit_location.rb +20 -0
  165. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties.rb +26 -0
  166. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary.rb +31 -0
  167. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +27 -0
  168. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +19 -5
  169. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +52 -183
  170. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +89 -0
  171. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/object/ole_object.rb +23 -0
  172. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/object.rb +21 -0
  173. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +24 -17
  174. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +7 -6
  175. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +15 -10
  176. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +43 -245
  177. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +19 -20
  178. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +24 -65
  179. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb +41 -0
  180. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +31 -0
  181. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +146 -172
  182. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +45 -26
  183. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/multilevel_type.rb +20 -0
  184. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/level_justification.rb +20 -0
  185. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/level_text.rb +20 -0
  186. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/numbering_format.rb +20 -0
  187. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/start.rb +20 -0
  188. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +31 -0
  189. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +65 -0
  190. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +42 -0
  191. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/numbering_definition/abstract_numbering_id.rb +20 -0
  192. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/numbering_definition.rb +31 -0
  193. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +45 -0
  194. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +15 -4
  195. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +24 -13
  196. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +6 -12
  197. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/footnote_properties.rb +32 -0
  198. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +8 -9
  199. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +31 -24
  200. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +61 -64
  201. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +56 -0
  202. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults/paragraph_properties_default.rb +20 -0
  203. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults/run_properties_default.rb +20 -0
  204. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults.rb +26 -0
  205. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +19 -0
  206. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +49 -54
  207. data/lib/ooxml_parser/docx_parser/docx_parser.rb +2 -1
  208. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +1 -1
  209. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_helpers.rb +13 -0
  210. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +15 -12
  211. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -1
  212. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background/background_properties/stretch.rb +11 -0
  213. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background/background_properties.rb +21 -0
  214. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -6
  215. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +27 -16
  216. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +13 -9
  217. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +11 -8
  218. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +19 -15
  219. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +17 -12
  220. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +15 -14
  221. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +18 -15
  222. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +9 -11
  223. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +16 -13
  224. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +23 -15
  225. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +21 -19
  226. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +15 -11
  227. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +52 -0
  228. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +13 -7
  229. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action.rb +11 -9
  230. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +13 -15
  231. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -14
  232. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +30 -67
  233. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +11 -8
  234. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +6 -3
  235. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +1 -1
  236. data/lib/ooxml_parser/version.rb +1 -1
  237. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +28 -0
  238. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill/pattern_fill.rb +33 -0
  239. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +25 -0
  240. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +38 -0
  241. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +35 -0
  242. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +38 -0
  243. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats/number_format.rb +24 -0
  244. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +47 -0
  245. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +36 -0
  246. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/workbook_helpers.rb +11 -0
  247. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +11 -10
  248. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +8 -10
  249. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +12 -12
  250. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +12 -10
  251. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +29 -8
  252. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/x14_table.rb +24 -0
  253. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb +21 -0
  254. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +30 -0
  255. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb +37 -0
  256. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +29 -10
  257. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb +25 -0
  258. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +23 -29
  259. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +15 -12
  260. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +70 -37
  261. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +16 -12
  262. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +31 -9
  263. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +34 -12
  264. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +20 -9
  265. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +1 -1
  266. data/lib/ooxml_parser.rb +0 -1
  267. metadata +122 -58
  268. data/lib/ooxml_parser/common_parser/common_data/alingment.rb +0 -56
  269. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +0 -17
  270. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +0 -17
  271. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +0 -10
  272. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +0 -34
  273. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +0 -30
  274. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +0 -6
  275. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +0 -10
  276. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_element.rb +0 -10
  277. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +0 -20
  278. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +0 -5
  279. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +0 -25
  280. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +0 -19
  281. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +0 -20
  282. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +0 -28
  283. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +0 -18
  284. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +0 -15
  285. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +0 -28
  286. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +0 -13
  287. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +0 -26
  288. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +0 -23
  289. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching/fill_rectangle.rb +0 -22
  290. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +0 -12
  291. data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +0 -16
  292. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +0 -16
  293. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +0 -25
  294. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +0 -69
  295. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +0 -18
  296. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +0 -20
  297. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +0 -21
  298. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +0 -19
  299. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +0 -20
  300. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +0 -13
  301. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +0 -10
  302. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +0 -19
  303. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +0 -35
  304. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +0 -56
  305. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +0 -15
  306. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +0 -84
  307. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +0 -16
  308. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +0 -27
  309. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +0 -25
  310. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +0 -22
  311. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +0 -22
  312. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +0 -37
  313. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +0 -25
  314. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +0 -36
  315. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +0 -30
@@ -1,3 +1,4 @@
1
+ require_relative 'color/color_helper'
1
2
  require_relative 'colors/color_alpha_channel'
2
3
  require_relative 'colors/hsl_color'
3
4
  require_relative 'colors/scheme_color'
@@ -6,7 +7,8 @@ require_relative 'colors/theme_colors'
6
7
  # @author Pavel.Lobashov
7
8
  # Class for Color in RGB
8
9
  module OoxmlParser
9
- class Color
10
+ class Color < OOXMLDocumentObject
11
+ include ColorHelper
10
12
  # @return [Array] Deprecated Indexed colors
11
13
  # List of color duplicated from `OpenXML Sdk IndexedColors` class
12
14
  # See https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx
@@ -89,6 +91,8 @@ module OoxmlParser
89
91
  # @return [String] Value of Color Style
90
92
  attr_accessor :style
91
93
  alias set_style style=
94
+ # @return [String] color scheme of color
95
+ attr_accessor :scheme
92
96
 
93
97
  # @return [Integer] Value of alpha-channel
94
98
  attr_accessor :alpha_channel
@@ -100,10 +104,14 @@ module OoxmlParser
100
104
  # Value of color if non selected
101
105
  VALUE_FOR_NONE_COLOR = nil
102
106
 
103
- def initialize(new_red = VALUE_FOR_NONE_COLOR, new_green = VALUE_FOR_NONE_COLOR, new_blue = VALUE_FOR_NONE_COLOR)
107
+ def initialize(new_red = VALUE_FOR_NONE_COLOR,
108
+ new_green = VALUE_FOR_NONE_COLOR,
109
+ new_blue = VALUE_FOR_NONE_COLOR,
110
+ parent: nil)
104
111
  @red = new_red
105
112
  @green = new_green
106
113
  @blue = new_blue
114
+ @parent = parent
107
115
  end
108
116
 
109
117
  def to_s
@@ -114,6 +122,10 @@ module OoxmlParser
114
122
  end
115
123
  end
116
124
 
125
+ def inspect
126
+ to_s
127
+ end
128
+
117
129
  def to_hex
118
130
  (@red.to_s(16).rjust(2, '0') + @green.to_s(16).rjust(2, '0') + @blue.to_s(16).rjust(2, '0')).upcase
119
131
  end
@@ -153,18 +165,19 @@ module OoxmlParser
153
165
  # @param [Integer] delta max delta for each of specters
154
166
  def looks_like?(color_to_check = nil, delta = 8)
155
167
  color_to_check = color_to_check.converted_color if color_to_check.is_a?(SchemeColor)
156
- color_to_check = color_to_check.color if color_to_check.is_a?(ForegroundColor)
168
+ color_to_check = color_to_check.pattern_fill.foreground_folor if color_to_check.is_a?(Fill)
157
169
  color_to_check = color_to_check.color.converted_color if color_to_check.is_a?(PresentationFill)
158
170
  color_to_check = Color.parse(color_to_check) if color_to_check.is_a?(String)
159
171
  color_to_check = Color.parse(color_to_check.to_s) if color_to_check.is_a?(Symbol)
160
172
  color_to_check = Color.parse(color_to_check.value) if color_to_check.is_a?(DocxColor)
173
+ return true if none? && color_to_check.nil?
161
174
  return false if none? && !color_to_check.none?
162
175
  return false if !none? && color_to_check.none?
163
176
  return true if self == color_to_check
164
177
  red = color_to_check.red
165
178
  green = color_to_check.green
166
179
  blue = color_to_check.blue
167
- ((self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta) ? true : false
180
+ (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
168
181
  end
169
182
 
170
183
  def calculate_with_tint!(tint)
@@ -179,80 +192,6 @@ module OoxmlParser
179
192
  @blue = (@blue * shade.to_f).to_i
180
193
  end
181
194
 
182
- def shade(shade_value)
183
- red = Color.scrgb_to_srgb(Color.shade_for_component(Color.srgb_to_scrgb(@red), shade_value))
184
- green = Color.scrgb_to_srgb(Color.shade_for_component(Color.srgb_to_scrgb(@green), shade_value))
185
- blue = Color.scrgb_to_srgb(Color.shade_for_component(Color.srgb_to_scrgb(@blue), shade_value))
186
- Color.new(red, green, blue)
187
- end
188
-
189
- def tint(shade_value)
190
- red = Color.scrgb_to_srgb(Color.tint_for_component(Color.srgb_to_scrgb(@red), shade_value))
191
- green = Color.scrgb_to_srgb(Color.tint_for_component(Color.srgb_to_scrgb(@green), shade_value))
192
- blue = Color.scrgb_to_srgb(Color.tint_for_component(Color.srgb_to_scrgb(@blue), shade_value))
193
- Color.new(red, green, blue)
194
- end
195
-
196
- # code from js to ruby
197
- # https://github.com/ONLYOFFICE/ONLYOFFICE-OnlineEditors/blob/master/OfficeWeb/sdk/Excel/model/DrawingObjects/Format/Format.js
198
- def to_hsl
199
- max_hls = 255.0
200
- cd13 = 1.0 / 3.0
201
- cd23 = 2.0 / 3.0
202
- hls_color = HSLColor.new
203
- min = [@red, @green, @blue].min.to_f
204
- max = [@red, @green, @blue].max.to_f
205
- delta = (max - min).to_f
206
- dmax = (max + min) / 255.0
207
- ddelta = delta / 255.0
208
- hls_color.l = dmax / 2.0
209
-
210
- if delta != 0
211
- hls_color.s = if hls_color.l < 0.5
212
- ddelta / dmax
213
- else
214
- ddelta / (2.0 - dmax)
215
- end
216
- ddelta *= 1_530.0
217
- d_r = (max - @red) / ddelta
218
- d_g = (max - @green) / ddelta
219
- d_b = (max - @blue) / ddelta
220
-
221
- if @red == max
222
- hls_color.h = d_b - d_r
223
- elsif @green == max
224
- hls_color.h = cd13 + d_r - d_b
225
- elsif @blue == max
226
- hls_color.h = cd23 + d_g - d_r
227
- end
228
-
229
- hls_color.h += 1 if hls_color.h < 0
230
- hls_color.h -= 1 if hls_color.h < 1
231
- end
232
- hls_color.h = ((hls_color.h * max_hls).round >> 0) & 0xFF
233
- hls_color.h = 0 if hls_color.h < 0
234
- hls_color.h = 255 if hls_color.h > 255
235
-
236
- hls_color.l = ((hls_color.l * max_hls).round >> 0) & 0xFF
237
- hls_color.l = 0 if hls_color.l < 0
238
- hls_color.l = 255 if hls_color.l > 255
239
-
240
- hls_color.s = ((hls_color.s * max_hls).round >> 0) & 0xFF
241
- hls_color.s = 0 if hls_color.s < 0
242
- hls_color.s = 255 if hls_color.s > 255
243
-
244
- hls_color
245
- end
246
-
247
- # redefine code from our to_hsl realisation to standartised way for services like http://serennu.com/colour/hsltorgb.php
248
- def to_hsl_standardised
249
- hsl = to_hsl
250
- hsl.h = hsl.h * 360 / 256
251
- hsl.l = (hsl.l * 100.0 / 255.0).round
252
- hsl.s = (hsl.s * 100.0 / 255.0).round
253
- hsl
254
- end
255
-
256
195
  class << self
257
196
  def generate_random_color
258
197
  Color.new(rand(256), rand(256), rand(256))
@@ -260,31 +199,6 @@ module OoxmlParser
260
199
 
261
200
  alias random generate_random_color
262
201
 
263
- def from_int16(color)
264
- return nil unless color
265
- return Color.new(nil, nil, nil) if color == 'auto' || color == 'null'
266
-
267
- char_array = color.split(//)
268
- alpha_channel, red, green, blue = nil
269
- if char_array.length == 6
270
- red = (char_array[0] + char_array[1]).hex
271
- green = (char_array[2] + char_array[3]).hex
272
- blue = (char_array[4] + char_array[5]).hex
273
- elsif char_array.length == 8
274
- alpha_channel = (char_array[0] + char_array[1]).hex
275
- red = (char_array[2] + char_array[3]).hex
276
- green = (char_array[4] + char_array[5]).hex
277
- blue = (char_array[6] + char_array[7]).hex
278
- end
279
- font_color = Color.new(red, green, blue)
280
- font_color.set_alpha_channel(alpha_channel) if alpha_channel
281
- font_color
282
- end
283
-
284
- def parse_color_hash(hash)
285
- Color.new(hash['red'], hash['green'], hash['blue'])
286
- end
287
-
288
202
  # Read array of color from the AllTestData's constant
289
203
  # @param [Array] const_array_name - array of the string
290
204
  # @return [Array, Color] array of color
@@ -294,7 +208,8 @@ module OoxmlParser
294
208
 
295
209
  def get_rgb_by_color_index(index)
296
210
  color_by_index = COLOR_INDEXED[index]
297
- color_by_index == 'n/a' ? Color.new : Color.from_int16(color_by_index)
211
+ return :unknown if color_by_index.nil?
212
+ color_by_index == 'n/a' ? Color.new : Color.new.parse_hex_string(color_by_index)
298
213
  end
299
214
 
300
215
  def parse_string(str)
@@ -313,67 +228,14 @@ module OoxmlParser
313
228
 
314
229
  alias parse parse_string
315
230
 
316
- def parse_int16_string(color)
317
- return nil if color.nil?
318
-
319
- char_array = color.split(//)
320
- red = (char_array[0] + char_array[1]).hex
321
- green = (char_array[2] + char_array[3]).hex
322
- blue = (char_array[4] + char_array[5]).hex
323
- Color.new(red, green, blue)
324
- end
325
-
326
- def srgb_to_scrgb(color)
327
- lineal_value = color.to_f / 255.0
328
- result_color = if lineal_value < 0
329
- 0
330
- elsif lineal_value <= 0.04045
331
- lineal_value / 12.92
332
- elsif lineal_value <= 1
333
- ((lineal_value + 0.055) / 1.055)**2.4
334
- else
335
- 1
336
- end
337
- result_color
338
- end
339
-
340
- def scrgb_to_srgb(color)
341
- result_color = if color < 0
342
- 0
343
- elsif color <= 0.0031308
344
- color * 12.92
345
- elsif color < 1
346
- 1.055 * (color**(1.0 / 2.4)) - 0.055
347
- else
348
- 1
349
- end
350
- (result_color * 255.0).to_i
351
- end
352
-
353
- def shade_for_component(color_component, shade_value)
354
- if color_component * shade_value < 0
355
- 0
356
- elsif color_component * shade_value > 1
357
- 1
358
- else
359
- color_component * shade_value
360
- end
361
- end
362
-
363
- def tint_for_component(color_component, tint)
364
- if tint > 0
365
- color_component * (1 - tint) + tint
366
- else
367
- color_component * (1 + tint)
368
- end
369
- end
370
-
371
231
  def to_color(something)
372
232
  case something
373
233
  when SchemeColor
374
234
  something.converted_color
375
- when ForegroundColor, DocxColorScheme
235
+ when DocxColorScheme
376
236
  something.color
237
+ when Fill
238
+ something.to_color
377
239
  when PresentationFill
378
240
  if something.color.respond_to? :converted_color
379
241
  something.color.converted_color
@@ -391,28 +253,26 @@ module OoxmlParser
391
253
  end
392
254
  end
393
255
 
394
- def parse_color_tag(color_tag)
395
- unless color_tag.nil?
396
- if color_tag.attribute('indexed').nil? && !color_tag.attribute('rgb').nil?
397
- if color_tag.attribute('rgb').value.is_a?(String)
398
- return Color.from_int16(color_tag.attribute('rgb').value.to_s)
399
- end
400
- return Color.from_int16(color_tag.attribute('rgb').value.value.to_s)
401
- elsif color_tag.attribute('rgb').nil? && !color_tag.attribute('indexed').nil?
402
- if color_tag.attribute('indexed').value.is_a?(String)
403
- return Color.get_rgb_by_color_index(color_tag.attribute('indexed').value.to_i)
404
- end
405
- return Color.get_rgb_by_color_index(color_tag.attribute('indexed').value.value.to_i)
406
- elsif !color_tag.attribute('theme').nil?
407
- return ThemeColors.parse_color_theme(color_tag)
256
+ def parse_color_tag(node)
257
+ return if node.nil?
258
+ node.attributes.each do |key, value|
259
+ case key
260
+ when 'val'
261
+ return Color.new.parse_hex_string(value.value.to_s)
262
+ when 'theme'
263
+ return ThemeColors.parse_color_theme(node)
264
+ when 'rgb'
265
+ return Color.new.parse_hex_string(value.value.to_s)
266
+ when 'indexed'
267
+ return Color.get_rgb_by_color_index(value.value.to_i)
408
268
  end
409
269
  end
410
- nil
411
270
  end
412
271
 
413
272
  def parse_scheme_color(scheme_color_node)
414
273
  color = ThemeColors.list[scheme_color_node.attribute('val').value.to_sym]
415
274
  hls = HSLColor.rgb_to_hsl(color)
275
+ scheme_name = nil
416
276
  scheme_color_node.xpath('*').each do |scheme_color_node_child|
417
277
  case scheme_color_node_child.name
418
278
  when 'lumMod'
@@ -421,8 +281,15 @@ module OoxmlParser
421
281
  hls.l = hls.l + (scheme_color_node_child.attribute('val').value.to_f / 100_000.0)
422
282
  end
423
283
  end
284
+ scheme_color_node.attributes.each do |key, value|
285
+ case key
286
+ when 'val'
287
+ scheme_name = value.to_s
288
+ end
289
+ end
424
290
  color = hls.to_rgb
425
291
  color.alpha_channel = ColorAlphaChannel.parse(scheme_color_node)
292
+ color.scheme = scheme_name
426
293
  color
427
294
  end
428
295
 
@@ -441,7 +308,7 @@ module OoxmlParser
441
308
  color = Color.new(color_model_node.attribute('r').value.to_i, color_model_node.attribute('g').value.to_i, color_model_node.attribute('b').value.to_i)
442
309
  color.alpha_channel = ColorAlphaChannel.parse(color_model_node)
443
310
  when 'srgbClr'
444
- color = Color.from_int16(color_model_node.attribute('val').value)
311
+ color = Color.new.parse_hex_string(color_model_node.attribute('val').value)
445
312
  color.alpha_channel = ColorAlphaChannel.parse(color_model_node)
446
313
  when 'schemeClr'
447
314
  color = parse_scheme_color(color_model_node)
@@ -455,16 +322,15 @@ module OoxmlParser
455
322
  def parse_color(color_node)
456
323
  case color_node.name
457
324
  when 'srgbClr'
458
- color = Color.from_int16(color_node.attribute('val').value)
459
- color.properties = ColorProperties.parse(color_node)
325
+ color = Color.new.parse_hex_string(color_node.attribute('val').value)
326
+ color.properties = ColorProperties.new(parent: color).parse(color_node)
460
327
  color
461
328
  when 'schemeClr'
462
329
  color = SchemeColor.new
463
330
  color.value = ThemeColors.list[color_node.attribute('val').value.to_sym]
464
- color.properties = ColorProperties.parse(color_node)
465
- color.converted_color = HSLColor.calculate_with_luminance color.value,
466
- color.properties.luminance_modulation,
467
- color.properties.luminance_offset
331
+ color.properties = ColorProperties.new(parent: color).parse(color_node)
332
+ color.converted_color = parse_scheme_color(color_node)
333
+ color.value.calculate_with_tint!(1.0 - color.properties.tint) if color.properties.tint
468
334
  color
469
335
  end
470
336
  end
@@ -1,21 +1,26 @@
1
- # Class for color transformations
2
1
  module OoxmlParser
3
- class ColorProperties
2
+ # Class for color transformations
3
+ class ColorProperties < OOXMLDocumentObject
4
4
  attr_accessor :alpha, :luminance_modulation, :luminance_offset
5
+ attr_accessor :tint
5
6
 
6
- def self.parse(color_properties_node)
7
- properties = ColorProperties.new
8
- color_properties_node.xpath('*').each do |color_properties_node_child|
9
- case color_properties_node_child.name
7
+ # Parse ColorProperties object
8
+ # @param node [Nokogiri::XML:Element] node to parse
9
+ # @return [ColorProperties] result of parsing
10
+ def parse(node)
11
+ node.xpath('*').each do |node_child|
12
+ case node_child.name
10
13
  when 'alpha'
11
- properties.alpha = (color_properties_node_child.attribute('val').value.to_f / 1_000.0).round
14
+ @alpha = (node_child.attribute('val').value.to_f / 1_000.0).round
12
15
  when 'lumMod'
13
- properties.luminance_modulation = color_properties_node_child.attribute('val').value.to_f / 100_000.0
16
+ @luminance_modulation = node_child.attribute('val').value.to_f / 100_000.0
14
17
  when 'lumOff'
15
- properties.luminance_offset = color_properties_node_child.attribute('val').value.to_f / 100_000.0
18
+ @luminance_offset = node_child.attribute('val').value.to_f / 100_000.0
19
+ when 'tint'
20
+ @tint = node_child.attribute('val').value.to_f / 100_000.0
16
21
  end
17
22
  end
18
- properties
23
+ self
19
24
  end
20
25
  end
21
26
  end
@@ -51,7 +51,7 @@ module OoxmlParser
51
51
  x = chroma * (1 - ((@h / 60.0) % 2.0 - 1).abs)
52
52
  m = @l - chroma / 2.0
53
53
 
54
- rgb = if @h == 0
54
+ rgb = if @h.zero?
55
55
  Color.new(0, 0, 0)
56
56
  elsif @h > 0 && @h < 60
57
57
  Color.new(chroma, x, 0)
@@ -69,20 +69,6 @@ module OoxmlParser
69
69
  Color.new(((rgb.red + m) * 255.0).round, ((rgb.green + m) * 255.0).round, ((rgb.blue + m) * 255.0).round)
70
70
  end
71
71
 
72
- def set_color(t1, t2, t3)
73
- t3 += 1.0 if t3 < 0
74
- t3 -= 1.0 if t3 > 1
75
- if 6.0 * t3 < 1
76
- t2 + (t1 - t2) * 6.0 * t3
77
- elsif 2.0 * t3 < 1
78
- t1
79
- elsif 3.0 * t3 < 2
80
- t2 + (t1 - t2) * ((2.0 / 3.0) - t3) * 6.0
81
- else
82
- t2
83
- end
84
- end
85
-
86
72
  def calculate_lum_value(tint, lum)
87
73
  if tint.nil?
88
74
  lum
@@ -91,54 +77,6 @@ module OoxmlParser
91
77
  end
92
78
  end
93
79
 
94
- def self.calculate_with_luminance(color, lum_mod, lum_off = nil)
95
- hls_color = color.is_a?(HSLColor) ? color : HSLColor.rgb_to_hsl(color)
96
- # for hsl color which have h == 0 need another values of lumOff lumMod - 0.04(+-0.005)
97
- if lum_mod
98
- if hls_color.h == 0
99
- hls_color.l *= case lum_mod
100
- when 0.2
101
- 0.169
102
- when 0.4
103
- 0.369
104
- when 0.6
105
- 0.55
106
- when 0.75
107
- 0.705
108
- when 0.5
109
- 0.469
110
- else
111
- lum_mod
112
- end
113
- else
114
- hls_color.l *= lum_mod
115
- end
116
- end
117
- current_rgb = hls_color.to_rgb
118
- return current_rgb if current_rgb == Color.new
119
-
120
- unless lum_off.nil?
121
- hls_color = HSLColor.rgb_to_hsl(current_rgb)
122
- # for hsl color which have h == 0 need another values of lumOff - 0.04(+-0.01)
123
- if hls_color.h == 0
124
- hls_color.l += case lum_off
125
- when 0.8
126
- 0.76
127
- when 0.6
128
- 0.55
129
- when 0.4
130
- 0.36
131
- else
132
- lum_off
133
- end
134
- else
135
- hls_color.l += lum_off
136
- end
137
- current_rgb = hls_color.to_rgb
138
- end
139
- current_rgb
140
- end
141
-
142
80
  def calculate_rgb_with_tint(tint)
143
81
  self.l = calculate_lum_value(tint, @l * 255.0) / 255.0
144
82
  to_rgb
@@ -1,33 +1,30 @@
1
1
  require_relative 'tile'
2
- require_relative 'image_properties'
3
- require_relative 'image/stretching'
4
2
  module OoxmlParser
5
3
  class ImageFill < OOXMLDocumentObject
6
- attr_accessor :path, :stretch, :tile, :properties
4
+ attr_accessor :stretch, :tile, :properties
5
+ # @return [FileReference] image structure
6
+ attr_accessor :file_reference
7
7
 
8
- alias path_to_media_file path
9
-
10
- def initialize(path = '')
11
- @path = path
8
+ def initialize(parent: nil)
9
+ @path = ''
10
+ @parent = parent
12
11
  end
13
12
 
14
- def self.parse(blip_fill_node)
15
- image = ImageFill.new
16
- blip_fill_node.xpath('*').each do |blip_fill_node_child|
17
- case blip_fill_node_child.name
13
+ # Parse ImageFill object
14
+ # @param node [Nokogiri::XML:Element] node to parse
15
+ # @return [ImageFill] result of parsing
16
+ def parse(node)
17
+ node.xpath('*').each do |node_child|
18
+ case node_child.name
18
19
  when 'blip'
19
- next unless blip_fill_node_child.attribute('embed')
20
- path_to_original_image = OOXMLDocumentObject.get_link_from_rels(blip_fill_node_child.attribute('embed').value)
21
- FileUtils.copy(dir + path_to_original_image, OOXMLDocumentObject.media_folder + File.basename(path_to_original_image))
22
- image.path = OOXMLDocumentObject.media_folder + File.basename(path_to_original_image)
23
- image.properties = ImageProperties.parse(blip_fill_node_child)
24
- when 'stretch'
25
- image.stretch = Stretching.parse(blip_fill_node_child) # !blip_fill_node_child.xpath('a:fillRect').first.nil?
20
+ @file_reference = FileReference.new(parent: self).parse(node_child)
26
21
  when 'tile'
27
- image.tile = Tile.parse(blip_fill_node_child)
22
+ @tile = Tile.new(OOXMLCoordinates.parse(node_child, x_attr: 'tx', y_attr: 'ty'),
23
+ OOXMLCoordinates.parse(node_child, x_attr: 'sx', y_attr: 'sy'),
24
+ parent: self).parse(node_child)
28
25
  end
29
26
  end
30
- image
27
+ self
31
28
  end
32
29
  end
33
30
  end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for working with `a:prstClr` tag
3
+ class PresetColor < OOXMLDocumentObject
4
+ # @return [String] value of preset color
5
+ attr_accessor :value
6
+
7
+ # Parse PresetColor object
8
+ # @param node [Nokogiri::XML:Element] node to parse
9
+ # @return [PresetColor] result of parsing
10
+ def parse(node)
11
+ node.attributes.each do |key, value|
12
+ case key
13
+ when 'val'
14
+ @value = value.value.to_s
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end
@@ -1,15 +1,28 @@
1
+ require_relative 'gradient_stop/preset_color'
1
2
  module OoxmlParser
2
3
  class GradientStop < OOXMLDocumentObject
3
4
  attr_accessor :position, :color
4
5
 
5
- def initialize(position)
6
- @position = position
7
- end
6
+ # Parse GradientStop object
7
+ # @param node [Nokogiri::XML:Element] node to parse
8
+ # @return [GradientStop] result of parsing
9
+ def parse(node)
10
+ node.attributes.each do |key, value|
11
+ case key
12
+ when 'pos'
13
+ @position = value.value.to_i / 1_000
14
+ end
15
+ end
8
16
 
9
- def self.parse(gs_node)
10
- gradient_stop = GradientStop.new(gs_node.attribute('pos').value.to_i / 1_000)
11
- gs_node.xpath('*').each { |color_node| gradient_stop.color = Color.parse_color(color_node) }
12
- gradient_stop
17
+ node.xpath('*').each do |node_child|
18
+ @color = case node_child.name
19
+ when 'prstClr'
20
+ PresetColor.new(parent: self).parse(node_child)
21
+ else
22
+ Color.parse_color(node_child)
23
+ end
24
+ end
25
+ self
13
26
  end
14
27
  end
15
28
  end
@@ -1,20 +1,21 @@
1
1
  module OoxmlParser
2
- class LinearGradient
2
+ # Class for parsing `lin` tags
3
+ class LinearGradient < OOXMLDocumentObject
3
4
  attr_accessor :angle, :scaled
4
5
 
5
- def initialize(angle = nil, scaled = nil)
6
- @angle = angle
7
- @scaled = scaled
8
- end
9
-
10
6
  # Parse LinearGradient object
11
7
  # @param node [Nokogiri::XML:Element] node to parse
12
8
  # @return [LinearGradient] result of parsing
13
- def self.parse(node)
14
- gradient = LinearGradient.new
15
- gradient.angle = node.attribute('ang').value.to_f / 100_000.0 if node.attribute('ang')
16
- gradient.scaled = node.attribute('scaled').value.to_i if node.attribute('scaled')
17
- gradient
9
+ def parse(node)
10
+ node.attributes.each do |key, value|
11
+ case key
12
+ when 'ang'
13
+ @angle = value.value.to_f / 100_000.0
14
+ when 'scaled'
15
+ @scaled = value.value.to_i
16
+ end
17
+ end
18
+ self
18
19
  end
19
20
  end
20
21
  end
@@ -1,34 +1,34 @@
1
1
  require_relative 'gradient_color/gradient_stop'
2
2
  require_relative 'gradient_color/linear_gradient'
3
3
  module OoxmlParser
4
+ # Class for parsing `gradFill` tags
4
5
  class GradientColor
5
6
  attr_accessor :gradient_stops, :path
7
+ # @return [LinearGradient] content of Linear Gradient
8
+ attr_accessor :linear_gradient
6
9
 
7
- def initialize(colors = [])
8
- @gradient_stops = colors
10
+ def initialize(parent: nil)
11
+ @gradient_stops = []
12
+ @parent = parent
9
13
  end
10
14
 
11
- def self.parse(gradient_fill_node)
12
- gradient_color = GradientColor.new
13
- gradient_fill_node.xpath('*').each do |gradient_fill_node_child|
14
- case gradient_fill_node_child.name
15
+ # Parse GradientColor object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [GradientColor] result of parsing
18
+ def parse(node)
19
+ node.xpath('*').each do |node_child|
20
+ case node_child.name
15
21
  when 'gsLst'
16
- begin
17
- gradient_fill_node_child.xpath('//a:gs')
18
- namespace = 'a'
19
- rescue Nokogiri::XML::XPath::SyntaxError
20
- namespace = 'w14'
21
- end
22
- gradient_fill_node_child.xpath("#{namespace}:gs").each do |gradient_stop_node|
23
- gradient_color.gradient_stops << GradientStop.parse(gradient_stop_node)
22
+ node_child.xpath('*').each do |gradient_stop_node|
23
+ @gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node)
24
24
  end
25
25
  when 'path'
26
- gradient_color.path = gradient_fill_node_child.attribute('path').value.to_sym
26
+ @path = node_child.attribute('path').value.to_sym
27
27
  when 'lin'
28
- gradient_color.path = LinearGradient.parse(gradient_fill_node_child)
28
+ @linear_gradient = LinearGradient.new(parent: self).parse(node_child)
29
29
  end
30
30
  end
31
- gradient_color
31
+ self
32
32
  end
33
33
  end
34
34
  end