ooxml_parser 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/.overcommit.yml +35 -0
  3. data/Changelog.md +25 -0
  4. data/LICENSE.txt +661 -0
  5. data/README.md +26 -0
  6. data/circle.yml +3 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alingment.rb +56 -0
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +34 -0
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +123 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +34 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +38 -0
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +23 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +33 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_point.rb +11 -0
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +17 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +17 -0
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +26 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +49 -0
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +23 -0
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +35 -0
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +11 -0
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +39 -0
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +32 -0
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +34 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +10 -0
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +34 -0
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +27 -0
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +26 -0
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +25 -0
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +16 -0
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +30 -0
  32. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +37 -0
  33. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +20 -0
  34. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +30 -0
  35. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +6 -0
  36. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +10 -0
  37. 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 +10 -0
  38. 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 +44 -0
  39. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +23 -0
  40. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +43 -0
  41. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +54 -0
  42. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +25 -0
  43. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +40 -0
  44. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +31 -0
  45. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +20 -0
  46. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +21 -0
  47. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +5 -0
  48. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +31 -0
  49. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_element.rb +10 -0
  50. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_properties.rb +6 -0
  51. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +26 -0
  52. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +24 -0
  53. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +26 -0
  54. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +24 -0
  55. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +25 -0
  56. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +19 -0
  57. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +20 -0
  58. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +28 -0
  59. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +18 -0
  60. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +15 -0
  61. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +28 -0
  62. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +13 -0
  63. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +26 -0
  64. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +23 -0
  65. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +58 -0
  66. data/lib/ooxml_parser/common_parser/common_data/color.rb +473 -0
  67. data/lib/ooxml_parser/common_parser/common_data/colors/color_alpha_channel.rb +14 -0
  68. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +21 -0
  69. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +150 -0
  70. data/lib/ooxml_parser/common_parser/common_data/colors/image/fill_rectangle.rb +22 -0
  71. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +11 -0
  72. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +32 -0
  73. data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +16 -0
  74. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +15 -0
  75. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +10 -0
  76. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +35 -0
  77. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +22 -0
  78. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +33 -0
  79. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +14 -0
  80. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +22 -0
  81. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +21 -0
  82. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +127 -0
  83. data/lib/ooxml_parser/common_parser/common_data/font_style.rb +101 -0
  84. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +53 -0
  85. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +87 -0
  86. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +48 -0
  87. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +23 -0
  88. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +16 -0
  89. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +79 -0
  90. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +24 -0
  91. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +25 -0
  92. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +69 -0
  93. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +18 -0
  94. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +115 -0
  95. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +35 -0
  96. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +35 -0
  97. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +47 -0
  98. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +20 -0
  99. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +20 -0
  100. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +43 -0
  101. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +49 -0
  102. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +83 -0
  103. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +21 -0
  104. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +19 -0
  105. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +20 -0
  106. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +43 -0
  107. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +142 -0
  108. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -0
  109. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +25 -0
  110. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +125 -0
  111. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +35 -0
  112. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +22 -0
  113. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +33 -0
  114. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +9 -0
  115. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +77 -0
  116. data/lib/ooxml_parser/common_parser/common_data/table.rb +41 -0
  117. data/lib/ooxml_parser/common_parser/common_data/underline.rb +40 -0
  118. data/lib/ooxml_parser/common_parser/common_document_structure.rb +7 -0
  119. data/lib/ooxml_parser/configuration.rb +20 -0
  120. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +28 -0
  121. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +10 -0
  122. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +21 -0
  123. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +70 -0
  124. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +11 -0
  125. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +10 -0
  126. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +11 -0
  127. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +12 -0
  128. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +11 -0
  129. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +11 -0
  130. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +13 -0
  131. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +12 -0
  132. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +12 -0
  133. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +10 -0
  134. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +10 -0
  135. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +13 -0
  136. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +11 -0
  137. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +203 -0
  138. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/offset.rb +10 -0
  139. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shadow.rb +10 -0
  140. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_margins.rb +11 -0
  141. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_size.rb +10 -0
  142. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/stroke.rb +10 -0
  143. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties.rb +16 -0
  144. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +40 -0
  145. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +13 -0
  146. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +22 -0
  147. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +388 -0
  148. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +46 -0
  149. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +87 -0
  150. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +10 -0
  151. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +19 -0
  152. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +35 -0
  153. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +56 -0
  154. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +324 -0
  155. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +37 -0
  156. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +15 -0
  157. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +10 -0
  158. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +37 -0
  159. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +29 -0
  160. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +49 -0
  161. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +42 -0
  162. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +88 -0
  163. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +84 -0
  164. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +232 -0
  165. data/lib/ooxml_parser/docx_parser/docx_parser.rb +16 -0
  166. data/lib/ooxml_parser/helpers/string_helper.rb +22 -0
  167. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment/presentation_comment_author.rb +25 -0
  168. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +31 -0
  169. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +40 -0
  170. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +44 -0
  171. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -0
  172. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +34 -0
  173. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +25 -0
  174. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +23 -0
  175. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/extents.rb +10 -0
  176. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/offset.rb +10 -0
  177. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/paragraph.rb +10 -0
  178. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/text_field.rb +18 -0
  179. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shapes_grouping/shapes_grouping.rb +9 -0
  180. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +16 -0
  181. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +30 -0
  182. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +22 -0
  183. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +28 -0
  184. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +31 -0
  185. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +20 -0
  186. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +26 -0
  187. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +33 -0
  188. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +52 -0
  189. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +23 -0
  190. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound/sound.rb +18 -0
  191. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound_action.rb +18 -0
  192. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +43 -0
  193. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -0
  194. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +110 -0
  195. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +20 -0
  196. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +62 -0
  197. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +15 -0
  198. data/lib/ooxml_parser/version.rb +6 -0
  199. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +27 -0
  200. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +25 -0
  201. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +20 -0
  202. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +43 -0
  203. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +21 -0
  204. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +23 -0
  205. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +18 -0
  206. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +24 -0
  207. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +22 -0
  208. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +22 -0
  209. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +37 -0
  210. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +49 -0
  211. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +30 -0
  212. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +25 -0
  213. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +38 -0
  214. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +95 -0
  215. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +47 -0
  216. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +19 -0
  217. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +30 -0
  218. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +74 -0
  219. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +108 -0
  220. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +15 -0
  221. data/lib/ooxml_parser.rb +35 -0
  222. data/ooxml_parser.gemspec +30 -0
  223. metadata +310 -0
@@ -0,0 +1,84 @@
1
+ module OoxmlParser
2
+ class Size
3
+ attr_accessor :height, :width, :orientation
4
+
5
+ def initialize(height = nil, width = nil, orientation = :portrait)
6
+ @height = height
7
+ @width = width
8
+ @orientation = orientation
9
+ end
10
+
11
+ def self.get_name_by_size(height, width, is_portrait = true)
12
+ unless is_portrait
13
+ swap_value = height
14
+ height = width
15
+ width = swap_value
16
+ end
17
+ return 'US Letter' if height == '15840' && width == '12240'
18
+ return 'US Legal' if height == '20160' && width == '12240'
19
+ return 'A4' if height == '16838' && width == '11906'
20
+ return 'A5' if height == '11900' && width == '8396'
21
+ return 'B5' if height == '14179' && width == '9978'
22
+ return 'Envelope #10' if height == '13680' && width == '5941'
23
+ return 'Envelope DL' if height == '12478' && width == '6242'
24
+ return 'Tabloid' if height == '24474' && width == '15840'
25
+ return 'A3' if height == '23817' && width == '16838'
26
+ return 'Tabloid Oversize' if height == '25914' && width == '17280'
27
+ return 'ROC 16K' if height == '15477' && width == '11157'
28
+ return 'Envelope Choukei 3' if height == '13317' && width == '6797'
29
+ return 'Super B/A3' if height == '27354' && width == '18720'
30
+ 'Unknown page size: Height ' + height.to_s + ' Width ' + width.to_s
31
+ end
32
+
33
+ def to_s
34
+ 'Height: ' + @height.to_s + ' Width: ' + @width.to_s + ' Orientation: ' + @orientation.to_s
35
+ end
36
+
37
+ # noinspection RubyUnnecessaryReturnStatement
38
+ def ==(other)
39
+ is_same = false
40
+ if (@height == other.height) &&
41
+ (@width == other.width) &&
42
+ (@orientation == other.orientation)
43
+ is_same = true
44
+ end
45
+ is_same
46
+ end
47
+
48
+ # @return [True, False] compare dimensions of size, ignoring orientation
49
+ def same_dimensions?(other)
50
+ (@height == other.height) && (@width == other.width) ||
51
+ (@height == other.width) && (@width == other.height)
52
+ end
53
+
54
+ # @return [String] get human format name
55
+ def name
56
+ return 'US Letter' if same_dimensions?(Size.new(27.94, 21.59))
57
+ return 'US Legal' if same_dimensions?(Size.new(35.56, 21.59))
58
+ return 'A4' if same_dimensions?(Size.new(29.7, 21.0))
59
+ return 'A5' if same_dimensions?(Size.new(20.99, 14.81))
60
+ return 'B5' if same_dimensions?(Size.new(25.01, 17.6))
61
+ return 'Envelope #10' if same_dimensions?(Size.new(24.13, 10.48))
62
+ return 'Envelope DL' if same_dimensions?(Size.new(22.01, 11.01))
63
+ return 'Tabloid' if same_dimensions?(Size.new(43.17, 27.94))
64
+ return 'A3' if same_dimensions?(Size.new(42.01, 29.7))
65
+ return 'Tabloid Oversize' if same_dimensions?(Size.new(45.71, 30.48))
66
+ return 'ROC 16K' if same_dimensions?(Size.new(27.3, 19.68))
67
+ return 'Envelope Choukei 3' if same_dimensions?(Size.new(23.49, 11.99))
68
+ return 'Super B/A3' if same_dimensions?(Size.new(48.25, 33.02))
69
+ "Unknown page size: Height #{@height} Width #{@width}"
70
+ end
71
+
72
+ # Parse BordersProperties
73
+ # @param [Nokogiri::XML:Element] node with Size
74
+ # @return [Size] value of Size
75
+ def self.parse(node)
76
+ size = Size.new
77
+ size.orientation = node.attribute('orient').value.to_sym unless node.attribute('orient').nil?
78
+ # TODO: implement and understand, why 566.929, but not `unit_delimeter`
79
+ size.height = (node.attribute('h').value.to_f / 566.929).round(2)
80
+ size.width = (node.attribute('w').value.to_f / 566.929).round(2)
81
+ size
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,232 @@
1
+ # noinspection RubyInstanceMethodNamingConvention
2
+ require_relative 'document_structure/comment'
3
+ require_relative 'document_structure/docx_paragraph'
4
+ require_relative 'document_structure/document_properties'
5
+ require_relative 'document_structure/document_style'
6
+ require_relative 'document_structure/page_properties/page_properties'
7
+ module OoxmlParser
8
+ class DocumentStructure < CommonDocumentStructure
9
+ attr_accessor :elements, :page_properties, :notes, :background, :document_properties, :comments
10
+
11
+ # @return [Array, DocumentStyle] array of document styles in current document
12
+ attr_accessor :document_styles
13
+
14
+ def initialize(elements = [], page_properties = nil, notes = [], background = nil, document_properties = DocumentProperties.new, comments = [])
15
+ @elements = elements
16
+ @page_properties = page_properties
17
+ @notes = notes
18
+ @background = background
19
+ @document_properties = document_properties
20
+ @comments = comments
21
+ @document_styles = []
22
+ end
23
+
24
+ def difference(other)
25
+ Hash.object_to_hash(self).diff(Hash.object_to_hash(other))
26
+ end
27
+
28
+ def element_by_description(location: :canvas, type: :docx_paragraph)
29
+ case location
30
+ when :canvas
31
+ case type
32
+ when :table
33
+ elements[1].rows[0].cells[0].elements
34
+ when :docx_paragraph, :simple, :paragraph
35
+ elements
36
+ when :shape
37
+ elements[0].nonempty_runs.first.alternate_content.office2007_content.data.text_box
38
+ else
39
+ raise 'Wrong location(Need One of ":table", ":paragraph", ":shape")'
40
+ end
41
+ when :footer
42
+ case type
43
+ when :table
44
+ note_by_description(:footer1).elements[1].rows[0].cells[0].elements
45
+ when :docx_paragraph, :simple, :paragraph
46
+ note_by_description(:footer1).elements
47
+ when :shape
48
+ note_by_description(:footer1).elements[0].nonempty_runs.first.alternate_content.office2007_content.data.text_box
49
+ else
50
+ raise 'Wrong location(Need One of ":table", ":simple", ":shape")'
51
+ end
52
+ when :header
53
+ case type
54
+ when :table
55
+ note_by_description(:header1).elements[1].rows[0].cells[0].elements
56
+ when :docx_paragraph, :simple, :paragraph
57
+ note_by_description(:header1).elements
58
+ when :shape
59
+ note_by_description(:header1).elements[0].nonempty_runs.first.alternate_content.office2007_content.data.text_box
60
+ else
61
+ raise 'Wrong location(Need One of ":table", ":simple", ":shape")'
62
+ end
63
+ when :comment
64
+ comments[0].paragraphs
65
+ else
66
+ raise 'Wrong global location(Need One of ":canvas", ":footer", ":header", ":comment")'
67
+ end
68
+ end
69
+
70
+ def note_by_description(type)
71
+ notes.each do |note|
72
+ return note if note.type.to_sym == type
73
+ end
74
+ raise 'There isn\'t this type of the note'
75
+ end
76
+
77
+ def recognize_numbering(location: :canvas, type: :simple, paragraph_number: 0)
78
+ elements = element_by_description(location: location, type: type)
79
+ lvl_text = elements[paragraph_number].numbering.numbering_properties.ilvls[0].level_text
80
+ num_format = elements[paragraph_number].numbering.numbering_properties.ilvls[0].num_format
81
+ [num_format, lvl_text]
82
+ end
83
+
84
+ def outline(location: :canvas, type: :simple, levels_count: 1)
85
+ elements = element_by_description(location: location, type: type)
86
+ set = []
87
+ levels_count.times do |col|
88
+ set[0] = elements[col].numbering.numbering_properties.ilvls[col].num_format
89
+ set[1] = elements[col].numbering.numbering_properties.ilvls[col].level_text
90
+ end
91
+ set
92
+ end
93
+
94
+ # Return document style by its name
95
+ # @param name [String] name of style
96
+ # @return [DocumentStyle, nil]
97
+ def document_style_by_name(name)
98
+ @document_styles.each do |style|
99
+ return style if style.name == name
100
+ end
101
+ nil
102
+ end
103
+
104
+ # Check if style exists in current document
105
+ # @param name [String] name of style
106
+ # @return [True, False]
107
+ def style_exist?(name)
108
+ !document_style_by_name(name).nil?
109
+ end
110
+
111
+ def self.parse(path)
112
+ OOXMLDocumentObject.root_subfolder = 'word/'
113
+ OOXMLDocumentObject.path_to_folder = path
114
+ OOXMLDocumentObject.xmls_stack = []
115
+ OOXMLDocumentObject.namespace_prefix = 'w'
116
+ @comments = []
117
+ @default_paragraph = DocxParagraph.new
118
+ @default_character = DocxParagraphRun.new
119
+ @default_table_properties = TableProperties.new
120
+ PresentationTheme.parse('word/theme/theme1.xml')
121
+ OOXMLDocumentObject.add_to_xmls_stack('word/styles.xml')
122
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
123
+ doc.search('//w:docDefaults').each do |doc_defaults|
124
+ doc_defaults.xpath('w:pPrDefault').each do |p_pr_defaults|
125
+ @default_paragraph = DocxParagraph.parse(p_pr_defaults, 0)
126
+ end
127
+ doc_defaults.xpath('w:rPrDefault').each do |r_pr_defaults|
128
+ r_pr_defaults.xpath('w:rPr').each do |r_pr|
129
+ @default_character = DocxParagraphRun.parse(r_pr, DocxParagraphRun.new)
130
+ end
131
+ end
132
+ end
133
+ parse_default_style
134
+ doc_structure = DocumentStructure.new
135
+ doc_structure.document_styles = DocumentStyle.parse_list
136
+ number = 0
137
+ OOXMLDocumentObject.add_to_xmls_stack('word/document.xml')
138
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
139
+ doc.search('//w:document').each do |document|
140
+ document.xpath('w:background').each do |background|
141
+ doc_structure.background = DocumentBackground.new
142
+ doc_structure.background.color1 = Color.from_int16(background.attribute('color').value)
143
+ background.xpath('v:background').each do |second_color|
144
+ unless second_color.attribute('targetscreensize').nil?
145
+ doc_structure.background.size = second_color.attribute('targetscreensize').value.sub(',', 'x')
146
+ end
147
+ second_color.xpath('v:fill').each do |fill|
148
+ if !fill.attribute('color2').nil?
149
+ doc_structure.background.color2 = Color.from_int16(fill.attribute('color2').value.split(' ').first.delete('#'))
150
+ doc_structure.background.type = fill.attribute('type').value
151
+ elsif !fill.attribute('id').nil?
152
+ path_to_image = path + 'word/' + ParserDocxHelper.get_link_from_rels(fill.attribute('id').value, path)
153
+ image_name = File.basename(path_to_image)
154
+ doc_structure.background.image = path + File.basename(path) + '/' + image_name
155
+ unless File.exist?(doc_structure.background.image.sub(File.basename(doc_structure.background.image), ''))
156
+ FileUtils.mkdir(doc_structure.background.image.sub(File.basename(doc_structure.background.image), ''))
157
+ end
158
+ FileUtils.cp path_to_image, doc_structure.background.image
159
+ doc_structure.background.type = 'image'
160
+ end
161
+ end
162
+ end
163
+ end
164
+ document.xpath('w:body').each do |body|
165
+ body.xpath('*').each do |element|
166
+ if element.name == 'p'
167
+ child = element.child
168
+ unless child.nil? && doc_structure.elements.last.class == Table
169
+ paragraph_style = DocxParagraph.parse(element, number, @default_paragraph, @default_character)
170
+ number += 1
171
+ doc_structure.elements << paragraph_style.copy
172
+ end
173
+ elsif element.name == 'tbl'
174
+ table = Table.parse(element, number, TableProperties.new, DocumentStructure.default_table_paragraph_style, DocumentStructure.default_table_run_style)
175
+ number += 1
176
+ doc_structure.elements << table
177
+ end
178
+ end
179
+ body.xpath('w:sectPr').each do |sect_pr|
180
+ doc_structure.page_properties = PageProperties.parse(sect_pr, @default_paragraph, @default_character)
181
+ doc_structure.notes = doc_structure.page_properties.notes # keep copy of notes to compatibility with previous docx models
182
+ end
183
+ end
184
+ end
185
+ OOXMLDocumentObject.xmls_stack.pop
186
+ doc_structure.document_properties = DocumentProperties.parse
187
+ doc_structure.comments = Comment.parse_list
188
+ doc_structure
189
+ end
190
+
191
+ def self.parse_default_style
192
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/styles.xml'))
193
+ doc.search('//w:style').each do |style|
194
+ next if style.attribute('default').nil?
195
+ if (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'paragraph'
196
+ style.xpath('w:pPr').each do |paragraph_pr_tag|
197
+ DocxParagraph.parse_paragraph_style(paragraph_pr_tag, @default_paragraph, @default_character)
198
+ end
199
+ style.xpath('w:rPr').each do |character_pr_tag|
200
+ DocxParagraphRun.parse(character_pr_tag, @default_character, @default_character)
201
+ end
202
+ elsif (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'character'
203
+ style.xpath('w:rPr').each do |character_pr_tag|
204
+ DocxParagraphRun.parse(character_pr_tag, @default_character, @default_character)
205
+ end
206
+ end
207
+ end
208
+ DocumentStructure.default_table_paragraph_style = @default_paragraph.copy
209
+ DocumentStructure.default_table_paragraph_style.spacing = Spacing.new(0, 0, 1, :auto)
210
+ DocumentStructure.default_table_run_style = @default_character.copy
211
+ doc.search('//w:style').each do |style|
212
+ next if style.attribute('default').nil?
213
+ next unless (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'table'
214
+ style.xpath('w:tblPr').each do |table_pr_tag|
215
+ @default_table_properties = TableProperties.parse(table_pr_tag)
216
+ end
217
+ style.xpath('w:pPr').each do |table_paragraph_pr_tag|
218
+ DocxParagraph.parse_paragraph_style(table_paragraph_pr_tag, @default_table_paragraph, @default_table_character)
219
+ end
220
+ style.xpath('w:rPr').each do |table_character_pr_tag|
221
+ DocxParagraphRun.parse(table_character_pr_tag, @default_table_character, @default_character)
222
+ end
223
+ end
224
+ end
225
+
226
+ class << self
227
+ attr_accessor :default_table_run_style
228
+ attr_accessor :default_table_paragraph_style
229
+ attr_accessor :default_paragraph_style
230
+ end
231
+ end
232
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../common_parser/common_data/ooxml_document_object'
2
+ require_relative 'docx_data/document_structure'
3
+
4
+ module OoxmlParser
5
+ class DocxParser
6
+ def self.parse_docx(path_to_file)
7
+ path_to_zip_file = OOXMLDocumentObject.copy_file_and_rename_to_zip(path_to_file)
8
+ OOXMLDocumentObject.unzip_file(path_to_zip_file, path_to_zip_file.sub(File.basename(path_to_zip_file), ''))
9
+ OOXMLDocumentObject.path_to_folder = path_to_zip_file.sub(File.basename(path_to_zip_file), '')
10
+ docx_model = DocumentStructure.parse(OOXMLDocumentObject.path_to_folder)
11
+ docx_model.file_path = path_to_file
12
+ FileUtils.remove_dir(OOXMLDocumentObject.path_to_folder)
13
+ docx_model
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ # Class for working with strings
2
+ module OoxmlParser
3
+ class StringHelper
4
+ class << self
5
+ # This method check if string contains numeric
6
+ # @return [True, False] result of comparison
7
+ def numeric?(string)
8
+ true if Float(string)
9
+ rescue ArgumentError
10
+ false
11
+ end
12
+
13
+ # Check if string is complex number
14
+ # @return [True, False] result of comparison
15
+ def complex?(string)
16
+ true if Complex(string.tr(',', '.'))
17
+ rescue ArgumentError
18
+ false
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module OoxmlParser
2
+ class PresentationCommentAuthor < OOXMLDocumentObject
3
+ attr_accessor :id, :name, :initials
4
+
5
+ def initialize(id, name, initials)
6
+ @id = id
7
+ @name = name
8
+ @initials = initials
9
+ end
10
+
11
+ def self.parse
12
+ comment_authors = {}
13
+ begin
14
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'ppt/commentAuthors.xml'))
15
+ rescue StandardError
16
+ raise "Can't find commentAuthors.xml in #{OOXMLDocumentObject.path_to_folder}/ppt folder"
17
+ end
18
+ doc.xpath('p:cmAuthorLst/p:cmAuthor').each do |author_node|
19
+ comment_authors[author_node.attribute('id').value] = PresentationCommentAuthor.new(
20
+ author_node.attribute('id').value, author_node.attribute('name').value, author_node.attribute('initials').value)
21
+ end
22
+ comment_authors
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'presentation_comment/presentation_comment_author'
2
+ module OoxmlParser
3
+ class PresentationComment < OOXMLDocumentObject
4
+ attr_accessor :author, :position, :text
5
+
6
+ def initialize(author)
7
+ @author = author
8
+ end
9
+
10
+ def self.parse(comment_node, comment_authors)
11
+ comment = PresentationComment.new(comment_authors[comment_node.attribute('authorId').value])
12
+ comment_node.xpath('*').each do |comment_node_child|
13
+ case comment_node_child.name
14
+ when 'pos'
15
+ comment.position = OOXMLShift.parse(comment_node_child, 'x', 'y', 1)
16
+ when 'text'
17
+ comment.text = comment_node_child.text.to_s
18
+ end
19
+ end
20
+ comment
21
+ end
22
+
23
+ def self.parse_list
24
+ File.exist?(OOXMLDocumentObject.path_to_folder + 'ppt/comments/comment1.xml') ? doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + '/ppt/comments/comment1.xml')) : (return [])
25
+ comment_authors = PresentationCommentAuthor.parse
26
+ comments = []
27
+ doc.xpath('p:cmLst/p:cm').each { |comment_node| comments << PresentationComment.parse(comment_node, comment_authors) }
28
+ comments
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ module OoxmlParser
2
+ class ThemeColor
3
+ attr_accessor :type, :value, :color
4
+
5
+ def initialize(type = '', color = nil)
6
+ @type = type
7
+ @color = color
8
+ end
9
+
10
+ def ==(other)
11
+ if other.is_a?(Color)
12
+ @color == other
13
+ else
14
+ all_instance_variables = instance_variables
15
+ all_instance_variables.each do |current_attributes|
16
+ unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
17
+ return false
18
+ end
19
+ end
20
+ true
21
+ end
22
+ end
23
+
24
+ def self.parse(color_node)
25
+ theme_color = ThemeColor.new
26
+ color_node.xpath('*').each do |color_node_child|
27
+ case color_node_child.name
28
+ when 'sysClr'
29
+ theme_color.type = :system
30
+ theme_color.value = color_node_child.attribute('val').value
31
+ theme_color.color = Color.from_int16(color_node_child.attribute('lastClr').value.to_s) unless color_node_child.attribute('lastClr').nil?
32
+ when 'srgbClr'
33
+ theme_color.type = :rgb
34
+ theme_color.color = Color.from_int16(color_node_child.attribute('val').value.to_s)
35
+ end
36
+ end
37
+ theme_color
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ require_relative 'presentation_theme/theme_color'
2
+ module OoxmlParser
3
+ class PresentationTheme < OOXMLDocumentObject
4
+ attr_accessor :name, :color_scheme
5
+
6
+ def initialize(name = '', color_scheme = {})
7
+ @name = name
8
+ @color_scheme = color_scheme
9
+ end
10
+
11
+ def self.parse(file)
12
+ OOXMLDocumentObject.theme = PresentationTheme.new
13
+ OOXMLDocumentObject.add_to_xmls_stack(file)
14
+ unless File.exist?(OOXMLDocumentObject.current_xml)
15
+ OOXMLDocumentObject.xmls_stack.pop
16
+ return
17
+ end
18
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
19
+ doc.xpath('a:theme').each do |theme_node|
20
+ OOXMLDocumentObject.theme.name = theme_node.attribute('name').value
21
+ theme_node.xpath('a:themeElements/*').each do |theme_element_node|
22
+ case theme_element_node.name
23
+ when 'clrScheme'
24
+ theme_element_node.xpath('*').each do |color_scheme_element|
25
+ OOXMLDocumentObject.theme.color_scheme[color_scheme_element.name.to_sym] = ThemeColor.parse(color_scheme_element)
26
+ end
27
+ OOXMLDocumentObject.theme.color_scheme[:background1] = OOXMLDocumentObject.theme.color_scheme[:lt1]
28
+ OOXMLDocumentObject.theme.color_scheme[:background2] = OOXMLDocumentObject.theme.color_scheme[:lt2]
29
+ OOXMLDocumentObject.theme.color_scheme[:bg1] = OOXMLDocumentObject.theme.color_scheme[:lt1]
30
+ OOXMLDocumentObject.theme.color_scheme[:bg2] = OOXMLDocumentObject.theme.color_scheme[:lt2]
31
+ OOXMLDocumentObject.theme.color_scheme[:text1] = OOXMLDocumentObject.theme.color_scheme[:dk1]
32
+ OOXMLDocumentObject.theme.color_scheme[:text2] = OOXMLDocumentObject.theme.color_scheme[:dk2]
33
+ OOXMLDocumentObject.theme.color_scheme[:tx1] = OOXMLDocumentObject.theme.color_scheme[:dk1]
34
+ OOXMLDocumentObject.theme.color_scheme[:tx2] = OOXMLDocumentObject.theme.color_scheme[:dk2]
35
+ end
36
+ end
37
+ end
38
+ OOXMLDocumentObject.xmls_stack.pop
39
+ ThemeColors.list = {}
40
+ OOXMLDocumentObject.theme.color_scheme.each { |key, value| ThemeColors.list[key] = value.color }
41
+ OOXMLDocumentObject.theme
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,19 @@
1
+ module OoxmlParser
2
+ class Background < OOXMLDocumentObject
3
+ attr_accessor :fill, :shade_to_title
4
+
5
+ def initialize(type = nil)
6
+ @type = type
7
+ end
8
+
9
+ def self.parse(background_node)
10
+ background = Background.new
11
+ background_properties_node = background_node.xpath('p:bgPr').first
12
+ if background_properties_node
13
+ background.shade_to_title = OOXMLDocumentObject.option_enabled?(background_properties_node, 'shadeToTitle')
14
+ background.fill = PresentationFill.parse(background_properties_node)
15
+ end
16
+ background
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ module OoxmlParser
2
+ class GraphicFrame < OOXMLDocumentObject
3
+ attr_accessor :properties, :transform, :graphic_data
4
+
5
+ def initialize(graphic_data = [])
6
+ @graphic_data = graphic_data
7
+ end
8
+
9
+ def self.parse(graphic_frame_node)
10
+ graphic_frame = GraphicFrame.new
11
+ graphic_frame_node.xpath('*').each do |graphic_frame_node_child|
12
+ case graphic_frame_node_child.name
13
+ when 'nvGraphicFramePr'
14
+ when 'xfrm'
15
+ graphic_frame.transform = TransformEffect.parse(graphic_frame_node_child)
16
+ when 'graphic'
17
+ graphic_data = []
18
+ graphic_frame_node_child.xpath('a:graphicData/*').each do |graphic_node_child|
19
+ case graphic_node_child.name
20
+ when 'tbl'
21
+ graphic_data << Table.parse(graphic_node_child)
22
+ when 'chart'
23
+ OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
24
+ graphic_data << Chart.parse
25
+ OOXMLDocumentObject.xmls_stack.pop
26
+ end
27
+ end
28
+ graphic_frame.graphic_data = graphic_data
29
+ end
30
+ end
31
+ graphic_frame
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'transition/transition'
2
+ module OoxmlParser
3
+ class PresentationAlternateContent < OOXMLDocumentObject
4
+ attr_accessor :transition, :timing, :elements
5
+
6
+ def initialize(elements = [])
7
+ @elements = elements
8
+ end
9
+
10
+ def self.parse(alternate_content_node)
11
+ alternate_content = PresentationAlternateContent.new
12
+ alternate_content_node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |choice_node_child|
13
+ case choice_node_child.name
14
+ when 'timing'
15
+ alternate_content.timing = Timing.parse(choice_node_child)
16
+ when 'transition'
17
+ alternate_content.transition = Transition.parse(choice_node_child)
18
+ when 'sp'
19
+ alternate_content.elements << PresentationShape.parse(choice_node_child)
20
+ end
21
+ end
22
+ alternate_content
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module OoxmlParser
2
+ class HyperlinkForHover
3
+ attr_accessor :id, :action, :sound
4
+
5
+ def initialize(id = '', action = '')
6
+ @id = id
7
+ @action = action
8
+ end
9
+
10
+ def self.parse(hyperlink_for_hover_node)
11
+ hyperlink_for_hover = HyperlinkForHover.new
12
+ hyperlink_for_hover.id = hyperlink_for_hover_node.attribute('id').value
13
+ hyperlink_for_hover.action = hyperlink_for_hover_node.attribute('action').value
14
+ hyperlink_for_hover_node.xpath('*').each do |hyperlink_for_hover_node_child|
15
+ case hyperlink_for_hover_node_child.name
16
+ when 'snd'
17
+ hyperlink_for_hover.sound = Sound.parse(hyperlink_for_hover_node_child)
18
+ end
19
+ end
20
+ hyperlink_for_hover
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ module OoxmlParser
2
+ class Extents
3
+ attr_accessor :x, :y
4
+
5
+ def initialize(x = '', y = '')
6
+ @x = x
7
+ @y = y
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module OoxmlParser
2
+ class Offset
3
+ attr_accessor :x, :y
4
+
5
+ def initialize(x = '', y = '')
6
+ @x = x
7
+ @y = y
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module OoxmlParser
2
+ class PresentationParagraph
3
+ attr_accessor :properties, :characters, :text_field, :formulas
4
+
5
+ def initialize(characters = [], formulas = [])
6
+ @characters = characters
7
+ @formulas = formulas
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module OoxmlParser
2
+ class TextField
3
+ attr_accessor :id, :type, :text
4
+
5
+ def self.parse(text_field_node)
6
+ text_field = TextField.new
7
+ text_field.id = text_field_node.attribute('id').value
8
+ text_field.type = text_field_node.attribute('type').value
9
+ text_field_node.xpath('*').each do |text_field_node_child|
10
+ case text_field_node_child.name
11
+ when 't'
12
+ text_field.text = text_field_node_child.text
13
+ end
14
+ end
15
+ text_field
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module OoxmlParser
2
+ class ShapesGrouping
3
+ attr_accessor :elements, :properties
4
+
5
+ def initialize(elements = [])
6
+ @elements = elements
7
+ end
8
+ end
9
+ end