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,29 +1,24 @@
1
1
  module OoxmlParser
2
- class TransitionProperties
2
+ class TransitionProperties < OOXMLDocumentObject
3
3
  attr_accessor :type, :through_black, :direction, :orientation, :spokes
4
4
 
5
- def initialize(type = nil)
6
- @type = type
7
- end
8
-
9
5
  # Parse TransitionProperties object
10
6
  # @param node [Nokogiri::XML:Element] node to parse
11
7
  # @return [TransitionProperties] result of parsing
12
- def self.parse(node)
13
- transition_properties = TransitionProperties.new
14
- transition_properties.type = node.name.to_sym
8
+ def parse(node)
9
+ @type = node.name.to_sym
15
10
  case node.name
16
11
  when 'blinds', 'checker', 'comb', 'cover', 'pull', 'push', 'randomBar', 'strips', 'wipe', 'zoom', 'warp'
17
- transition_properties.direction = Alignment.parse(node.attribute('dir')) if node.attribute('dir')
12
+ @direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
18
13
  when 'cut', 'fade'
19
- transition_properties.through_black = OOXMLDocumentObject.option_enabled?(node, 'thruBlk')
14
+ @through_black = option_enabled?(node, 'thruBlk')
20
15
  when 'split'
21
- transition_properties.direction = Alignment.parse(node.attribute('dir')) if node.attribute('dir')
22
- transition_properties.orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
16
+ @direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
17
+ @orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
23
18
  when 'wheel', 'wheelReverse'
24
- transition_properties.spokes = OOXMLDocumentObject.option_enabled?(node, 'spokes')
19
+ @spokes = option_enabled?(node, 'spokes')
25
20
  end
26
- transition_properties
21
+ self
27
22
  end
28
23
  end
29
24
  end
@@ -3,102 +3,65 @@ require_relative 'slide/background'
3
3
  require_relative 'slide/graphic_frame/graphic_frame'
4
4
  require_relative 'slide/slide/shapes_grouping'
5
5
  require_relative 'slide/slide/timing'
6
+ require_relative 'slide/slide_helper'
6
7
  module OoxmlParser
8
+ # Class for parsing `slide.xml`
7
9
  class Slide < OOXMLDocumentObject
10
+ include SlideHelper
8
11
  attr_accessor :elements, :background, :transition, :timing, :alternate_content
9
12
 
10
- def initialize(elements = [], background = nil)
11
- @elements = elements
12
- @background = background
13
+ def initialize(parent: nil, xml_path: nil)
14
+ @elements = []
15
+ @background = nil
16
+ @parent = parent
17
+ @xml_path = xml_path
13
18
  end
14
19
 
15
- def nonempty_elements
16
- @elements.select { |cur_shape| !cur_shape.text_body.paragraphs.first.characters.empty? }
17
- end
18
-
19
- def graphic_frames
20
- @elements.select { |cur_element| cur_element.is_a?(GraphicFrame) }
21
- end
22
-
23
- # Get transform property of object, by object type
24
- # @param object [Symbol] type of object: :image, :chart, :table, :shape
25
- # @return [OOXMLDocumentObject] needed object
26
- def transform_of_object(object)
27
- case object
28
- when :image
29
- return elements.find { |e| e.is_a? Picture }.properties.transform
30
- when :chart
31
- return elements.find { |e| e.is_a? GraphicFrame }.transform
32
- when :table
33
- return elements.find { |e| e.is_a? GraphicFrame }.transform
34
- when :shape
35
- return elements.find { |e| !e.shape_properties.preset.nil? }.shape_properties.transform
36
- else
37
- raise "Dont know this type object - #{object}"
20
+ def with_data?
21
+ return true unless @background.nil?
22
+ @elements.each do |current_element|
23
+ return true if current_element.with_data?
38
24
  end
25
+ false
39
26
  end
40
27
 
41
- def content_horizontal_align(object, slide_size)
42
- transform = transform_of_object(object)
43
- return :left if transform.offset.x == 0
44
- return :center if ((slide_size.width / 2) - (transform.extents.x / 2)).round(1) == transform.offset.x.round(1)
45
- return :right if (slide_size.width - transform.extents.x).round(1) == transform.offset.x.round(1)
46
- :unknown
47
- end
48
-
49
- def content_vertical_align(object, slide_size)
50
- transform = transform_of_object(object)
51
- return :top if transform.offset.y == 0
52
- return :middle if ((slide_size.height / 2) - (transform.extents.y / 2)).round(1) == transform.offset.y.round(1)
53
- return :bottom if (slide_size.height - transform.extents.y).round(1) == transform.offset.y.round(1)
54
- :unknown
55
- end
56
-
57
- def content_distribute(object, slide_size)
58
- return [:horizontally, :vertically] if content_horizontal_align(object, slide_size) == :center && content_vertical_align(object, slide_size) == :middle
59
- return [:horizontally] if content_horizontal_align(object, slide_size) == :center
60
- return [:vertically] if content_vertical_align(object, slide_size) == :middle
61
- end
62
-
63
- def self.parse(path_to_slide_xml)
64
- slide = Slide.new
65
- OOXMLDocumentObject.add_to_xmls_stack(path_to_slide_xml)
66
- doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
67
- doc.xpath('//p:sld/*').each do |slide_node_child|
68
- case slide_node_child.name
28
+ # Parse Slide object
29
+ # @return [Slide] result of parsing
30
+ def parse
31
+ OOXMLDocumentObject.add_to_xmls_stack(@xml_path)
32
+ node = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
33
+ node.xpath('//p:sld/*').each do |node_child|
34
+ case node_child.name
69
35
  when 'cSld'
70
- slide_node_child.xpath('*').each do |common_slide_node_child|
36
+ node_child.xpath('*').each do |common_slide_node_child|
71
37
  case common_slide_node_child.name
72
38
  when 'spTree'
73
39
  common_slide_node_child.xpath('*').each do |slide_element_node|
74
40
  case slide_element_node.name
75
- when 'nvGrpSpPr'
76
- when 'grpSpPr'
77
41
  when 'sp'
78
- slide.elements << PresentationShape.parse(slide_element_node).dup
42
+ @elements << DocxShape.new(parent: self).parse(slide_element_node).dup
79
43
  when 'pic'
80
- slide.elements << DocxPicture.parse(slide_element_node)
44
+ @elements << DocxPicture.new(parent: self).parse(slide_element_node)
81
45
  when 'graphicFrame'
82
- slide.elements << GraphicFrame.parse(slide_element_node)
46
+ @elements << GraphicFrame.new(parent: self).parse(slide_element_node)
83
47
  when 'grpSp'
84
- slide.elements << ShapesGrouping.parse(slide_element_node)
48
+ @elements << ShapesGrouping.new(parent: self).parse(slide_element_node)
85
49
  end
86
50
  end
87
51
  when 'bg'
88
- slide.background = Background.parse(common_slide_node_child)
52
+ @background = Background.new(parent: self).parse(common_slide_node_child)
89
53
  end
90
54
  end
91
- when 'clrMapOvr'
92
55
  when 'timing'
93
- slide.timing = Timing.parse(slide_node_child)
56
+ @timing = Timing.new(parent: self).parse(node_child)
94
57
  when 'transition'
95
- slide.transition = Transition.parse(slide_node_child)
58
+ @transition = Transition.new(parent: self).parse(node_child)
96
59
  when 'AlternateContent'
97
- slide.alternate_content = PresentationAlternateContent.parse(slide_node_child)
60
+ @alternate_content = PresentationAlternateContent.new(parent: self).parse(node_child)
98
61
  end
99
62
  end
100
63
  OOXMLDocumentObject.xmls_stack.pop
101
- slide
64
+ self
102
65
  end
103
66
  end
104
67
  end
@@ -1,20 +1,23 @@
1
1
  module OoxmlParser
2
- class SlideSize
2
+ # Class for parsing `sldSz` tag
3
+ class SlideSize < OOXMLDocumentObject
3
4
  attr_accessor :width, :height, :type
4
5
 
5
- def self.parse(slide_size_node)
6
- slide_size = SlideSize.new
7
- slide_size_node.attributes.each do |key, value|
6
+ # Parse SlideSize object
7
+ # @param node [Nokogiri::XML:Element] node to parse
8
+ # @return [Bookmark] result of parsing
9
+ def parse(node)
10
+ node.attributes.each do |key, value|
8
11
  case key
9
12
  when 'cx'
10
- slide_size.width = (value.value.to_f / OoxmlParser.configuration.units_delimiter).round(2)
13
+ @width = OoxmlSize.new(value.value.to_f, :emu)
11
14
  when 'cy'
12
- slide_size.height = (value.value.to_f / OoxmlParser.configuration.units_delimiter).round(2)
15
+ @height = OoxmlSize.new(value.value.to_f, :emu)
13
16
  when 'type'
14
- slide_size.type = value.value.to_sym
17
+ @type = value.value.to_sym
15
18
  end
16
19
  end
17
- slide_size
20
+ self
18
21
  end
19
22
  end
20
23
  end
@@ -1,9 +1,11 @@
1
1
  require_relative 'presentation/presentation_comment'
2
+ require_relative 'presentation/presentation_helpers'
2
3
  require_relative 'presentation/presentation_theme'
3
4
  require_relative 'presentation/slide'
4
5
  require_relative 'presentation/slide_size'
5
6
  module OoxmlParser
6
7
  class Presentation < CommonDocumentStructure
8
+ include PresentationHelpers
7
9
  attr_accessor :slides, :theme, :slide_size, :comments
8
10
 
9
11
  def initialize(slides = [], theme = nil, comments = [])
@@ -15,7 +17,6 @@ module OoxmlParser
15
17
  def self.parse
16
18
  OOXMLDocumentObject.root_subfolder = 'ppt/'
17
19
  OOXMLDocumentObject.xmls_stack = []
18
- OOXMLDocumentObject.namespace_prefix = 'a'
19
20
  OOXMLDocumentObject.add_to_xmls_stack('ppt/presentation.xml')
20
21
  doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
21
22
  presentation = Presentation.new
@@ -24,12 +25,14 @@ module OoxmlParser
24
25
  presentation_node.xpath('*').each do |presentation_node_child|
25
26
  case presentation_node_child.name
26
27
  when 'sldSz'
27
- presentation.slide_size = SlideSize.parse(presentation_node_child)
28
+ presentation.slide_size = SlideSize.new(parent: presentation).parse(presentation_node_child)
28
29
  when 'sldIdLst'
29
30
  presentation_node_child.xpath('p:sldId').each do |silde_id_node|
30
31
  id = nil
31
32
  silde_id_node.attribute_nodes.select { |node| id = node.to_s if node.namespace && node.namespace.prefix == 'r' }
32
- presentation.slides << Slide.parse("#{OOXMLDocumentObject.root_subfolder}/#{OOXMLDocumentObject.get_link_from_rels(id)}")
33
+ presentation.slides << Slide.new(parent: presentation,
34
+ xml_path: "#{OOXMLDocumentObject.root_subfolder}/#{OOXMLDocumentObject.get_link_from_rels(id)}")
35
+ .parse
33
36
  end
34
37
  end
35
38
  end
@@ -3,7 +3,7 @@ require_relative 'pptx_data/presentation.rb'
3
3
  module OoxmlParser
4
4
  class PptxParser
5
5
  def self.parse_pptx(path_to_file)
6
- Parser.parse(path_to_file) do
6
+ Parser.parse_format(path_to_file) do
7
7
  Presentation.parse
8
8
  end
9
9
  end
@@ -1,6 +1,6 @@
1
1
  module OoxmlParser
2
2
  # This module holds the RuboCop version information.
3
3
  module Version
4
- STRING = '0.1.2'.freeze
4
+ STRING = '0.2.0'.freeze
5
5
  end
6
6
  end
@@ -0,0 +1,28 @@
1
+ module OoxmlParser
2
+ # Class for storing data of chartsheets files
3
+ class Chartsheet < OOXMLDocumentObject
4
+ # @return [Array, SheetView] array of views
5
+ attr_accessor :sheet_views
6
+
7
+ def initialize(parent: nil)
8
+ @sheet_views = []
9
+ @parent = parent
10
+ end
11
+
12
+ def parse(file)
13
+ OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.root_subfolder + file)
14
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
15
+ node = doc.xpath('//xmlns:chartsheet').first
16
+ node.xpath('*').each do |node_child|
17
+ case node_child.name
18
+ when 'sheetViews'
19
+ node_child.xpath('*').each do |view_child|
20
+ @sheet_views << SheetView.new(parent: self).parse(view_child)
21
+ end
22
+ end
23
+ end
24
+ OOXMLDocumentObject.xmls_stack.pop
25
+ self
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ module OoxmlParser
2
+ # Parsing `patternFill` tag
3
+ class PatternFill < OOXMLDocumentObject
4
+ # @return [String] pattern type
5
+ attr_accessor :pattern_type
6
+ # @return [Color] foreground color
7
+ attr_accessor :foreground_color
8
+ # @return [Color] background color
9
+ attr_accessor :background_color
10
+
11
+ # Parse PatternFill data
12
+ # @param [Nokogiri::XML:Element] node with PatternFill data
13
+ # @return [PatternFill] value of PatternFill data
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'patternType'
18
+ @pattern_type = value.value.to_sym
19
+ end
20
+ end
21
+
22
+ node.xpath('*').each do |node_child|
23
+ case node_child.name
24
+ when 'fgColor'
25
+ @foreground_color = Color.parse_color_tag(node_child)
26
+ when 'bgColor'
27
+ @background_color = Color.parse_color_tag(node_child)
28
+ end
29
+ end
30
+ self
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'fill/pattern_fill'
2
+ module OoxmlParser
3
+ # Parsing `fill` tag
4
+ class Fill < OOXMLDocumentObject
5
+ # @return [PatternFill] pattern fill
6
+ attr_accessor :pattern_fill
7
+
8
+ # Parse Fill data
9
+ # @param [Nokogiri::XML:Element] node with Fill data
10
+ # @return [Fill] value of Fill data
11
+ def parse(node)
12
+ node.xpath('*').each do |node_child|
13
+ case node_child.name
14
+ when 'patternFill'
15
+ @pattern_fill = PatternFill.new(parent: self).parse(node_child)
16
+ end
17
+ end
18
+ self
19
+ end
20
+
21
+ def to_color
22
+ pattern_fill.foreground_color
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'fills/fill'
2
+ module OoxmlParser
3
+ # Parsing `fonts` tag
4
+ class Fills < OOXMLDocumentObject
5
+ # @return [Array, Fill] array of fills
6
+ attr_accessor :fills_array
7
+
8
+ def initialize(parent: nil)
9
+ @fills_array = []
10
+ @parent = parent
11
+ end
12
+
13
+ # @return [Array, Fill] accessor
14
+ def [](key)
15
+ @fills_array[key]
16
+ end
17
+
18
+ # Parse Fills data
19
+ # @param [Nokogiri::XML:Element] node with Fills data
20
+ # @return [Fills] value of Fills data
21
+ def parse(node)
22
+ node.attributes.each do |key, value|
23
+ case key
24
+ when 'count'
25
+ @count = value.value.to_i
26
+ end
27
+ end
28
+
29
+ node.xpath('*').each do |node_child|
30
+ case node_child.name
31
+ when 'fill'
32
+ @fills_array << Fill.new(parent: self).parse(node_child)
33
+ end
34
+ end
35
+ self
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ module OoxmlParser
2
+ # Parsing `fonts` tag
3
+ class Font < OOXMLDocumentObject
4
+ attr_accessor :name, :size, :font_style, :color
5
+
6
+ def initialize(parent: nil)
7
+ @name = 'Calibri'
8
+ @size = 11
9
+ @parent = parent
10
+ end
11
+
12
+ def parse(node)
13
+ @font_style = FontStyle.new
14
+ node.xpath('*').each do |node_child|
15
+ case node_child.name
16
+ when 'name'
17
+ @name = node_child.attribute('val').value
18
+ when 'sz'
19
+ @size = node_child.attribute('val').value.to_f
20
+ when 'b'
21
+ @font_style.bold = true
22
+ when 'i'
23
+ @font_style.italic = true
24
+ when 'strike'
25
+ @font_style.strike = :single
26
+ when 'u'
27
+ @font_style.underlined = Underline.new(:single)
28
+ when 'color'
29
+ @color = Color.parse_color_tag(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'fonts/font'
2
+ module OoxmlParser
3
+ # Parsing `fonts` tag
4
+ class Fonts < OOXMLDocumentObject
5
+ # @return [Array, Font] array of number formats
6
+ attr_accessor :fonts_array
7
+
8
+ def initialize(parent: nil)
9
+ @fonts_array = []
10
+ @parent = parent
11
+ end
12
+
13
+ # @return [Array, Font] accessor
14
+ def [](key)
15
+ @fonts_array[key]
16
+ end
17
+
18
+ # Parse NumberFormats data
19
+ # @param [Nokogiri::XML:Element] node with NumberFormats data
20
+ # @return [NumberFormats] value of NumberFormats data
21
+ def parse(node)
22
+ node.attributes.each do |key, value|
23
+ case key
24
+ when 'count'
25
+ @count = value.value.to_i
26
+ end
27
+ end
28
+
29
+ node.xpath('*').each do |node_child|
30
+ case node_child.name
31
+ when 'font'
32
+ @fonts_array << Font.new(parent: self).parse(node_child)
33
+ end
34
+ end
35
+ self
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ module OoxmlParser
2
+ # Parsing `numFmt` tag
3
+ class NumberFormat < OOXMLDocumentObject
4
+ # @return [Integer] id of number format
5
+ attr_accessor :id
6
+ # @return [String] code of format
7
+ attr_accessor :format_code
8
+
9
+ # Parse NumberFormat data
10
+ # @param [Nokogiri::XML:Element] node with NumberFormat data
11
+ # @return [NumberFormat] value of NumberFormat data
12
+ def parse(node)
13
+ node.attributes.each do |key, value|
14
+ case key
15
+ when 'numFmtId'
16
+ @id = value.value.to_i
17
+ when 'formatCode'
18
+ @format_code = value.value.to_s
19
+ end
20
+ end
21
+ self
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'number_formats/number_format'
2
+ module OoxmlParser
3
+ # Parsing `numFmts` tag
4
+ class NumberFormats < OOXMLDocumentObject
5
+ # @return [Array, NumberFormat] array of number formats
6
+ attr_accessor :number_formats_array
7
+
8
+ def initialize(parent: nil)
9
+ @number_formats_array = []
10
+ @parent = parent
11
+ end
12
+
13
+ # @return [Array, NumberFormats] accessor
14
+ def [](key)
15
+ @number_formats_array[key]
16
+ end
17
+
18
+ # Parse NumberFormats data
19
+ # @param [Nokogiri::XML:Element] node with NumberFormats data
20
+ # @return [NumberFormats] value of NumberFormats data
21
+ def parse(node)
22
+ node.attributes.each do |key, value|
23
+ case key
24
+ when 'count'
25
+ @count = value.value.to_i
26
+ end
27
+ end
28
+
29
+ node.xpath('*').each do |node_child|
30
+ case node_child.name
31
+ when 'numFmt'
32
+ @number_formats_array << NumberFormat.new(parent: self).parse(node_child)
33
+ end
34
+ end
35
+ self
36
+ end
37
+
38
+ # @param id [Integer] id of format
39
+ # @return [NumberFormat, nil] value of format
40
+ def format_by_id(id)
41
+ @number_formats_array.each do |cur_format|
42
+ return cur_format if cur_format.id == id
43
+ end
44
+ nil
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'style_sheet/fills'
2
+ require_relative 'style_sheet/fonts'
3
+ require_relative 'style_sheet/number_formats'
4
+ module OoxmlParser
5
+ # Parsing file styles.xml
6
+ class StyleSheet < OOXMLDocumentObject
7
+ # @return [NumberFormats] number formats
8
+ attr_accessor :number_formats
9
+ # @return [Fonts] fonts
10
+ attr_accessor :fonts
11
+ # @return [Fills] fills
12
+ attr_accessor :fills
13
+
14
+ def initialize(parent: nil)
15
+ @number_formats = NumberFormats.new(parent: self)
16
+ @fonts = Fonts.new(parent: self)
17
+ @fills = Fills.new(parent: self)
18
+ @parent = parent
19
+ end
20
+
21
+ def parse
22
+ doc = Nokogiri::XML(File.open("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/styles.xml"))
23
+ doc.root.xpath('*').each do |node_child|
24
+ case node_child.name
25
+ when 'numFmts'
26
+ @number_formats.parse(node_child)
27
+ when 'fonts'
28
+ @fonts.parse(node_child)
29
+ when 'fills'
30
+ @fills.parse(node_child)
31
+ end
32
+ end
33
+ self
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ module OoxmlParser
2
+ # method to help to work with DocumentStructure
3
+ module WorkbookHelpers
4
+ # @return [True, false] if structure contain any user data
5
+ def with_data?
6
+ return true if @worksheets.length > 1
7
+ return true if @worksheets.first.with_data?
8
+ false
9
+ end
10
+ end
11
+ end
@@ -1,20 +1,21 @@
1
- require_relative 'excel_comment/excel_comment_character'
2
- # Single Comment of XLSX
3
1
  module OoxmlParser
2
+ # Single Comment of XLSX
4
3
  class ExcelComment < OOXMLDocumentObject
5
4
  attr_accessor :characters
6
5
 
7
- def initialize(characters = [])
8
- @characters = characters
6
+ def initialize(parent: nil)
7
+ @characters = []
8
+ @parent = parent
9
9
  end
10
10
 
11
- def self.parse(comment_node)
12
- comment = ExcelComment.new
13
- comment_node.xpath('xmlns:text/xmlns:r').each do |character_node|
14
- character = ExcelCommentCharacter.parse(character_node)
15
- comment.characters << character.dup
11
+ # Parse ExcelComment object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [ExcelComment] result of parsing
14
+ def parse(node)
15
+ node.xpath('xmlns:text/xmlns:r').each do |node_child|
16
+ @characters << ParagraphRun.new(parent: self).parse(node_child)
16
17
  end
17
- comment
18
+ self
18
19
  end
19
20
  end
20
21
  end
@@ -21,7 +21,7 @@ module OoxmlParser
21
21
  end
22
22
  when 'commentList'
23
23
  comments_node_child.xpath('xmlns:comment').each do |comment_node|
24
- excel_comments.comments << ExcelComment.parse(comment_node)
24
+ excel_comments.comments << ExcelComment.new(parent: excel_comments).parse(comment_node)
25
25
  end
26
26
  end
27
27
  end
@@ -29,15 +29,13 @@ module OoxmlParser
29
29
  end
30
30
 
31
31
  def self.parse_file(file_name, path_to_folder)
32
- path_to_comments_xml = ''
33
- return nil unless File.exist?(path_to_folder + "xl/worksheets/_rels/#{file_name}.rels")
34
- relationships = XmlSimple.xml_in(File.open(path_to_folder + "xl/worksheets/_rels/#{file_name}.rels"))
35
- if relationships['Relationship']
36
- relationships['Relationship'].each do |relationship|
37
- path_to_comments_xml = path_to_folder + 'xl/' + relationship['Target'].gsub('..', '') if File.basename(relationship['Target']).include?('comment')
38
- end
39
- end
40
- ExcelComments.parse(path_to_comments_xml) unless path_to_comments_xml == ''
32
+ file = path_to_folder + "xl/worksheets/_rels/#{file_name}.rels"
33
+ return nil unless File.exist?(file)
34
+ relationships = Relationships.parse_rels(file)
35
+ target = relationships.target_by_type('comment')
36
+ return if target.nil?
37
+ comment_file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{target.gsub('..', '')}"
38
+ ExcelComments.parse(comment_file)
41
39
  end
42
40
  end
43
41
  end