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
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # ooxml_parser
2
+
3
+ _ooxml_parser_ is a Ooxml files (docx, xlsx, pptx) parser written in Ruby.
4
+
5
+ ## Installation
6
+
7
+ $ gem install parser
8
+
9
+ ## Usage
10
+
11
+ Parse a docx file
12
+
13
+ require 'ooxml_parser'
14
+ docx = OoxmlParser::DocxParser.parse_docx('spec/docx_examples/document_properties/page_count.docx')
15
+ p docx.document_properties.pages # 2
16
+
17
+
18
+ ## Configuration
19
+
20
+ Set units of mesaurements:
21
+ Possible units are `:points`, `:centimeters`, `:dxa`, `:inches`, `:emu`
22
+ Default is `:centimeters`
23
+
24
+ OoxmlParser.configure do |config|
25
+ config.units = :points
26
+ end
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.3.0
@@ -0,0 +1,56 @@
1
+ # Class for describing Alignment type
2
+ module OoxmlParser
3
+ class Alignment
4
+ # Parse TransitionDirection
5
+ # @param [Nokogiri::XML:Element] node with Alignment
6
+ # @return [Symbol] value of Alignment
7
+ def self.parse(node)
8
+ case node.value
9
+ when 'l'
10
+ :left
11
+ when 'ctr'
12
+ :center
13
+ when 'r'
14
+ :right
15
+ when 'just'
16
+ :justify
17
+ when 'b'
18
+ :bottom
19
+ when 't'
20
+ :top
21
+ when 'tr'
22
+ :top_right
23
+ when 'tl'
24
+ :top_left
25
+ when 'br'
26
+ :bottom_right
27
+ when 'bl'
28
+ :bottom_left
29
+ when 'dist'
30
+ :distributed
31
+ when 'tb'
32
+ :horizontal
33
+ when 'rl'
34
+ :rotate_on_90
35
+ when 'lr'
36
+ :rotate_on_270
37
+ when 'inset'
38
+ :in
39
+ when 'lu'
40
+ :left_up
41
+ when 'ru'
42
+ :right_up
43
+ when 'ld'
44
+ :left_down
45
+ when 'rd'
46
+ :right_down
47
+ when 'd'
48
+ :down
49
+ when 'u'
50
+ :up
51
+ else
52
+ node.value.to_sym
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,34 @@
1
+ require_relative 'chart/chart'
2
+ require_relative 'drawing/docx_drawing'
3
+ require_relative 'shape/shape'
4
+ require_relative 'picture/old_docx_picture'
5
+ # Class for storing fallback graphic elements
6
+ module OoxmlParser
7
+ class AlternateContent
8
+ attr_accessor :office2010_content, :office2007_content
9
+
10
+ def self.parse(alt_content_node)
11
+ alternate_content = AlternateContent.new
12
+ alt_content_node.xpath('*').each do |alternate_content_node_child|
13
+ begin
14
+ alternate_content_node_child.xpath('w:drawing')
15
+ rescue Nokogiri::XML::XPath::SyntaxError # This mean it is Chart
16
+ case alternate_content_node_child.name
17
+ when 'Choice'
18
+ alternate_content.office2010_content = Office2010ChartStyle.parse(alternate_content_node_child)
19
+ when 'Fallback'
20
+ alternate_content.office2007_content = Office2007ChartStyle.parse(alternate_content_node_child)
21
+ end
22
+ next
23
+ end
24
+ case alternate_content_node_child.name
25
+ when 'Choice'
26
+ alternate_content.office2010_content = DocxDrawing.parse(alternate_content_node_child.xpath('w:drawing').first) unless alternate_content_node_child.xpath('w:drawing').first.nil?
27
+ when 'Fallback'
28
+ alternate_content.office2007_content = OldDocxPicture.parse(alternate_content_node_child.xpath('w:pict').first) unless alternate_content_node_child.xpath('w:pict').first.nil?
29
+ end
30
+ end
31
+ alternate_content
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,123 @@
1
+ require_relative 'chart_axis'
2
+ require_relative 'chart_cells_range'
3
+ require_relative 'chart_legend'
4
+ require_relative 'chart_point'
5
+ require_relative 'display_labels_properties'
6
+ require_relative 'chart_style/office_2007_chart_style'
7
+ require_relative 'chart_style/office_2010_chart_style'
8
+
9
+ module OoxmlParser
10
+ class Chart < OOXMLDocumentObject
11
+ attr_accessor :type, :data, :grouping, :title, :legend, :display_labels, :axises, :alternate_content, :shape_properties
12
+
13
+ def initialize
14
+ @type = ''
15
+ @data = []
16
+ @grouping = nil
17
+ @title = nil
18
+ @legend = nil
19
+ @axises = []
20
+ end
21
+
22
+ def parse_properties(chart_prop_node)
23
+ chart_prop_node.xpath('*').each do |chart_props_node_child|
24
+ case chart_props_node_child.name
25
+ when 'grouping'
26
+ @grouping = chart_props_node_child.attribute('val').value.to_sym
27
+ when 'ser'
28
+ case @type
29
+ when :bar, :line, :area, :pie, :doughnut, :radar, :stock, :surface_3d, :column
30
+ val = chart_props_node_child.xpath('c:val')[0]
31
+ when :point, :bubble
32
+ val = chart_props_node_child.xpath('c:yVal')[0]
33
+ else
34
+ val = nil
35
+ end
36
+ @data << ChartCellsRange.parse(val.xpath('c:numRef').first).dup unless val.nil?
37
+ when 'dLbls'
38
+ @display_labels = DisplayLabelsProperties.parse(chart_props_node_child)
39
+ end
40
+ end
41
+ end
42
+
43
+ def self.parse
44
+ chart = Chart.new
45
+ chart_xml = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
46
+ chart_xml.xpath('c:chartSpace/*', 'xmlns:c' => 'http://schemas.openxmlformats.org/drawingml/2006/chart').each do |chart_space_node_child|
47
+ case chart_space_node_child.name
48
+ when 'AlternateContent'
49
+ chart.alternate_content = AlternateContent.parse(chart_space_node_child)
50
+ when 'spPr'
51
+ chart.shape_properties = DocxShapeProperties.parse chart_space_node_child
52
+ when 'chart'
53
+ chart_space_node_child.xpath('*').each do |chart_node_child|
54
+ case chart_node_child.name
55
+ when 'plotArea'
56
+ chart_node_child.xpath('*').each do |plot_area_node_child|
57
+ next unless chart.type.empty?
58
+ case plot_area_node_child.name
59
+ when 'barChart'
60
+ chart.type = :bar
61
+ bar_dir_node = plot_area_node_child.xpath('c:barDir')
62
+ unless bar_dir_node.first.nil?
63
+ chart.type = :column if bar_dir_node.first.attribute('val').value == 'col'
64
+ end
65
+ chart.parse_properties(plot_area_node_child)
66
+ when 'lineChart'
67
+ chart.type = :line
68
+ chart.parse_properties(plot_area_node_child)
69
+ when 'areaChart'
70
+ chart.type = :area
71
+ chart.parse_properties(plot_area_node_child)
72
+ when 'bubbleChart'
73
+ chart.type = :bubble
74
+ chart.parse_properties(plot_area_node_child)
75
+ when 'doughnutChart'
76
+ chart.type = :doughnut
77
+ chart.parse_properties(plot_area_node_child)
78
+ when 'pieChart'
79
+ chart.type = :pie
80
+ chart.parse_properties(plot_area_node_child)
81
+ when 'scatterChart'
82
+ chart.type = :point
83
+ chart.parse_properties(plot_area_node_child)
84
+ when 'radarChart'
85
+ chart.type = :radar
86
+ chart.parse_properties(plot_area_node_child)
87
+ when 'stockChart'
88
+ chart.type = :stock
89
+ chart.parse_properties(plot_area_node_child)
90
+ when 'surface3DChart'
91
+ chart.type = :surface_3d
92
+ chart.parse_properties(plot_area_node_child)
93
+ when 'line3DChart'
94
+ chart.type = :line_3d
95
+ chart.parse_properties(plot_area_node_child)
96
+ when 'bar3DChart'
97
+ chart.type = :bar_3d
98
+ chart.parse_properties(plot_area_node_child)
99
+ when 'pie3DChart'
100
+ chart.type = :pie_3d
101
+ chart.parse_properties(plot_area_node_child)
102
+ end
103
+ end
104
+ chart_node_child.xpath('*').each do |plot_area_node_child|
105
+ case plot_area_node_child.name
106
+ when 'catAx'
107
+ chart.axises << ChartAxis.parse(plot_area_node_child)
108
+ when 'valAx'
109
+ chart.axises << ChartAxis.parse(plot_area_node_child)
110
+ end
111
+ end
112
+ when 'title'
113
+ chart.title = ChartAxisTitle.parse(chart_node_child)
114
+ when 'legend'
115
+ chart.legend = ChartLegend.parse(chart_node_child)
116
+ end
117
+ end
118
+ end
119
+ end
120
+ chart
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,34 @@
1
+ require_relative 'chart_axis_title'
2
+ # Chart Axis
3
+ module OoxmlParser
4
+ class ChartAxis < OOXMLDocumentObject
5
+ attr_accessor :title, :display, :position, :major_grid_lines, :minor_grid_lines
6
+
7
+ def initialize(title = ChartAxisTitle.new, display = true, major_grid_lines = false, minor_grid_lines = false)
8
+ @title = title
9
+ @display = display
10
+ @minor_grid_lines = minor_grid_lines
11
+ @major_grid_lines = major_grid_lines
12
+ end
13
+
14
+ def self.parse(axis_node)
15
+ axis = ChartAxis.new
16
+ axis_node.xpath('*').each do |axis_node_child|
17
+ case axis_node_child.name
18
+ when 'delete'
19
+ axis.display = false if axis_node_child.attribute('val').value == '1'
20
+ when 'title'
21
+ axis.title = ChartAxisTitle.parse(axis_node_child)
22
+ when 'majorGridlines'
23
+ axis.major_grid_lines = true
24
+ when 'minorGridlines'
25
+ axis.minor_grid_lines = true
26
+ when 'axPos'
27
+ axis.position = Alignment.parse(axis_node_child.attribute('val'))
28
+ end
29
+ end
30
+ axis.display = false if axis.title.nil?
31
+ axis
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # Chart Axis Title
2
+ module OoxmlParser
3
+ class ChartAxisTitle < OOXMLDocumentObject
4
+ attr_accessor :layout, :overlay, :elements
5
+
6
+ def initialize(layout = nil, overlay = nil, elements = [])
7
+ @layout = layout
8
+ @overlay = overlay
9
+ @elements = elements
10
+ end
11
+
12
+ def nil?
13
+ @layout.nil? && @overlay.nil? && @elements.empty?
14
+ end
15
+
16
+ def self.parse(axis_title_node)
17
+ title = ChartAxisTitle.new
18
+ axis_title_node.xpath('*').each do |title_node_child|
19
+ case title_node_child.name
20
+ when 'tx'
21
+ title_node_child.xpath('c:rich/*').each do |rich_node_child|
22
+ case rich_node_child.name
23
+ when 'p'
24
+ Presentation.current_font_style = FontStyle.new(true) # Default font style for chart title always bold
25
+ title.elements << Paragraph.parse(rich_node_child)
26
+ Presentation.current_font_style = FontStyle.new
27
+ end
28
+ end
29
+ when 'layout'
30
+ title.layout = OOXMLDocumentObject.option_enabled?(title_node_child)
31
+ when 'overlay'
32
+ title.overlay = OOXMLDocumentObject.option_enabled?(title_node_child)
33
+ end
34
+ end
35
+ title
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ # Cell Range of Chart
2
+ module OoxmlParser
3
+ class ChartCellsRange
4
+ attr_accessor :list, :points
5
+
6
+ def initialize(list = '', points = [])
7
+ @list = list
8
+ @points = points
9
+ end
10
+
11
+ def self.parse(num_ref_node)
12
+ chart_range = ChartCellsRange.new
13
+ chart_range.list = num_ref_node.xpath('c:f')[0].text.split('!').first
14
+ coordinates = Coordinates.parser_coordinates_range(num_ref_node.xpath('c:f')[0].text) # .split('!')[1].gsub('$', ''))
15
+ num_ref_node.xpath('c:numCache/c:pt').each_with_index do |point_node, index|
16
+ point = ChartPoint.new(coordinates[index])
17
+ point.value = point_node.xpath('c:v').first.text.to_f unless point_node.xpath('c:v').first.nil?
18
+ chart_range.points << point
19
+ end
20
+ chart_range
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # Legend of Chart
2
+ module OoxmlParser
3
+ class ChartLegend
4
+ attr_accessor :position, :overlay
5
+
6
+ def initialize(position = :right, overlay = false)
7
+ @position = position
8
+ @overlay = overlay
9
+ end
10
+
11
+ # Return combined data from @position and @overlay
12
+ # If there is no overlay - return :right f.e.
13
+ # If there is overlay - return :right_overlay
14
+ # @return [Symbol] overlay and position type
15
+ def position_with_overlay
16
+ return "#{@position}_overlay".to_sym if overlay
17
+ @position
18
+ end
19
+
20
+ def self.parse(legend_node)
21
+ legend = ChartLegend.new
22
+ legend_node.xpath('*').each do |legend_node_child|
23
+ case legend_node_child.name
24
+ when 'legendPos'
25
+ legend.position = Alignment.parse(legend_node_child.attribute('val'))
26
+ when 'overlay'
27
+ legend.overlay = true if legend_node_child.attribute('val').value.to_s == '1'
28
+ end
29
+ end
30
+ legend
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ # Single Chart Point
2
+ module OoxmlParser
3
+ class ChartPoint
4
+ attr_accessor :coordinates, :value
5
+
6
+ def initialize(coordinates = nil, value = nil)
7
+ @coordinates = coordinates
8
+ @value = value
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # XLSX 2007 Chart Style
2
+ module OoxmlParser
3
+ class Office2007ChartStyle
4
+ attr_accessor :style_number
5
+
6
+ def self.parse(chart_style_node)
7
+ chart_style = Office2007ChartStyle.new
8
+ chart_style_node.xpath('*').each do |chart_style_node_child|
9
+ case chart_style_node_child.name
10
+ when 'style'
11
+ chart_style.style_number = chart_style_node_child.attribute('val').value.to_i
12
+ end
13
+ end
14
+ chart_style
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # XLSX 2010 Chart Style
2
+ module OoxmlParser
3
+ class Office2010ChartStyle
4
+ attr_accessor :style_number
5
+
6
+ def self.parse(chart_style_node)
7
+ chart_style = Office2010ChartStyle.new
8
+ chart_style_node.xpath('*').each do |chart_style_node_child|
9
+ case chart_style_node_child.name
10
+ when 'style'
11
+ chart_style.style_number = chart_style_node_child.attribute('val').value.to_i
12
+ end
13
+ end
14
+ chart_style
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # Chart Label Properties
2
+ module OoxmlParser
3
+ class DisplayLabelsProperties
4
+ attr_accessor :position, :show_legend_key, :show_values, :show_x_axis_name, :show_y_axis_name
5
+
6
+ def initialize(show_legend_key = false, show_values = false)
7
+ @show_legend_key = show_legend_key
8
+ @show_values = show_values
9
+ end
10
+
11
+ def self.parse(display_labels_node)
12
+ display_labels_properties = DisplayLabelsProperties.new
13
+ display_labels_node.xpath('*').each do |display_label_property_node|
14
+ case display_label_property_node.name
15
+ when 'dLblPos'
16
+ display_labels_properties.position = Alignment.parse(display_label_property_node.attribute('val'))
17
+ when 'showLegendKey'
18
+ display_labels_properties.show_legend_key = true if display_label_property_node.attribute('val').value == '1'
19
+ when 'showVal'
20
+ display_labels_properties.show_values = true if display_label_property_node.attribute('val').value == '1'
21
+ end
22
+ end
23
+ display_labels_properties
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'drawing_properties/docx_drawing_properties'
2
+ require_relative 'graphic/docx_graphic'
3
+ # Docx Drawing Data
4
+ module OoxmlParser
5
+ class DocxDrawing
6
+ attr_accessor :type, :properties, :graphic
7
+
8
+ alias picture graphic
9
+
10
+ def initialize(properties = DocxDrawingProperties.new)
11
+ @properties = properties
12
+ end
13
+
14
+ def self.parse(drawing_node)
15
+ drawing = DocxDrawing.new
16
+ drawing_node.xpath('*').each do |drawing_node_child|
17
+ case drawing_node_child.name
18
+ when 'anchor'
19
+ drawing.type = :flow
20
+ when 'inline'
21
+ drawing.type = :inline
22
+ end
23
+ drawing.properties.distance_from_text = DocxDrawingDistanceFromText.parse(drawing_node_child)
24
+ drawing.properties.wrap = DocxWrapDrawing.parse(drawing_node_child)
25
+ drawing_node_child.attributes.each do |key, value|
26
+ case key
27
+ when 'relativeHeight'
28
+ drawing.properties.relative_height = value.value.to_i
29
+ end
30
+ end
31
+ drawing_node_child.xpath('*').each do |content_node_child|
32
+ case content_node_child.name
33
+ when 'simplePos'
34
+ drawing.properties.simple_position = OOXMLCoordinates.parse(content_node_child)
35
+ when 'extent'
36
+ drawing.properties.object_size = OOXMLCoordinates.parse(content_node_child, x_attr: 'cx', y_attr: 'cy')
37
+ when 'graphic'
38
+ drawing.graphic = DocxGraphic.parse(content_node_child)
39
+ when 'positionV'
40
+ drawing.properties.vertical_position = DocxDrawingPosition.parse(content_node_child)
41
+ when 'positionH'
42
+ drawing.properties.horizontal_position = DocxDrawingPosition.parse(content_node_child)
43
+ end
44
+ end
45
+ end
46
+ drawing
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ # Docx Drawing Distance From Text
2
+ module OoxmlParser
3
+ class DocxDrawingDistanceFromText
4
+ attr_accessor :top, :bottom, :left, :right
5
+
6
+ def self.parse(distance_node)
7
+ distance_from_text = DocxDrawingDistanceFromText.new
8
+ distance_node.attributes.each do |key, value|
9
+ case key
10
+ when 'distT'
11
+ distance_from_text.top = (value.value.to_f / 360_000.0).round(2)
12
+ when 'distB'
13
+ distance_from_text.bottom = (value.value.to_f / 360_000.0).round(2)
14
+ when 'distL'
15
+ distance_from_text.left = (value.value.to_f / 360_000.0).round(2)
16
+ when 'distR'
17
+ distance_from_text.right = (value.value.to_f / 360_000.0).round(2)
18
+ end
19
+ end
20
+ distance_from_text
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ # Docx Drawing Position
2
+ module OoxmlParser
3
+ class DocxDrawingPosition
4
+ attr_accessor :relative_from, :offset, :align
5
+
6
+ def self.parse(drawing_position_node)
7
+ position = DocxDrawingPosition.new
8
+ position.relative_from = case drawing_position_node.attribute('relativeFrom').value
9
+ when 'leftMargin'
10
+ :left_margin
11
+ when 'rightMargin'
12
+ :right_margin
13
+ when 'bottomMargin'
14
+ :bottom_margin
15
+ when 'topMargin'
16
+ :top_margin
17
+ when 'insideMargin'
18
+ :inside_margin
19
+ when 'outsideMargin'
20
+ :outside_margin
21
+ else
22
+ drawing_position_node.attribute('relativeFrom').value.to_sym
23
+ end
24
+ drawing_position_node.xpath('*').each do |position_node_child|
25
+ case position_node_child.name
26
+ when 'posOffset', 'pctPosHOffset', 'pctPosVOffset'
27
+ position.offset = (position_node_child.text.to_f / 360_000.0).round(3)
28
+ when 'align'
29
+ position.align = position_node_child.text.to_sym
30
+ end
31
+ end
32
+ position
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'ooxml_coordinates'
2
+ require_relative 'docx_drawing_distance_from_text'
3
+ require_relative 'docx_drawing_position'
4
+ require_relative 'docx_wrap_drawing'
5
+ # Docx Drawing Properties
6
+ module OoxmlParser
7
+ class DocxDrawingProperties
8
+ attr_accessor :distance_from_text, :simple_position, :wrap, :object_size, :vertical_position, :horizontal_position,
9
+ :relative_height
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ # Docx Wrap Drawing
2
+ module OoxmlParser
3
+ class DocxWrapDrawing
4
+ attr_accessor :wrap_text, :distance_from_text
5
+
6
+ def initialize(wrap_text = :none)
7
+ @wrap_text = wrap_text
8
+ end
9
+
10
+ def self.parse(drawing_node)
11
+ wrap = DocxWrapDrawing.new
12
+ unless drawing_node.attribute('behindDoc').nil?
13
+ wrap.wrap_text = :behind if drawing_node.attribute('behindDoc').value == '1'
14
+ wrap.wrap_text = :infront if drawing_node.attribute('behindDoc').value == '0'
15
+ end
16
+ drawing_node.xpath('*').each do |wrap_node|
17
+ case wrap_node.name
18
+ when 'wrapSquare'
19
+ wrap.wrap_text = :square
20
+ wrap.distance_from_text = DocxDrawingDistanceFromText.parse(wrap_node)
21
+ break
22
+ when 'wrapTight'
23
+ wrap.wrap_text = :tight
24
+ wrap.distance_from_text = DocxDrawingDistanceFromText.parse(wrap_node)
25
+ break
26
+ when 'wrapThrough'
27
+ wrap.wrap_text = :through
28
+ wrap.distance_from_text = DocxDrawingDistanceFromText.parse(wrap_node)
29
+ break
30
+ when 'wrapTopAndBottom'
31
+ wrap.wrap_text = :topbottom
32
+ wrap.distance_from_text = DocxDrawingDistanceFromText.parse(wrap_node)
33
+ break
34
+ end
35
+ end
36
+ wrap
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ # Docx Coordinates
2
+ module OoxmlParser
3
+ class OOXMLCoordinates
4
+ attr_accessor :x, :y
5
+
6
+ def initialize(x, y)
7
+ @x = x
8
+ @y = y
9
+ end
10
+
11
+ def to_s
12
+ '(' + @x.to_s + '; ' + @y.to_s + ')'
13
+ end
14
+
15
+ # Compare two OOXMLCoordinates objects
16
+ # @param other [OOXMLCoordinates] other object
17
+ # @return [True, False] result of comparasion
18
+ def ==(other)
19
+ x == other.x && y == other.y
20
+ end
21
+
22
+ # Parse OOXMLCoordinates object
23
+ # @param position_node [Nokogiri::XML:Element] node to parse
24
+ # @param x_attr [String] name of x attribute
25
+ # @param y_attr [String] name of y attribute
26
+ # @param delimiter [Float] delimiter to devise values
27
+ # @return [OOXMLCoordinates] result of parsing
28
+ def self.parse(position_node, x_attr: 'x', y_attr: 'y', delimiter: OoxmlParser.configuration.units_delimiter)
29
+ OOXMLCoordinates.new((position_node.attribute(x_attr).value.to_f / delimiter).round(3), (position_node.attribute(y_attr).value.to_f / delimiter).round(3))
30
+ end
31
+ end
32
+ end