ooxml_parser 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -5
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/chart_style.rb +19 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text/math_paragraph.rb +18 -0
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text.rb +19 -0
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice.rb +20 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +20 -14
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/order.rb +20 -0
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_index.rb +20 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point/text_value.rb +15 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point.rb +31 -0
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache/point_count.rb +20 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/string_cache.rb +31 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference.rb +25 -0
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +23 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +39 -0
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/view_3d.rb +32 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +81 -74
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +20 -13
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +15 -14
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +15 -12
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +15 -10
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +22 -11
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing/doc_properties.rb +24 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +34 -20
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +9 -10
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +18 -25
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +4 -1
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +23 -20
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +15 -5
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +104 -0
  32. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative/picture_dimension.rb +17 -0
  33. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative_horizontal.rb +31 -0
  34. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/size_relative_vertical.rb +30 -0
  35. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +17 -16
  36. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +34 -0
  37. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +12 -15
  38. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +15 -10
  39. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb +38 -0
  40. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/non_visual_properties/shape_placeholder.rb +21 -0
  41. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/non_visual_properties.rb +29 -0
  42. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties.rb +22 -0
  43. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +29 -0
  44. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +26 -0
  45. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +27 -10
  46. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +7 -4
  47. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +20 -11
  48. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +18 -15
  49. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +11 -9
  50. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb +39 -0
  51. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb +15 -27
  52. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +13 -9
  53. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +20 -23
  54. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +27 -22
  55. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip/alpha_mod_fix.rb +19 -0
  56. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill/blip.rb +21 -0
  57. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill.rb +24 -0
  58. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry/shape_adjust_value_list/shape_guide.rb +24 -0
  59. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry/shape_adjust_value_list.rb +31 -0
  60. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry.rb +24 -0
  61. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +3 -3
  62. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +22 -13
  63. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +20 -12
  64. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +9 -8
  65. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +15 -13
  66. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +14 -12
  67. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +15 -12
  68. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +18 -14
  69. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +12 -11
  70. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +20 -24
  71. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +25 -0
  72. data/lib/ooxml_parser/common_parser/common_data/color.rb +48 -182
  73. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +15 -10
  74. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +1 -63
  75. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +17 -20
  76. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop/preset_color.rb +20 -0
  77. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +20 -7
  78. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +12 -11
  79. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +17 -17
  80. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +15 -9
  81. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +19 -16
  82. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +10 -6
  83. data/lib/ooxml_parser/common_parser/common_data/font_style.rb +1 -61
  84. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +33 -26
  85. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb +97 -0
  86. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +23 -37
  87. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +71 -23
  88. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/language.rb +20 -0
  89. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +11 -7
  90. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/position.rb +20 -0
  91. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_spacing.rb +20 -0
  92. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/run_style.rb +25 -0
  93. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +38 -0
  94. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/size.rb +20 -0
  95. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +92 -40
  96. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +12 -8
  97. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +37 -0
  98. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +53 -0
  99. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb +36 -0
  100. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +6 -6
  101. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tab_list/presentation_tab.rb +26 -0
  102. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tab_list.rb +36 -0
  103. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/paragraph_tab.rb +26 -0
  104. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +36 -0
  105. data/lib/ooxml_parser/common_parser/common_data/paragraph/text_field.rb +11 -8
  106. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +20 -12
  107. data/lib/ooxml_parser/common_parser/common_data/relationships/relationship.rb +13 -7
  108. data/lib/ooxml_parser/common_parser/common_data/relationships.rb +36 -4
  109. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +12 -8
  110. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +18 -19
  111. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +9 -8
  112. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_layout.rb +23 -0
  113. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +17 -14
  114. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +16 -23
  115. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +21 -40
  116. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_column_band_size.rb +23 -0
  117. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +42 -0
  118. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +50 -0
  119. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_row_band_size.rb +23 -0
  120. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +28 -23
  121. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties/vertical_merge.rb +20 -0
  122. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +71 -69
  123. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -10
  124. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +19 -17
  125. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +31 -48
  126. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line/line_join.rb +21 -0
  127. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +25 -19
  128. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties/table_row_height.rb +20 -0
  129. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +20 -10
  130. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +20 -16
  131. data/lib/ooxml_parser/common_parser/common_data/table/table_grid/grid_column.rb +20 -0
  132. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +27 -3
  133. data/lib/ooxml_parser/common_parser/common_data/table/table_properties/table_borders.rb +20 -13
  134. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +54 -37
  135. data/lib/ooxml_parser/common_parser/common_data/table.rb +23 -17
  136. data/lib/ooxml_parser/common_parser/common_data/underline.rb +13 -10
  137. data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +29 -0
  138. data/lib/ooxml_parser/common_parser/parser.rb +32 -4
  139. data/lib/ooxml_parser/configuration.rb +3 -13
  140. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +1 -1
  141. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +16 -16
  142. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +18 -13
  143. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +20 -0
  144. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_structure_helpers.rb +18 -0
  145. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb +37 -0
  146. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +43 -14
  147. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark.rb +21 -0
  148. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +19 -5
  149. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/argument_properties/argument_size.rb +20 -0
  150. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/argument_properties.rb +21 -0
  151. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +24 -4
  152. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +14 -5
  153. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +27 -6
  154. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +15 -5
  155. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +14 -5
  156. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +23 -7
  157. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +16 -6
  158. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +20 -6
  159. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +25 -0
  160. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run.rb +25 -0
  161. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +4 -3
  162. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +36 -3
  163. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties/nary_grow.rb +20 -0
  164. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties/nary_limit_location.rb +20 -0
  165. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary/nary_properties.rb +26 -0
  166. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/nary.rb +31 -0
  167. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +27 -0
  168. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +19 -5
  169. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +52 -183
  170. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +89 -0
  171. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/object/ole_object.rb +23 -0
  172. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/object.rb +21 -0
  173. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +24 -17
  174. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +7 -6
  175. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +15 -10
  176. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +43 -245
  177. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +19 -20
  178. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +24 -65
  179. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb +41 -0
  180. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +31 -0
  181. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +146 -172
  182. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +45 -26
  183. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/multilevel_type.rb +20 -0
  184. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/level_justification.rb +20 -0
  185. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/level_text.rb +20 -0
  186. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/numbering_format.rb +20 -0
  187. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/start.rb +20 -0
  188. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +31 -0
  189. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +65 -0
  190. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +42 -0
  191. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/numbering_definition/abstract_numbering_id.rb +20 -0
  192. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/numbering_definition.rb +31 -0
  193. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +45 -0
  194. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +15 -4
  195. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +24 -13
  196. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +6 -12
  197. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/footnote_properties.rb +32 -0
  198. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +8 -9
  199. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +31 -24
  200. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +61 -64
  201. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +56 -0
  202. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults/paragraph_properties_default.rb +20 -0
  203. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults/run_properties_default.rb +20 -0
  204. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles/document_defaults.rb +26 -0
  205. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +19 -0
  206. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +49 -54
  207. data/lib/ooxml_parser/docx_parser/docx_parser.rb +2 -1
  208. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +1 -1
  209. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_helpers.rb +13 -0
  210. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +15 -12
  211. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -1
  212. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background/background_properties/stretch.rb +11 -0
  213. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background/background_properties.rb +21 -0
  214. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -6
  215. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +27 -16
  216. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +13 -9
  217. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +11 -8
  218. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +19 -15
  219. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +17 -12
  220. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +15 -14
  221. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +18 -15
  222. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +9 -11
  223. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +16 -13
  224. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +23 -15
  225. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +21 -19
  226. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +15 -11
  227. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +52 -0
  228. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +13 -7
  229. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action.rb +11 -9
  230. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +13 -15
  231. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -14
  232. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +30 -67
  233. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +11 -8
  234. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +6 -3
  235. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +1 -1
  236. data/lib/ooxml_parser/version.rb +1 -1
  237. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +28 -0
  238. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill/pattern_fill.rb +33 -0
  239. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +25 -0
  240. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +38 -0
  241. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +35 -0
  242. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +38 -0
  243. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats/number_format.rb +24 -0
  244. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +47 -0
  245. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +36 -0
  246. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/workbook_helpers.rb +11 -0
  247. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +11 -10
  248. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +8 -10
  249. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +12 -12
  250. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +12 -10
  251. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +29 -8
  252. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/x14_table.rb +24 -0
  253. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb +21 -0
  254. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +30 -0
  255. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb +37 -0
  256. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +29 -10
  257. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position_parameters.rb +25 -0
  258. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +23 -29
  259. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +15 -12
  260. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +70 -37
  261. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +16 -12
  262. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +31 -9
  263. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +34 -12
  264. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +20 -9
  265. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +1 -1
  266. data/lib/ooxml_parser.rb +0 -1
  267. metadata +122 -58
  268. data/lib/ooxml_parser/common_parser/common_data/alingment.rb +0 -56
  269. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +0 -17
  270. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +0 -17
  271. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +0 -10
  272. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +0 -34
  273. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +0 -30
  274. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +0 -6
  275. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +0 -10
  276. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_element.rb +0 -10
  277. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +0 -20
  278. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +0 -5
  279. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +0 -25
  280. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +0 -19
  281. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +0 -20
  282. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +0 -28
  283. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +0 -18
  284. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +0 -15
  285. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +0 -28
  286. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +0 -13
  287. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +0 -26
  288. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +0 -23
  289. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching/fill_rectangle.rb +0 -22
  290. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +0 -12
  291. data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +0 -16
  292. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +0 -16
  293. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +0 -25
  294. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +0 -69
  295. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +0 -18
  296. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +0 -20
  297. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +0 -21
  298. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +0 -19
  299. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +0 -20
  300. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +0 -13
  301. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +0 -10
  302. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +0 -19
  303. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +0 -35
  304. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +0 -56
  305. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +0 -15
  306. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +0 -84
  307. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +0 -16
  308. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +0 -27
  309. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +0 -25
  310. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +0 -22
  311. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +0 -22
  312. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +0 -37
  313. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +0 -25
  314. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +0 -36
  315. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +0 -30
@@ -1,18 +1,21 @@
1
1
  module OoxmlParser
2
- class TextField
2
+ # Class for parsing `fld` tags
3
+ class TextField < OOXMLDocumentObject
3
4
  attr_accessor :id, :type, :text
4
5
 
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|
6
+ # Parse TextField object
7
+ # @param node [Nokogiri::XML:Element] node to parse
8
+ # @return [TextField] result of parsing
9
+ def parse(node)
10
+ @id = node.attribute('id').value
11
+ @type = node.attribute('type').value
12
+ node.xpath('*').each do |text_field_node_child|
10
13
  case text_field_node_child.name
11
14
  when 't'
12
- text_field.text = text_field_node_child.text
15
+ @text = text_field_node_child.text
13
16
  end
14
17
  end
15
- text_field
18
+ self
16
19
  end
17
20
  end
18
21
  end
@@ -2,13 +2,19 @@ require_relative 'paragraph/paragraph_properties'
2
2
  require_relative 'paragraph/paragraph_run'
3
3
  require_relative 'paragraph/text_field'
4
4
  module OoxmlParser
5
- class Paragraph
5
+ # Class for parsing `p` tags
6
+ class Paragraph < OOXMLDocumentObject
6
7
  attr_accessor :properties, :runs, :text_field, :formulas
8
+ # @return [AlternateContent] alternate content data
9
+ attr_accessor :alternate_content
7
10
 
8
- def initialize(runs = [], formulas = [])
11
+ def initialize(runs = [],
12
+ formulas = [],
13
+ parent: nil)
9
14
  @runs = runs
10
15
  @formulas = formulas
11
16
  @runs = []
17
+ @parent = parent
12
18
  end
13
19
 
14
20
  alias characters runs
@@ -16,21 +22,23 @@ module OoxmlParser
16
22
  alias characters= runs=
17
23
  alias character_style_array= runs=
18
24
 
19
- def self.parse(paragraph_node)
20
- paragraph = Paragraph.new
21
- paragraph_node.xpath('*').each do |paragraph_node_child|
22
- case paragraph_node_child.name
25
+ # Parse Paragraph object
26
+ # @param node [Nokogiri::XML:Element] node to parse
27
+ # @return [Paragraph] result of parsing
28
+ def parse(node)
29
+ node.xpath('*').each do |node_child|
30
+ case node_child.name
23
31
  when 'pPr'
24
- paragraph.properties = ParagraphProperties.parse(paragraph_node_child)
32
+ @properties = ParagraphProperties.new(parent: self).parse(node_child)
25
33
  when 'fld'
26
- paragraph.text_field = TextField.parse(paragraph_node_child)
34
+ @text_field = TextField.new(parent: self).parse(node_child)
27
35
  when 'r'
28
- paragraph.characters << ParagraphRun.parse(paragraph_node_child)
29
- when 'm'
30
- # TODO: add parsing formulas in paragraph
36
+ @runs << ParagraphRun.new(parent: self).parse(node_child)
37
+ when 'AlternateContent'
38
+ @alternate_content = AlternateContent.new(parent: self).parse(node_child)
31
39
  end
32
40
  end
33
- paragraph
41
+ self
34
42
  end
35
43
  end
36
44
  end
@@ -1,6 +1,6 @@
1
1
  module OoxmlParser
2
2
  # Class for single relationship
3
- class Relationship
3
+ class Relationship < OOXMLDocumentObject
4
4
  # @return [String] id of relation
5
5
  attr_accessor :id
6
6
  # @return [String] type of relation
@@ -11,12 +11,18 @@ module OoxmlParser
11
11
  # Parse Relationship
12
12
  # @param [Nokogiri::XML:Node] node with Relationship
13
13
  # @return [Relationship] result of parsing
14
- def self.parse(node)
15
- rel = Relationship.new
16
- rel.id = node.attribute('Id').value
17
- rel.type = node.attribute('Type').value
18
- rel.target = node.attribute('Target').value
19
- rel
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'Id'
18
+ @id = value.value
19
+ when 'Type'
20
+ @type = value.value
21
+ when 'Target'
22
+ @target = value.value
23
+ end
24
+ end
25
+ self
20
26
  end
21
27
  end
22
28
  end
@@ -17,15 +17,47 @@ module OoxmlParser
17
17
  # Parse Relationships
18
18
  # @param [Nokogiri::XML:Node] node with Relationships
19
19
  # @return [Relationships] result of parsing
20
- def self.parse(node)
21
- rels = Relationships.new
20
+ def parse(node)
22
21
  node.xpath('*').each do |node_children|
23
22
  case node_children.name
24
23
  when 'Relationship'
25
- rels.relationship << Relationship.parse(node_children)
24
+ @relationship << Relationship.new(parent: self).parse(node_children)
25
+ end
26
+ end
27
+ self
28
+ end
29
+
30
+ # Get target name by id
31
+ # @param id [String] id of target
32
+ # @return [String] target name
33
+ def target_by_id(id)
34
+ @relationship.each do |cur_rels|
35
+ return cur_rels.target if cur_rels.id == id
36
+ end
37
+ nil
38
+ end
39
+
40
+ # Get target name by type
41
+ # @param type [String] type of target
42
+ # @return [String] target name
43
+ def target_by_type(type)
44
+ @relationship.each do |cur_rels|
45
+ return cur_rels.target if cur_rels.type.include?(type)
46
+ end
47
+ nil
48
+ end
49
+
50
+ # Parse .rels file
51
+ # @param file_path [String] path to file
52
+ # @return [Relationships]
53
+ def self.parse_rels(file_path)
54
+ node = Nokogiri::XML(File.open(file_path))
55
+ node.xpath('*').each do |node_child|
56
+ case node_child.name
57
+ when 'Relationships'
58
+ return Relationships.new.parse(node_child)
26
59
  end
27
60
  end
28
- rels
29
61
  end
30
62
  end
31
63
  end
@@ -1,10 +1,15 @@
1
1
  module OoxmlParser
2
2
  class ParagraphMargins < TableMargins
3
- def initialize(top = 0.0, bottom = 0.0, left = 0.0, right = 0.0)
3
+ def initialize(top = OoxmlSize.new(0),
4
+ bottom = OoxmlSize.new(0),
5
+ left = OoxmlSize.new(0),
6
+ right = OoxmlSize.new(0),
7
+ parent: nil)
4
8
  @top = top
5
9
  @bottom = bottom
6
10
  @left = left
7
11
  @right = right
12
+ @parent = parent
8
13
  end
9
14
 
10
15
  def round(count_of_digits = 1)
@@ -15,21 +20,20 @@ module OoxmlParser
15
20
  ParagraphMargins.new(top, bottom, left, right)
16
21
  end
17
22
 
18
- def self.parse(text_body_props_node)
19
- margins = ParagraphMargins.new(0.127, 0.127, 0.254, 0.254)
23
+ def parse(text_body_props_node)
20
24
  text_body_props_node.attributes.each do |key, value|
21
25
  case key
22
26
  when 'bIns', 'marB'
23
- margins.bottom = (value.value.to_f / 360_000.0).round(3)
27
+ @bottom = OoxmlSize.new(value.value.to_f, :emu)
24
28
  when 'tIns', 'marT'
25
- margins.top = (value.value.to_f / 360_000.0).round(3)
29
+ @top = OoxmlSize.new(value.value.to_f, :emu)
26
30
  when 'lIns', 'marL'
27
- margins.left = (value.value.to_f / 360_000.0).round(3)
31
+ @left = OoxmlSize.new(value.value.to_f, :emu)
28
32
  when 'rIns', 'marR'
29
- margins.right = (value.value.to_f / 360_000.0).round(3)
33
+ @right = OoxmlSize.new(value.value.to_f, :emu)
30
34
  end
31
35
  end
32
- margins
36
+ self
33
37
  end
34
38
  end
35
39
  end
@@ -1,47 +1,46 @@
1
1
  module OoxmlParser
2
- class TableMargins
2
+ class TableMargins < OOXMLDocumentObject
3
3
  attr_accessor :is_default, :top, :bottom, :left, :right
4
4
 
5
- def initialize(is_default = true, top = nil, bottom = nil, left = nil, right = nil)
5
+ def initialize(is_default = true, top = nil, bottom = nil, left = nil, right = nil, parent: nil)
6
6
  @is_default = is_default
7
7
  @top = top
8
8
  @bottom = bottom
9
9
  @left = left
10
10
  @right = right
11
+ @parent = parent
11
12
  end
12
13
 
14
+ # TODO: Separate @is_default attribute and remove this method
13
15
  def ==(other)
14
- (@top - other.top).round(2) == 0 && (@bottom - other.bottom).round(2) == 0 &&
15
- (@left - other.left).round(2) == 0 && (@right - other.right).round(2) == 0
16
+ instance_variables.each do |current_attribute|
17
+ next if current_attribute == :@parent
18
+ next if current_attribute == :@is_default
19
+ unless instance_variable_get(current_attribute) == other.instance_variable_get(current_attribute)
20
+ return false
21
+ end
22
+ end
23
+ true
16
24
  end
17
25
 
18
26
  def to_s
19
27
  'Default: ' + is_default.to_s + ' top: ' + @top.to_s + ', bottom: ' + @bottom.to_s + ', left: ' + @left.to_s + ', right: ' + @right.to_s
20
28
  end
21
29
 
22
- def round(count_of_digits = 1)
23
- top = @top.round(count_of_digits)
24
- bottom = @bottom.round(count_of_digits)
25
- left = @left.round(count_of_digits)
26
- right = @right.round(count_of_digits)
27
- TableMargins.new(@is_default, top, bottom, left, right)
28
- end
29
-
30
- def self.parse(margin_node)
31
- cell_margins = TableMargins.new
30
+ def parse(margin_node)
32
31
  margin_node.xpath('*').each do |cell_margin_node|
33
32
  case cell_margin_node.name
34
33
  when 'left'
35
- cell_margins.left = (cell_margin_node.attribute('w').value.to_f / 566.9).round(2)
34
+ @left = OoxmlSize.new(cell_margin_node.attribute('w').value.to_f)
36
35
  when 'top'
37
- cell_margins.top = (cell_margin_node.attribute('w').value.to_f / 566.9).round(2)
36
+ @top = OoxmlSize.new(cell_margin_node.attribute('w').value.to_f)
38
37
  when 'right'
39
- cell_margins.right = (cell_margin_node.attribute('w').value.to_f / 566.9).round(2)
38
+ @right = OoxmlSize.new(cell_margin_node.attribute('w').value.to_f)
40
39
  when 'bottom'
41
- cell_margins.bottom = (cell_margin_node.attribute('w').value.to_f / 566.9).round(2)
40
+ @bottom = OoxmlSize.new(cell_margin_node.attribute('w').value.to_f)
42
41
  end
43
42
  end
44
- cell_margins
43
+ self
45
44
  end
46
45
  end
47
46
  end
@@ -1,20 +1,21 @@
1
- require_relative 'whole_table/table_cell_style'
2
1
  # Describe single table element
3
2
  module OoxmlParser
4
- class TableElement
3
+ class TableElement < OOXMLDocumentObject
5
4
  attr_accessor :cell_style
6
5
 
7
6
  alias cell_properties cell_style
8
7
 
9
- def self.parse(whole_table_node)
10
- table_element = TableElement.new
11
- whole_table_node.xpath('*').each do |whole_table_node_child|
12
- case whole_table_node_child.name
8
+ # Parse TableElement object
9
+ # @param node [Nokogiri::XML:Element] node to parse
10
+ # @return [TableElement] result of parsing
11
+ def parse(node)
12
+ node.xpath('*').each do |node_child|
13
+ case node_child.name
13
14
  when 'tcStyle', 'tcPr'
14
- table_element.cell_style = CellProperties.parse(whole_table_node_child)
15
+ @cell_style = CellProperties.new(parent: self).parse(node_child)
15
16
  end
16
17
  end
17
- table_element
18
+ self
18
19
  end
19
20
  end
20
21
  end
@@ -0,0 +1,23 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w:tblLayout` object
3
+ # Whether a table uses a fixed width or autofit method for laying out the table
4
+ # contents is specified with the <w:tblLayout> element within the <w:tblPr> element.
5
+ # If <w:tblLayout> is omitted, autofit is assumed.
6
+ class TableLayout < OOXMLDocumentObject
7
+ # @return [Symbol] Specifies the method of laying out the contents of the table
8
+ attr_accessor :type
9
+
10
+ # Parse TableLayout
11
+ # @param [Nokogiri::XML:Node] node with TableLayout
12
+ # @return [TableLayout] result of parsing
13
+ def parse(node)
14
+ node.attributes.each do |key, value|
15
+ case key
16
+ when 'type'
17
+ @type = value.value.to_sym
18
+ end
19
+ end
20
+ self
21
+ end
22
+ end
23
+ end
@@ -1,10 +1,10 @@
1
- # Describe look of table
2
1
  module OoxmlParser
2
+ # Describe look of table, parsed `w:tblLook`
3
3
  class TableLook < OOXMLDocumentObject
4
4
  attr_accessor :first_row, :first_column, :last_row, :last_column, :banding_row, :banding_column, :no_horizontal_banding,
5
5
  :no_vertical_banding
6
6
 
7
- def initialize
7
+ def initialize(parent: nil)
8
8
  @first_row = false
9
9
  @first_column = false
10
10
  @last_row = false
@@ -13,31 +13,34 @@ module OoxmlParser
13
13
  @banding_column = false
14
14
  @no_horizontal_banding = false
15
15
  @no_horizontal_banding = false
16
+ @parent = parent
16
17
  end
17
18
 
18
- def self.parse(table_look_node)
19
- table_look = TableLook.new
20
- table_look_node.attributes.each do |key, value|
19
+ # Parse TableLook object
20
+ # @param node [Nokogiri::XML:Element] node to parse
21
+ # @return [TableLook] result of parsing
22
+ def parse(node)
23
+ node.attributes.each do |key, value|
21
24
  case key
22
25
  when 'firstRow'
23
- table_look.first_row = OOXMLDocumentObject.option_enabled?(value)
26
+ @first_row = attribute_enabled?(value)
24
27
  when 'lastRow'
25
- table_look.last_row = OOXMLDocumentObject.option_enabled?(value)
28
+ @last_row = attribute_enabled?(value)
26
29
  when 'firstCol', 'firstColumn'
27
- table_look.first_column = OOXMLDocumentObject.option_enabled?(value)
30
+ @first_column = attribute_enabled?(value)
28
31
  when 'lastCol', 'lastColumn'
29
- table_look.last_column = OOXMLDocumentObject.option_enabled?(value)
32
+ @last_column = attribute_enabled?(value)
30
33
  when 'noHBand'
31
- table_look.no_horizontal_banding = OOXMLDocumentObject.option_enabled?(value)
34
+ @no_horizontal_banding = attribute_enabled?(value)
32
35
  when 'noVBand'
33
- table_look.no_vertical_banding = OOXMLDocumentObject.option_enabled?(value)
36
+ @no_vertical_banding = attribute_enabled?(value)
34
37
  when 'bandRow'
35
- table_look.banding_row = OOXMLDocumentObject.option_enabled?(value)
38
+ @banding_row = attribute_enabled?(value)
36
39
  when 'bandCol'
37
- table_look.banding_column = OOXMLDocumentObject.option_enabled?(value)
40
+ @banding_column = attribute_enabled?(value)
38
41
  end
39
42
  end
40
- table_look
43
+ self
41
44
  end
42
45
  end
43
46
  end
@@ -1,49 +1,42 @@
1
1
  # Table Position Data
2
2
  module OoxmlParser
3
- class TablePosition
3
+ class TablePosition < OOXMLDocumentObject
4
4
  attr_accessor :left, :right, :top, :bottom, :position_x, :position_y, :horizontal_anchor, :vertical_anchor, :vertical_align_from_anchor,
5
5
  :horizontal_align_from_anchor
6
6
 
7
- def initialize
8
- @left = nil
9
- @right = nil
10
- @top = nil
11
- @bottom = nil
12
- @position_x = nil
13
- @position_y = nil
14
- end
15
-
16
7
  def to_s
17
8
  'Table position left: ' + @left.to_s + ', right: ' + @right.to_s + ', top: ' + @top.to_s + ', bottom: ' + @bottom.to_s + 'position x: ' + position_x.to_s + 'position y: ' + position_x.to_s
18
9
  end
19
10
 
20
- def self.parse(node)
21
- table_p_properties = TablePosition.new
11
+ # Parse TablePosition object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [TablePosition] result of parsing
14
+ def parse(node)
22
15
  node.attributes.each do |key, value|
23
16
  case key
24
17
  when 'leftFromText'
25
- table_p_properties.left = value.value.to_f / 567.5
18
+ @left = OoxmlSize.new(value.value.to_f)
26
19
  when 'rightFromText'
27
- table_p_properties.right = value.value.to_f / 567.5
20
+ @right = OoxmlSize.new(value.value.to_f)
28
21
  when 'topFromText'
29
- table_p_properties.top = value.value.to_f / 567.5
22
+ @top = OoxmlSize.new(value.value.to_f)
30
23
  when 'bottomFromText'
31
- table_p_properties.bottom = value.value.to_f / 567.5
24
+ @bottom = OoxmlSize.new(value.value.to_f)
32
25
  when 'tblpX'
33
- table_p_properties.position_x = (value.value.to_f / 566.9).round(3)
26
+ @position_x = OoxmlSize.new(value.value.to_f)
34
27
  when 'tblpY'
35
- table_p_properties.position_y = (value.value.to_f / 566.9).round(3)
28
+ @position_y = OoxmlSize.new(value.value.to_f)
36
29
  when 'vertAnchor'
37
- table_p_properties.vertical_anchor = value.value.to_sym
30
+ @vertical_anchor = value.value.to_sym
38
31
  when 'horzAnchor'
39
- table_p_properties.horizontal_anchor = value.value.to_sym
32
+ @horizontal_anchor = value.value.to_sym
40
33
  when 'tblpXSpec'
41
- table_p_properties.horizontal_align_from_anchor = value.value.to_sym
34
+ @horizontal_align_from_anchor = value.value.to_sym
42
35
  when 'tblpYSpec'
43
- table_p_properties.vertical_align_from_anchor = value.value.to_sym
36
+ @vertical_align_from_anchor = value.value.to_sym
44
37
  end
45
38
  end
46
- table_p_properties
39
+ self
47
40
  end
48
41
  end
49
42
  end
@@ -1,4 +1,3 @@
1
- require_relative 'table_style_elements'
2
1
  require_relative 'table_element'
3
2
  # Style of Table
4
3
  module OoxmlParser
@@ -7,71 +6,53 @@ module OoxmlParser
7
6
  :last_column, :first_column, :last_row, :first_row, :southeast_cell, :southwest_cell, :northeast_cell,
8
7
  :northwest_cell
9
8
 
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?
9
+ # Parse TableStyle object
10
+ # @param style_id [String] id to parse
11
+ # @return [TableStyle] result of parsing
12
+ def parse(style_id: nil)
13
+ unless style_id.nil?
29
14
  nodes = get_style_node(style_id)
30
15
  return nil if nodes.nil?
31
16
  xpath = '*'
32
17
  attributes = 'style_node_child.name'
33
- elsif !table_style_node.nil?
34
- nodes = table_style_node
35
- xpath = 'w:tblStylePr'
36
- attributes = "style_node_child.attribute('type').value"
37
18
  end
38
19
  begin
39
20
  nodes.xpath(xpath).each do |style_node_child|
40
21
  case instance_eval(attributes)
41
22
  when 'wholeTbl'
42
- table_style.whole_table = TableElement.parse(style_node_child)
23
+ @whole_table = TableElement.new(parent: self).parse(style_node_child)
43
24
  when 'band1H'
44
- table_style.banding_1_horizontal = TableElement.parse(style_node_child)
25
+ @banding_1_horizontal = TableElement.new(parent: self).parse(style_node_child)
45
26
  when 'band2H', 'band2Horz'
46
- table_style.banding_2_horizontal = TableElement.parse(style_node_child)
27
+ @banding_2_horizontal = TableElement.new(parent: self).parse(style_node_child)
47
28
  when 'band1V'
48
- table_style.banding_1_vertical = TableElement.parse(style_node_child)
29
+ @banding_1_vertical = TableElement.new(parent: self).parse(style_node_child)
49
30
  when 'band2V'
50
- table_style.banding_2_vertical = TableElement.parse(style_node_child)
31
+ @banding_2_vertical = TableElement.new(parent: self).parse(style_node_child)
51
32
  when 'lastCol'
52
- table_style.last_column = TableElement.parse(style_node_child)
33
+ @last_column = TableElement.new(parent: self).parse(style_node_child)
53
34
  when 'firstCol'
54
- table_style.first_column = TableElement.parse(style_node_child)
35
+ @first_column = TableElement.new(parent: self).parse(style_node_child)
55
36
  when 'lastRow'
56
- table_style.last_row = TableElement.parse(style_node_child)
37
+ @last_row = TableElement.new(parent: self).parse(style_node_child)
57
38
  when 'firstRow'
58
- table_style.first_row = TableElement.parse(style_node_child)
39
+ @first_row = TableElement.new(parent: self).parse(style_node_child)
59
40
  when 'seCell'
60
- table_style.southeast_cell = TableElement.parse(style_node_child)
41
+ @southeast_cell = TableElement.new(parent: self).parse(style_node_child)
61
42
  when 'swCell'
62
- table_style.southwest_cell = TableElement.parse(style_node_child)
43
+ @southwest_cell = TableElement.new(parent: self).parse(style_node_child)
63
44
  when 'neCell'
64
- table_style.northeast_cell = TableElement.parse(style_node_child)
45
+ @northeast_cell = TableElement.new(parent: self).parse(style_node_child)
65
46
  when 'nwCell'
66
- table_style.northwest_cell = TableElement.parse(style_node_child)
47
+ @northwest_cell = TableElement.new(parent: self).parse(style_node_child)
67
48
  end
68
49
  end
69
50
  end
70
- table_style.id = style_id unless style_id.nil?
71
- table_style
51
+ @id = style_id unless style_id.nil?
52
+ self
72
53
  end
73
54
 
74
- def self.get_style_node(style_id)
55
+ def get_style_node(style_id)
75
56
  begin
76
57
  doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'ppt/tableStyles.xml'))
77
58
  rescue StandardError
@@ -0,0 +1,23 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w:tblStyleColBandSize` object
3
+ # When a style specifies the format for a band of columns in a
4
+ # table (a set of contiguous columns),
5
+ # this specifies the number of columns in a band.
6
+ class TableStyleColumnBandSize < OOXMLDocumentObject
7
+ # @return [Integer] value of table style column band size
8
+ attr_accessor :value
9
+
10
+ # Parse TableStyleColumnBandSize
11
+ # @param [Nokogiri::XML:Node] node with TableStyleColumnBandSize
12
+ # @return [TableStyleColumnBandSize] result of parsing
13
+ def parse(node)
14
+ node.attributes.each do |key, value|
15
+ case key
16
+ when 'val'
17
+ @value = value.value.to_i
18
+ end
19
+ end
20
+ self
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ module OoxmlParser
2
+ # Helper method for working with TableStyleProperties
3
+ module TableStylePropertiesHelper
4
+ TABLE_STYLES_NAMES_HASH = { first_column: :firstCol,
5
+ last_column: :lastCol,
6
+ whole_table: :wholeTbl,
7
+ banding_1_horizontal: :band1Horz,
8
+ banding_2_horizontal: :band2Horz,
9
+ banding_1_vertical: :band1Vert,
10
+ banding_2_vertical: :band2Vert,
11
+ southeast_cell: :seCell,
12
+ southwest_cell: :swCell,
13
+ northeast_cell: :neCell,
14
+ northwest_cell: :nwCell,
15
+ first_row: :firstRow,
16
+ last_row: :lastRow }.freeze
17
+
18
+ TABLE_STYLES_NAMES_HASH.keys.each do |table_style_name|
19
+ define_method(table_style_name) do
20
+ @table_style_properties_list.each do |table_style|
21
+ return table_style if table_style.type == TABLE_STYLES_NAMES_HASH[table_style_name]
22
+ end
23
+ nil
24
+ end
25
+ end
26
+
27
+ # Fill all empty tables styles with default value
28
+ # To make last changes in parsing table styles compatible
29
+ # with `ooxml_parser` 0.1.2 and earlier
30
+ # @return [Nothing]
31
+ def fill_empty_table_styles
32
+ TABLE_STYLES_NAMES_HASH.values.each do |current_table_style|
33
+ style_exist = false
34
+ @table_style_properties_list.each do |existing_style|
35
+ style_exist = true if existing_style.type == current_table_style
36
+ end
37
+ next if style_exist
38
+ @table_style_properties_list << TableStyleProperties.new(type: current_table_style)
39
+ end
40
+ end
41
+ end
42
+ end