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,83 @@
1
+ require_relative 'table_style_elements'
2
+ require_relative 'table_element'
3
+ # Style of Table
4
+ module OoxmlParser
5
+ class TableStyle < OOXMLDocumentObject
6
+ attr_accessor :id, :name, :whole_table, :banding_1_horizontal, :banding_2_horizontal, :banding_1_vertical, :banding_2_vertical,
7
+ :last_column, :first_column, :last_row, :first_row, :southeast_cell, :southwest_cell, :northeast_cell,
8
+ :northwest_cell
9
+
10
+ def initialize(id = nil)
11
+ @id = id
12
+ @banding_1_horizontal = TableStyleElement.new
13
+ @banding_2_horizontal = TableStyleElement.new
14
+ @banding_1_vertical = TableStyleElement.new
15
+ @banding_2_vertical = TableStyleElement.new
16
+ @last_column = TableStyleElement.new
17
+ @first_column = TableStyleElement.new
18
+ @last_row = TableStyleElement.new
19
+ @first_row = TableStyleElement.new
20
+ @southeast_cell = TableStyleElement.new
21
+ @southwest_cell = TableStyleElement.new
22
+ @northeast_cell = TableStyleElement.new
23
+ @northwest_cell = TableStyleElement.new
24
+ end
25
+
26
+ def self.parse(style_id: nil, table_style_node: nil)
27
+ table_style = TableStyle.new
28
+ if !style_id.nil?
29
+ nodes = get_style_node(style_id)
30
+ xpath = '*'
31
+ attributes = 'style_node_child.name'
32
+ elsif !table_style_node.nil?
33
+ nodes = table_style_node
34
+ xpath = 'w:tblStylePr'
35
+ attributes = "style_node_child.attribute('type').value"
36
+ end
37
+ begin
38
+ nodes.xpath(xpath).each do |style_node_child|
39
+ case instance_eval(attributes)
40
+ when 'wholeTbl'
41
+ table_style.whole_table = TableElement.parse(style_node_child)
42
+ when 'band1H'
43
+ table_style.banding_1_horizontal = TableElement.parse(style_node_child)
44
+ when 'band2H', 'band2Horz'
45
+ table_style.banding_2_horizontal = TableElement.parse(style_node_child)
46
+ when 'band1V'
47
+ table_style.banding_1_vertical = TableElement.parse(style_node_child)
48
+ when 'band2V'
49
+ table_style.banding_2_vertical = TableElement.parse(style_node_child)
50
+ when 'lastCol'
51
+ table_style.last_column = TableElement.parse(style_node_child)
52
+ when 'firstCol'
53
+ table_style.first_column = TableElement.parse(style_node_child)
54
+ when 'lastRow'
55
+ table_style.last_row = TableElement.parse(style_node_child)
56
+ when 'firstRow'
57
+ table_style.first_row = TableElement.parse(style_node_child)
58
+ when 'seCell'
59
+ table_style.southeast_cell = TableElement.parse(style_node_child)
60
+ when 'swCell'
61
+ table_style.southwest_cell = TableElement.parse(style_node_child)
62
+ when 'neCell'
63
+ table_style.northeast_cell = TableElement.parse(style_node_child)
64
+ when 'nwCell'
65
+ table_style.northwest_cell = TableElement.parse(style_node_child)
66
+ end
67
+ end
68
+ end
69
+ table_style.id = style_id unless style_id.nil?
70
+ table_style
71
+ end
72
+
73
+ def self.get_style_node(style_id)
74
+ begin
75
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'ppt/tableStyles.xml'))
76
+ rescue StandardError
77
+ raise 'Can\'t find tableStyles.xml in ' + OOXMLDocumentObject.path_to_folder.to_s + '/ppt folder'
78
+ end
79
+ doc.xpath('a:tblStyleLst/a:tblStyle').each { |table_style_node| return table_style_node if table_style_node.attribute('styleId').value == style_id }
80
+ nil
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,21 @@
1
+ # Table Style in XLSX
2
+ module OoxmlParser
3
+ class TableStyleElement
4
+ attr_accessor :cell_properties
5
+
6
+ def initialize
7
+ @cell_properties = CellProperties.new
8
+ end
9
+
10
+ def self.parse(style_node)
11
+ element_style = TableStyleElement.new
12
+ style_node.xpath('*').each do |style_node_child|
13
+ case style_node_child.name
14
+ when 'tcPr'
15
+ element_style.cell_properties = CellProperties.parse(style_node_child)
16
+ end
17
+ end
18
+ element_style
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module OoxmlParser
2
+ class LineJoin
3
+ attr_accessor :type, :limit
4
+
5
+ def self.parse(parent_node)
6
+ line_join = LineJoin.new
7
+ parent_node.xpath('*').each do |line_join_node|
8
+ case line_join_node.name
9
+ when 'round', 'bevel'
10
+ line_join.type = line_join_node.name.to_sym
11
+ when 'miter'
12
+ line_join.type = :miter
13
+ line_join.limit = line_join_node.attribute('lim').value.to_f
14
+ end
15
+ end
16
+ line_join
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'line_join'
2
+ # Table Cell Style in XLSX
3
+ module OoxmlParser
4
+ class TableCellStyle
5
+ attr_accessor :borders, :fill
6
+
7
+ def self.parse(cell_style_node)
8
+ cell_style = TableCellStyle.new
9
+ cell_style_node.xpath('*').each do |cell_node_child|
10
+ case cell_node_child.name
11
+ when 'tcBdr'
12
+ cell_style.borders = Borders.parse(cell_node_child)
13
+ when 'fill'
14
+ cell_style.fill = PresentationFill.parse(cell_node_child)
15
+ end
16
+ end
17
+ cell_style
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'properties/borders'
2
+ require_relative 'cell_properties'
3
+ module OoxmlParser
4
+ class TableCell < OOXMLDocumentObject
5
+ attr_accessor :text_body, :properties, :grid_span, :horizontal_merge, :vertical_merge, :elements
6
+
7
+ def initialize(text_body = nil)
8
+ @text_body = text_body
9
+ @elements = []
10
+ end
11
+
12
+ alias cell_properties properties
13
+
14
+ def self.parse(cell_node)
15
+ cell = TableCell.new
16
+ cell_node.xpath('*').each do |cell_node_child|
17
+ case cell_node_child.name
18
+ when 'txBody'
19
+ cell.text_body = TextBody.parse(cell_node_child)
20
+ when 'tcPr'
21
+ cell.properties = CellProperties.parse(cell_node_child)
22
+ when 'p'
23
+ paragraph = DocxParagraph.parse(cell_node_child, 0, DocumentStructure.default_table_paragraph_style, DocumentStructure.default_table_run_style)
24
+ cell.elements << paragraph
25
+ when 'tbl'
26
+ table = Table.parse(cell_node_child)
27
+ cell.elements << table
28
+ end
29
+ end
30
+ cell_node.attributes.each do |key, value|
31
+ case key
32
+ when 'gridSpan'
33
+ cell.grid_span = value.value.to_i
34
+ when 'hMerge'
35
+ cell.horizontal_merge = value.value.to_i
36
+ when 'vMerge'
37
+ cell.vertical_merge = value.value.to_i
38
+ end
39
+ end
40
+ cell
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,142 @@
1
+ require_relative 'merge'
2
+ module OoxmlParser
3
+ class CellProperties < OOXMLDocumentObject
4
+ attr_accessor :fill, :color, :borders, :margins, :text_direction, :anchor, :anchor_center, :horizontal_overflow, :merge, :table_cell_width, :borders_properties, :shd, :vertical_align
5
+
6
+ def initialize(borders = nil, color = nil)
7
+ @borders = borders
8
+ @color = color
9
+ @fill = fill
10
+ @shd = :none
11
+ @merge = false
12
+ end
13
+
14
+ alias table_cell_margin margins
15
+ alias table_cell_margin= margins=
16
+
17
+ def self.parse(cell_properties_node)
18
+ cell_properties = CellProperties.new(Borders.parse(cell_properties_node), PresentationFill.parse(cell_properties_node))
19
+ cell_properties.margins = ParagraphMargins.parse(cell_properties_node)
20
+ cell_properties_node.attributes.each do |key, value|
21
+ case key
22
+ when 'vert'
23
+ cell_properties.text_direction = value.value.to_sym
24
+ when 'anchor'
25
+ cell_properties.anchor = Alignment.parse(value)
26
+ when 'anchorCtr'
27
+ cell_properties.anchor_center = value.value
28
+ when 'horzOverflow'
29
+ cell_properties.horizontal_overflow = value.value.to_sym
30
+ end
31
+ end
32
+ cell_borders = Borders.new
33
+ parse_w_namespace = true
34
+ begin
35
+ cell_properties_node.xpath('w:vMerge') # TODO: Perform not so stupit check
36
+ rescue Nokogiri::XML::XPath::SyntaxError
37
+ parse_w_namespace = false
38
+ end
39
+ if parse_w_namespace
40
+ cell_properties_node.xpath('w:vMerge').each do |v_merge|
41
+ merge = v_merge.attribute('count_rows_in_span').nil? ? nil : v_merge.attribute('count_rows_in_span').value
42
+ cell_properties.merge = CellMerge.new('vertical', v_merge.attribute('val').value, merge)
43
+ end
44
+ cell_properties_node.xpath('w:vAlign').each do |valign_node|
45
+ cell_properties.vertical_align = valign_node.attribute('val').value.to_sym
46
+ end
47
+ cell_properties_node.xpath('w:gridSpan').each do |grid_span|
48
+ cell_properties.merge = CellMerge.new('horizontal', grid_span.attribute('val').value)
49
+ end
50
+ cell_properties_node.xpath('w:tcW').each do |table_cell_width|
51
+ cell_properties.table_cell_width = table_cell_width.attribute('w').value.to_f / 567.5
52
+ end
53
+ cell_properties_node.xpath('w:tcMar').each do |cell_margins_node|
54
+ cell_properties.table_cell_margin = TableMargins.parse(cell_margins_node)
55
+ end
56
+ cell_properties_node.xpath('w:textDirection').each do |text_direction|
57
+ cell_properties.text_direction = Alignment.parse(text_direction.attribute('val'))
58
+ end
59
+ cell_properties_node.xpath('w:tcBorders').each do |tc_boders|
60
+ tc_boders.xpath('w:top').each do |top|
61
+ top_border = BordersProperties.new
62
+ top_border.color = top.attribute('color').value
63
+ if !top.attribute('color').nil? && top.attribute('color').value != 'auto'
64
+ top_border.color = Color.from_int16(top.attribute('color').value)
65
+ end
66
+ top_border.sz = top.attribute('sz').value.to_f / 8.0
67
+ top_border.val = top.attribute('val').value
68
+ top_border.space = top.attribute('space').value
69
+ cell_borders.top = top_border
70
+ end
71
+ tc_boders.xpath('w:right').each do |right|
72
+ right_border = BordersProperties.new
73
+ right_border.color = right.attribute('color').value
74
+ if !right.attribute('color').nil? && right.attribute('color').value != 'auto'
75
+ right_border.color = Color.from_int16(right.attribute('color').value)
76
+ end
77
+ right_border.sz = right.attribute('sz').value.to_f / 8.0
78
+ right_border.val = right.attribute('val').value
79
+ right_border.space = right.attribute('space').value
80
+ cell_borders.right = right_border
81
+ end
82
+ tc_boders.xpath('w:left').each do |left|
83
+ left_border = BordersProperties.new
84
+ left_border.color = left.attribute('color').value
85
+ if !left.attribute('color').nil? && left.attribute('color').value != 'auto'
86
+ left_border.color = Color.from_int16(left.attribute('color').value)
87
+ end
88
+ left_border.sz = left.attribute('sz').value.to_f / 8.0
89
+ left_border.val = left.attribute('val').value
90
+ left_border.space = left.attribute('space').value
91
+ cell_borders.left = left_border
92
+ end
93
+ tc_boders.xpath('w:bottom').each do |bottom|
94
+ bottom_border = BordersProperties.new
95
+ bottom_border.color = bottom.attribute('color').value
96
+ if !bottom.attribute('color').nil? && bottom.attribute('color').value != 'auto'
97
+ bottom_border.color = Color.from_int16(bottom.attribute('color').value)
98
+ end
99
+ bottom_border.sz = bottom.attribute('sz').value.to_f / 8.0
100
+ bottom_border.val = bottom.attribute('val').value
101
+ bottom_border.space = bottom.attribute('space').value
102
+ cell_borders.bottom = bottom_border
103
+ end
104
+ tc_boders.xpath('w:tl2br').each do |tl2br|
105
+ top_left_to_bottom_right = BordersProperties.new
106
+ top_left_to_bottom_right.color = tl2br.attribute('color').value
107
+ if !tl2br.attribute('color').nil? && tl2br.attribute('color').value != 'auto'
108
+ top_left_to_bottom_right.color = Color.from_int16(tl2br.attribute('color').value)
109
+ end
110
+ top_left_to_bottom_right.sz = tl2br.attribute('sz').value.to_f / 8.0
111
+ top_left_to_bottom_right.val = tl2br.attribute('val').value
112
+ top_left_to_bottom_right.space = tl2br.attribute('space').value
113
+ cell_borders.top_left_to_bottom_right = top_left_to_bottom_right
114
+ end
115
+ tc_boders.xpath('w:tr2bl').each do |tr2bl|
116
+ top_right_to_bottom_left = BordersProperties.new
117
+ top_right_to_bottom_left.color = tr2bl.attribute('color').value
118
+ if !tr2bl.attribute('color').nil? && tr2bl.attribute('color').value != 'auto'
119
+ top_right_to_bottom_left.color = Color.from_int16(tr2bl.attribute('color').value)
120
+ end
121
+ top_right_to_bottom_left.sz = tr2bl.attribute('sz').value.to_f / 8.0
122
+ top_right_to_bottom_left.val = tr2bl.attribute('val').value
123
+ top_right_to_bottom_left.space = tr2bl.attribute('space').value
124
+ cell_borders.top_right_to_bottom_left = top_right_to_bottom_left
125
+ end
126
+ end
127
+ cell_properties_node.xpath('w:shd').each do |shd|
128
+ cell_properties.shd = shd.attribute('fill').value
129
+ if !shd.attribute('fill').nil? && shd.attribute('fill').value != 'auto'
130
+ cell_properties.shd = Color.from_int16(shd.attribute('fill').value)
131
+ end
132
+ end
133
+ else
134
+ cell_properties_node.xpath('a:fill').each do |fill|
135
+ cell_properties.fill = DocxColorScheme.parse(fill)
136
+ end
137
+ end
138
+ cell_properties.borders_properties = cell_borders
139
+ cell_properties
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,18 @@
1
+ module OoxmlParser
2
+ class CellMerge
3
+ attr_accessor :type, :count_of_merged_cells, :value
4
+
5
+ def initialize(type = 'horizontal', value = nil, count_of_merged_cells = 2)
6
+ @type = type
7
+ @count_of_merged_cells = count_of_merged_cells
8
+ @value = value
9
+ end
10
+
11
+ def self.parse_merge_hash(hash)
12
+ merge = CellMerge.new
13
+ merge.type = hash['type']
14
+ merge.count_of_merged_cells = hash['count_of_merged_cells']
15
+ merge
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'table_cell_line'
2
+ # Border Data
3
+ module OoxmlParser
4
+ class Border
5
+ attr_accessor :style, :color
6
+
7
+ def initialize(style = nil, color = nil)
8
+ @style = style
9
+ @color = color
10
+ end
11
+
12
+ def ==(other)
13
+ return true if nil? && other.nil?
14
+ return false if nil? && !other.nil?
15
+ return false if !nil? && other.nil?
16
+ return false if style != other.style
17
+ return false if color != other.color
18
+ true
19
+ end
20
+
21
+ def to_s
22
+ "Border style: #{style}, color: #{color}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,125 @@
1
+ require_relative 'border'
2
+ module OoxmlParser
3
+ class Borders < OOXMLDocumentObject
4
+ attr_accessor :left, :right, :top, :bottom, :inner_vertical, :inner_horizontal, :display, :between, :bar,
5
+ :top_left_to_bottom_right, :top_right_to_bottom_left, :offset_from
6
+
7
+ def initialize(left = BordersProperties.new,
8
+ right = BordersProperties.new,
9
+ top = BordersProperties.new,
10
+ bottom = BordersProperties.new,
11
+ between = BordersProperties.new)
12
+ @left = left
13
+ @right = right
14
+ @top = top
15
+ @bottom = bottom
16
+ @between = between
17
+ end
18
+
19
+ def copy
20
+ new_borders = Borders.new(@left, @right, @top, @bottom)
21
+ new_borders.inner_vertical = @inner_vertical unless @inner_vertical.nil?
22
+ new_borders.inner_horizontal = @inner_horizontal unless @inner_horizontal.nil?
23
+ new_borders.between = @between unless @between.nil?
24
+ new_borders.display = @display unless @display.nil?
25
+ new_borders.bar = @bar unless bar.nil?
26
+ new_borders
27
+ end
28
+
29
+ def ==(other)
30
+ @left == other.left && @right == other.right && @top == other.top && @bottom == other.bottom if other.is_a?(Borders)
31
+ end
32
+
33
+ def each_border
34
+ yield(bottom)
35
+ yield(inner_horizontal)
36
+ yield(inner_vertical)
37
+ yield(left)
38
+ yield(right)
39
+ yield(top)
40
+ end
41
+
42
+ def each_side
43
+ yield(bottom)
44
+ yield(left)
45
+ yield(right)
46
+ yield(top)
47
+ end
48
+
49
+ def border_visual_type
50
+ result = []
51
+ result << :left if @left.val == :single
52
+ result << :right if @right.val == :single
53
+ result << :top if @top.val == :single
54
+ result << :bottom if @bottom.val == :single
55
+ result << :inner if @between.val == :single
56
+ return :none if result == []
57
+ return :all if result == [:left, :right, :top, :bottom, :inner]
58
+ return :outer if result == [:left, :right, :top, :bottom]
59
+ return result.first if result.size == 1
60
+ end
61
+
62
+ def to_s
63
+ "Left border: #{left}, Right: #{right}, Top: #{top}, Bottom: #{bottom}"
64
+ end
65
+
66
+ def visible?
67
+ visible = false
68
+ each_side do |current_size|
69
+ visible ||= current_size.visible?
70
+ end
71
+ visible
72
+ end
73
+
74
+ def self.parse(borders_node)
75
+ borders = Borders.new
76
+ borders_node.xpath('*').each do |border_node|
77
+ case border_node.name
78
+ when 'lnL', 'left'
79
+ borders.left = TableCellLine.parse(border_node)
80
+ when 'lnR', 'right'
81
+ borders.right = TableCellLine.parse(border_node)
82
+ when 'lnT', 'top'
83
+ borders.top = TableCellLine.parse(border_node)
84
+ when 'lnB', 'bottom'
85
+ borders.bottom = TableCellLine.parse(border_node)
86
+ when 'lnTlToBr', 'tl2br'
87
+ borders.top_left_to_bottom_right = TableCellLine.parse(border_node)
88
+ when 'lnBlToTr', 'tr2bl'
89
+ borders.top_right_to_bottom_left = TableCellLine.parse(border_node)
90
+ when 'insideV'
91
+ borders.inner_vertical = TableCellLine.parse(border_node)
92
+ when 'insideH'
93
+ borders.inner_horizontal = TableCellLine.parse(border_node)
94
+ end
95
+ end
96
+ borders
97
+ end
98
+
99
+ def self.parse_from_style(style_number)
100
+ border_style_node = XLSXWorkbook.styles_node.xpath('//xmlns:border')[style_number.to_i]
101
+ cell_borders = Borders.new
102
+ unless border_style_node.xpath('xmlns:bottom')[0].attribute('style').nil?
103
+ cell_borders.bottom = Border.new
104
+ cell_borders.bottom.style = border_style_node.xpath('xmlns:bottom')[0].attribute('style').value
105
+ cell_borders.bottom.color = Color.parse_color_tag(border_style_node.xpath('xmlns:bottom/xmlns:color')[0])
106
+ end
107
+ unless border_style_node.xpath('xmlns:top')[0].attribute('style').nil?
108
+ cell_borders.top = Border.new
109
+ cell_borders.top.style = border_style_node.xpath('xmlns:top')[0].attribute('style').value
110
+ cell_borders.top.color = Color.parse_color_tag(border_style_node.xpath('xmlns:top/xmlns:color')[0])
111
+ end
112
+ unless border_style_node.xpath('xmlns:right')[0].attribute('style').nil?
113
+ cell_borders.right = Border.new
114
+ cell_borders.right.style = border_style_node.xpath('xmlns:right')[0].attribute('style').value
115
+ cell_borders.right.color = Color.parse_color_tag(border_style_node.xpath('xmlns:right/xmlns:color')[0])
116
+ end
117
+ unless border_style_node.xpath('xmlns:left')[0].attribute('style').nil?
118
+ cell_borders.left = Border.new
119
+ cell_borders.left.style = border_style_node.xpath('xmlns:left')[0].attribute('style').value
120
+ cell_borders.left.color = Color.parse_color_tag(border_style_node.xpath('xmlns:left/xmlns:color')[0])
121
+ end
122
+ cell_borders
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,35 @@
1
+ module OoxmlParser
2
+ class TableCellLine < OOXMLDocumentObject
3
+ attr_accessor :fill, :dash, :line_join, :head_end, :tail_end, :align, :width, :cap_type, :compound_line_type
4
+
5
+ def initialize(fill = nil, line_join = nil)
6
+ @fill = fill
7
+ @line_join = line_join
8
+ end
9
+
10
+ def self.parse(border_node)
11
+ line = TableCellLine.new(PresentationFill.parse(border_node), LineJoin.parse(border_node))
12
+ border_node.xpath('*').each do |border_node_child|
13
+ case border_node_child.name
14
+ when 'prstDash'
15
+ when 'custDash'
16
+ when 'headEnd'
17
+ line.head_end = LineEnd.parse(border_node_child)
18
+ when 'tailEnd'
19
+ line.tail_end = LineEnd.parse(border_node_child)
20
+ when 'ln'
21
+ return TableCellLine.parse(border_node_child)
22
+ end
23
+ end
24
+ border_node.attributes.each do |key, value|
25
+ case key
26
+ when 'w'
27
+ line.width = value.value.to_f / 12_700.0
28
+ when 'algn'
29
+ line.align = Alignment.parse(value)
30
+ end
31
+ end
32
+ line
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ module OoxmlParser
2
+ # Class for describing Table Row Properties
3
+ class TableRowProperties
4
+ # @return [Float] Table Row Height
5
+ attr_accessor :height
6
+
7
+ def initialize
8
+ @height = nil
9
+ end
10
+
11
+ # Parse Columns data
12
+ # @param [Nokogiri::XML:Element] node with Table Row Properties data
13
+ # @return [TableRowProperties] value of Columns data
14
+ def self.parse(node)
15
+ properties = TableRowProperties.new
16
+ node.xpath('w:trHeight').each do |height|
17
+ properties.height = height.attribute('val').value.to_f
18
+ end
19
+ properties
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'cell/cell'
2
+ require_relative 'row/table_row_properties'
3
+ module OoxmlParser
4
+ class TableRow < OOXMLDocumentObject
5
+ attr_accessor :height, :cells, :cells_spacing, :table_row_properties
6
+
7
+ def initialize(cells = [])
8
+ @cells = cells
9
+ end
10
+
11
+ alias table_row_height height
12
+
13
+ def self.parse(row_node)
14
+ row = TableRow.new
15
+ row.height = (row_node.attribute('h').value.to_f / 360_000.0).round(2) unless row_node.attribute('h').nil?
16
+ row_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:trPr").each do |table_prop_node|
17
+ row.table_row_properties = TableRowProperties.parse(table_prop_node)
18
+ end
19
+ row_node.xpath('*').each do |row_node_child|
20
+ row_node_child.xpath('*').each do |row_properties|
21
+ case row_properties.name
22
+ when 'tblCellSpacing'
23
+ row.cells_spacing = (row_properties.attribute('w').value.to_f / 283.3).round(2)
24
+ end
25
+ end
26
+ end
27
+ Presentation.current_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
28
+ row_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:tc").each { |cell_node| row.cells << TableCell.parse(cell_node) }
29
+ Presentation.current_font_style = FontStyle.new
30
+ row
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ module OoxmlParser
2
+ class TableGrid
3
+ attr_accessor :columns, :mass_of_width_cells
4
+
5
+ def initialize(columns = [])
6
+ @columns = columns
7
+ end
8
+ end
9
+ end