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
@@ -0,0 +1,56 @@
1
+ module OoxmlParser
2
+ class PageSize < OOXMLDocumentObject
3
+ attr_accessor :height, :width, :orientation
4
+
5
+ def initialize(height = nil, width = nil, orientation = :portrait)
6
+ @height = height
7
+ @width = width
8
+ @orientation = orientation
9
+ end
10
+
11
+ def to_s
12
+ 'Height: ' + @height.to_s + ' Width: ' + @width.to_s + ' Orientation: ' + @orientation.to_s
13
+ end
14
+
15
+ # @return [True, False] compare dimensions of size, ignoring orientation
16
+ def same_dimensions?(other)
17
+ (@height == other.height) && (@width == other.width) ||
18
+ (@height == other.width) && (@width == other.height)
19
+ end
20
+
21
+ # @return [String] get human format name
22
+ def name
23
+ return 'US Letter' if same_dimensions?(PageSize.new(OoxmlSize.new(27.94, :centimeter), OoxmlSize.new(21.59, :centimeter)))
24
+ return 'US Legal' if same_dimensions?(PageSize.new(OoxmlSize.new(35.56, :centimeter), OoxmlSize.new(21.59, :centimeter)))
25
+ return 'A4' if same_dimensions?(PageSize.new(OoxmlSize.new(29.7, :centimeter), OoxmlSize.new(21.0, :centimeter)))
26
+ return 'A5' if same_dimensions?(PageSize.new(OoxmlSize.new(20.99, :centimeter), OoxmlSize.new(14.81, :centimeter)))
27
+ return 'B5' if same_dimensions?(PageSize.new(OoxmlSize.new(25.01, :centimeter), OoxmlSize.new(17.6, :centimeter)))
28
+ return 'Envelope #10' if same_dimensions?(PageSize.new(OoxmlSize.new(24.13, :centimeter), OoxmlSize.new(10.48, :centimeter)))
29
+ return 'Envelope DL' if same_dimensions?(PageSize.new(OoxmlSize.new(22.01, :centimeter), OoxmlSize.new(11.01, :centimeter)))
30
+ return 'Tabloid' if same_dimensions?(PageSize.new(OoxmlSize.new(43.17, :centimeter), OoxmlSize.new(27.94, :centimeter)))
31
+ return 'A3' if same_dimensions?(PageSize.new(OoxmlSize.new(42.01, :centimeter), OoxmlSize.new(29.7, :centimeter)))
32
+ return 'Tabloid Oversize' if same_dimensions?(PageSize.new(OoxmlSize.new(45.71, :centimeter), OoxmlSize.new(30.48, :centimeter)))
33
+ return 'ROC 16K' if same_dimensions?(PageSize.new(OoxmlSize.new(27.3, :centimeter), OoxmlSize.new(19.68, :centimeter)))
34
+ return 'Envelope Choukei 3' if same_dimensions?(PageSize.new(OoxmlSize.new(23.49, :centimeter), OoxmlSize.new(11.99, :centimeter)))
35
+ return 'Super B/A3' if same_dimensions?(PageSize.new(OoxmlSize.new(48.25, :centimeter), OoxmlSize.new(33.02, :centimeter)))
36
+ "Unknown page size: Height #{@height} Width #{@width}"
37
+ end
38
+
39
+ # Parse PageSize
40
+ # @param [Nokogiri::XML:Element] node with PageSize
41
+ # @return [PageSize] value of Size
42
+ def parse(node)
43
+ node.attributes.each do |key, value|
44
+ case key
45
+ when 'orient'
46
+ @orientation = value.value.to_sym
47
+ when 'h'
48
+ @height = OoxmlSize.new(value.value.to_f)
49
+ when 'w'
50
+ @width = OoxmlSize.new(value.value.to_f)
51
+ end
52
+ end
53
+ self
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w:pPrDefault` tags
3
+ class ParagraphPropertiesDefault < OOXMLDocumentObject
4
+ # @return [ParagraphProperties] properties of run
5
+ attr_accessor :paragraph_properties
6
+
7
+ # Parse ParagraphPropertiesDefault object
8
+ # @param node [Nokogiri::XML:Element] node to parse
9
+ # @return [ParagraphPropertiesDefault] result of parsing
10
+ def parse(node)
11
+ node.xpath('*').each do |node_child|
12
+ case node_child.name
13
+ when 'pPr'
14
+ @paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w:rPrDefault` tags
3
+ class RunPropertiesDefault < OOXMLDocumentObject
4
+ # @return [RunProperties] properties of run
5
+ attr_accessor :run_properties
6
+
7
+ # Parse RunPropertiesDefault object
8
+ # @param node [Nokogiri::XML:Element] node to parse
9
+ # @return [RunPropertiesDefault] result of parsing
10
+ def parse(node)
11
+ node.xpath('*').each do |node_child|
12
+ case node_child.name
13
+ when 'rPr'
14
+ @run_properties = RunProperties.new(parent: self).parse(node_child)
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'document_defaults/paragraph_properties_default'
2
+ require_relative 'document_defaults/run_properties_default'
3
+ module OoxmlParser
4
+ # Class for parsing `w:docDefaults` tags
5
+ class DocumentDefaults < OOXMLDocumentObject
6
+ # @return [RunPropertiesDefault] default properties of run
7
+ attr_accessor :run_properties_default
8
+ # @return [RunPropertiesDefault] default properties of run
9
+ attr_accessor :paragraph_properties_default
10
+
11
+ # Parse Bookmark object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [Bookmark] result of parsing
14
+ def parse(node)
15
+ node.xpath('*').each do |node_child|
16
+ case node_child.name
17
+ when 'rPrDefault'
18
+ @run_properties_default = RunPropertiesDefault.new(parent: self).parse(node_child)
19
+ when 'pPrDefault'
20
+ @paragraph_properties_default = ParagraphPropertiesDefault.new(parent: self).parse(node_child)
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'styles/document_defaults'
2
+ module OoxmlParser
3
+ # Class for parsing `styles.xml` file
4
+ class Styles < OOXMLDocumentObject
5
+ # @return [DocumentDefaults] defaults of document
6
+ attr_accessor :document_defaults
7
+
8
+ def parse
9
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/styles.xml'))
10
+ doc.xpath('w:styles/*').each do |node_child|
11
+ case node_child.name
12
+ when 'docDefaults'
13
+ @document_defaults = DocumentDefaults.new(parent: self).parse(node_child)
14
+ end
15
+ end
16
+ self
17
+ end
18
+ end
19
+ end
@@ -3,23 +3,34 @@ require_relative 'document_structure/comment'
3
3
  require_relative 'document_structure/docx_paragraph'
4
4
  require_relative 'document_structure/document_background'
5
5
  require_relative 'document_structure/document_properties'
6
+ require_relative 'document_structure/document_structure_helpers'
6
7
  require_relative 'document_structure/document_style'
7
8
  require_relative 'document_structure/header_footer'
9
+ require_relative 'document_structure/numbering'
8
10
  require_relative 'document_structure/page_properties/page_properties'
11
+ require_relative 'document_structure/document_settings'
12
+ require_relative 'document_structure/styles'
9
13
  module OoxmlParser
10
14
  class DocumentStructure < CommonDocumentStructure
15
+ include DocumentStyleHelper
16
+ include DocumentStructureHelpers
11
17
  attr_accessor :elements, :page_properties, :notes, :background, :document_properties, :comments
12
18
 
13
19
  # @return [Array, DocumentStyle] array of document styles in current document
14
20
  attr_accessor :document_styles
21
+ # @return [Numbering] store numbering data
22
+ attr_accessor :numbering
23
+ # @return [Styles] styles of document
24
+ attr_accessor :styles
25
+ attr_accessor :theme_colors
26
+ # @return [DocumentSettings] settings
27
+ attr_accessor :settings
15
28
 
16
- def initialize(elements = [], page_properties = nil, notes = [], background = nil, document_properties = DocumentProperties.new, comments = [])
17
- @elements = elements
18
- @page_properties = page_properties
19
- @notes = notes
20
- @background = background
21
- @document_properties = document_properties
22
- @comments = comments
29
+ def initialize
30
+ @elements = []
31
+ @notes = []
32
+ @document_properties = DocumentProperties.new
33
+ @comments = []
23
34
  @document_styles = []
24
35
  end
25
36
 
@@ -87,8 +98,8 @@ module OoxmlParser
87
98
 
88
99
  def recognize_numbering(location: :canvas, type: :simple, paragraph_number: 0)
89
100
  elements = element_by_description(location: location, type: type)
90
- lvl_text = elements[paragraph_number].numbering.numbering_properties.ilvls[0].level_text
91
- num_format = elements[paragraph_number].numbering.numbering_properties.ilvls[0].num_format
101
+ lvl_text = elements[paragraph_number].numbering.abstruct_numbering.level_list[0].text.value
102
+ num_format = elements[paragraph_number].numbering.abstruct_numbering.level_list[0].numbering_format.value
92
103
  [num_format, lvl_text]
93
104
  end
94
105
 
@@ -96,84 +107,73 @@ module OoxmlParser
96
107
  elements = element_by_description(location: location, type: type)
97
108
  set = []
98
109
  levels_count.times do |col|
99
- set[0] = elements[col].numbering.numbering_properties.ilvls[col].num_format
100
- set[1] = elements[col].numbering.numbering_properties.ilvls[col].level_text
110
+ set[0] = elements[col].numbering.abstruct_numbering.level_list[col].numbering_format.value
111
+ set[1] = elements[col].numbering.abstruct_numbering.level_list[col].text.value
101
112
  end
102
113
  set
103
114
  end
104
115
 
105
- # Return document style by its name
106
- # @param name [String] name of style
107
- # @return [DocumentStyle, nil]
108
- def document_style_by_name(name)
109
- @document_styles.each do |style|
110
- return style if style.name == name
111
- end
112
- nil
113
- end
114
-
115
- # Check if style exists in current document
116
- # @param name [String] name of style
117
- # @return [True, False]
118
- def style_exist?(name)
119
- !document_style_by_name(name).nil?
120
- end
121
-
122
116
  def self.parse
117
+ doc_structure = DocumentStructure.new
123
118
  OOXMLDocumentObject.root_subfolder = 'word/'
124
119
  OOXMLDocumentObject.xmls_stack = []
125
- OOXMLDocumentObject.namespace_prefix = 'w'
126
120
  @comments = []
127
- @default_paragraph = DocxParagraph.new
128
- @default_character = DocxParagraphRun.new
129
- @default_table_properties = TableProperties.new
130
- PresentationTheme.parse('word/theme/theme1.xml')
121
+ DocumentStructure.default_paragraph_style = DocxParagraph.new
122
+ DocumentStructure.default_run_style = DocxParagraphRun.new
123
+ doc_structure.theme_colors = PresentationTheme.parse('word/theme/theme1.xml')
131
124
  OOXMLDocumentObject.add_to_xmls_stack('word/styles.xml')
132
125
  doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
126
+ # TODO: Remove this old way parsing in favor of doc_structure.styles.document_defaults
133
127
  doc.search('//w:docDefaults').each do |doc_defaults|
134
128
  doc_defaults.xpath('w:pPrDefault').each do |p_pr_defaults|
135
- @default_paragraph = DocxParagraph.parse(p_pr_defaults, 0)
129
+ DocumentStructure.default_paragraph_style = DocxParagraph.new.parse(p_pr_defaults, 0)
136
130
  end
137
131
  doc_defaults.xpath('w:rPrDefault').each do |r_pr_defaults|
138
132
  r_pr_defaults.xpath('w:rPr').each do |r_pr|
139
- @default_character = DocxParagraphRun.parse(r_pr, DocxParagraphRun.new)
133
+ DocumentStructure.default_run_style = DocxParagraphRun.new.parse_properties(r_pr)
140
134
  end
141
135
  end
142
136
  end
143
137
  parse_default_style
144
- doc_structure = DocumentStructure.new
145
- doc_structure.document_styles = DocumentStyle.parse_list
138
+ doc_structure.numbering = Numbering.new(parent: doc_structure).parse
139
+ doc_structure.document_styles = DocumentStyle.parse_list(doc_structure)
140
+ doc_structure.styles = Styles.new(parent: doc_structure).parse
146
141
  number = 0
147
142
  OOXMLDocumentObject.add_to_xmls_stack('word/document.xml')
148
143
  doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
149
144
  doc.search('//w:document').each do |document|
150
145
  document.xpath('w:background').each do |background|
151
- doc_structure.background = DocumentBackground.parse(background)
146
+ doc_structure.background = DocumentBackground.new(parent: doc_structure).parse(background)
152
147
  end
153
148
  document.xpath('w:body').each do |body|
154
149
  body.xpath('*').each do |element|
155
150
  if element.name == 'p'
156
151
  child = element.child
157
152
  unless child.nil? && doc_structure.elements.last.class == Table
158
- paragraph_style = DocxParagraph.parse(element, number, @default_paragraph, @default_character)
153
+ paragraph_style = DocumentStructure.default_paragraph_style.copy.parse(element, number, DocumentStructure.default_run_style, parent: doc_structure)
159
154
  number += 1
160
155
  doc_structure.elements << paragraph_style.copy
161
156
  end
162
157
  elsif element.name == 'tbl'
163
- table = Table.parse(element, number, TableProperties.new, DocumentStructure.default_table_paragraph_style, DocumentStructure.default_table_run_style)
158
+ table = Table.new(parent: doc_structure).parse(element,
159
+ number,
160
+ TableProperties.new)
164
161
  number += 1
165
162
  doc_structure.elements << table
166
163
  end
167
164
  end
168
165
  body.xpath('w:sectPr').each do |sect_pr|
169
- doc_structure.page_properties = PageProperties.parse(sect_pr, @default_paragraph, @default_character)
166
+ doc_structure.page_properties = PageProperties.new(parent: doc_structure).parse(sect_pr,
167
+ DocumentStructure.default_paragraph_style,
168
+ DocumentStructure.default_run_style)
170
169
  doc_structure.notes = doc_structure.page_properties.notes # keep copy of notes to compatibility with previous docx models
171
170
  end
172
171
  end
173
172
  end
174
173
  OOXMLDocumentObject.xmls_stack.pop
175
- doc_structure.document_properties = DocumentProperties.parse
174
+ doc_structure.document_properties = DocumentProperties.new(parent: doc_structure).parse
176
175
  doc_structure.comments = Comment.parse_list
176
+ doc_structure.settings = DocumentSettings.new(parent: doc_structure).parse
177
177
  doc_structure
178
178
  end
179
179
 
@@ -183,31 +183,25 @@ module OoxmlParser
183
183
  next if style.attribute('default').nil?
184
184
  if (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'paragraph'
185
185
  style.xpath('w:pPr').each do |paragraph_pr_tag|
186
- DocxParagraph.parse_paragraph_style(paragraph_pr_tag, @default_paragraph, @default_character)
186
+ DocumentStructure.default_paragraph_style = DocxParagraph.new.parse_paragraph_style(paragraph_pr_tag, DocumentStructure.default_run_style)
187
187
  end
188
188
  style.xpath('w:rPr').each do |character_pr_tag|
189
- DocxParagraphRun.parse(character_pr_tag, @default_character, @default_character)
189
+ DocumentStructure.default_run_style.parse_properties(character_pr_tag, DocumentStructure.default_run_style)
190
190
  end
191
191
  elsif (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'character'
192
192
  style.xpath('w:rPr').each do |character_pr_tag|
193
- DocxParagraphRun.parse(character_pr_tag, @default_character, @default_character)
193
+ DocumentStructure.default_run_style.parse_properties(character_pr_tag, DocumentStructure.default_run_style)
194
194
  end
195
195
  end
196
196
  end
197
- DocumentStructure.default_table_paragraph_style = @default_paragraph.copy
197
+ DocumentStructure.default_table_paragraph_style = DocumentStructure.default_paragraph_style.copy
198
198
  DocumentStructure.default_table_paragraph_style.spacing = Spacing.new(0, 0, 1, :auto)
199
- DocumentStructure.default_table_run_style = @default_character.copy
199
+ DocumentStructure.default_table_run_style = DocumentStructure.default_run_style.copy
200
200
  doc.search('//w:style').each do |style|
201
201
  next if style.attribute('default').nil?
202
202
  next unless (style.attribute('default').value == '1' || style.attribute('default').value == 'on' || style.attribute('default').value == 'true') && style.attribute('type').value == 'table'
203
- style.xpath('w:tblPr').each do |table_pr_tag|
204
- @default_table_properties = TableProperties.parse(table_pr_tag)
205
- end
206
- style.xpath('w:pPr').each do |table_paragraph_pr_tag|
207
- DocxParagraph.parse_paragraph_style(table_paragraph_pr_tag, DocumentStructure.default_table_paragraph_style, DocumentStructure.default_table_run_style)
208
- end
209
203
  style.xpath('w:rPr').each do |table_character_pr_tag|
210
- DocxParagraphRun.parse(table_character_pr_tag, DocumentStructure.default_table_run_style, @default_character)
204
+ DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag, DocumentStructure.default_run_style)
211
205
  end
212
206
  end
213
207
  end
@@ -216,6 +210,7 @@ module OoxmlParser
216
210
  attr_accessor :default_table_run_style
217
211
  attr_accessor :default_table_paragraph_style
218
212
  attr_accessor :default_paragraph_style
213
+ attr_accessor :default_run_style
219
214
  end
220
215
  end
221
216
  end
@@ -1,10 +1,11 @@
1
1
  require_relative '../common_parser/common_data/ooxml_document_object'
2
+ require_relative '../common_parser/common_data/valued_child'
2
3
  require_relative 'docx_data/document_structure'
3
4
 
4
5
  module OoxmlParser
5
6
  class DocxParser
6
7
  def self.parse_docx(path_to_file)
7
- Parser.parse(path_to_file) do
8
+ Parser.parse_format(path_to_file) do
8
9
  DocumentStructure.parse
9
10
  end
10
11
  end
@@ -12,7 +12,7 @@ module OoxmlParser
12
12
  comment_node.xpath('*').each do |comment_node_child|
13
13
  case comment_node_child.name
14
14
  when 'pos'
15
- comment.position = OOXMLShift.parse(comment_node_child, 'x', 'y', 1)
15
+ comment.position = OOXMLCoordinates.parse(comment_node_child, x_attr: 'x', y_attr: 'y')
16
16
  when 'text'
17
17
  comment.text = comment_node_child.text.to_s
18
18
  end
@@ -0,0 +1,13 @@
1
+ module OoxmlParser
2
+ # method to help to work with Presentation
3
+ module PresentationHelpers
4
+ # @return [True, false] if structure contain any user data
5
+ def with_data?
6
+ return true if @slides.length > 1
7
+ @slides.each do |current_slide|
8
+ return true if current_slide.with_data?
9
+ end
10
+ false
11
+ end
12
+ end
13
+ end
@@ -1,10 +1,11 @@
1
1
  module OoxmlParser
2
- class ThemeColor
2
+ # Class for parsing ThemeColor tags
3
+ class ThemeColor < OOXMLDocumentObject
3
4
  attr_accessor :type, :value, :color
4
5
 
5
- def initialize(type = '', color = nil)
6
- @type = type
7
- @color = color
6
+ def initialize(parent: nil)
7
+ @type = ''
8
+ @parent = parent
8
9
  end
9
10
 
10
11
  def ==(other)
@@ -21,20 +22,22 @@ module OoxmlParser
21
22
  end
22
23
  end
23
24
 
24
- def self.parse(color_node)
25
- theme_color = ThemeColor.new
25
+ # Parse ThemeColor
26
+ # @param node [Nokogiri::XML::Element] node to parse
27
+ # @return [ThemeColor] result of parsing
28
+ def parse(color_node)
26
29
  color_node.xpath('*').each do |color_node_child|
27
30
  case color_node_child.name
28
31
  when 'sysClr'
29
- theme_color.type = :system
30
- theme_color.value = color_node_child.attribute('val').value
31
- theme_color.color = Color.from_int16(color_node_child.attribute('lastClr').value.to_s) unless color_node_child.attribute('lastClr').nil?
32
+ @type = :system
33
+ @value = color_node_child.attribute('val').value
34
+ @color = Color.new(parent: self).parse_hex_string(color_node_child.attribute('lastClr').value.to_s) unless color_node_child.attribute('lastClr').nil?
32
35
  when 'srgbClr'
33
- theme_color.type = :rgb
34
- theme_color.color = Color.from_int16(color_node_child.attribute('val').value.to_s)
36
+ @type = :rgb
37
+ @color = Color.new(parent: self).parse_hex_string(color_node_child.attribute('val').value.to_s)
35
38
  end
36
39
  end
37
- theme_color
40
+ self
38
41
  end
39
42
  end
40
43
  end
@@ -22,7 +22,7 @@ module OoxmlParser
22
22
  case theme_element_node.name
23
23
  when 'clrScheme'
24
24
  theme_element_node.xpath('*').each do |color_scheme_element|
25
- OOXMLDocumentObject.theme.color_scheme[color_scheme_element.name.to_sym] = ThemeColor.parse(color_scheme_element)
25
+ OOXMLDocumentObject.theme.color_scheme[color_scheme_element.name.to_sym] = ThemeColor.new.parse(color_scheme_element)
26
26
  end
27
27
  OOXMLDocumentObject.theme.color_scheme[:background1] = OOXMLDocumentObject.theme.color_scheme[:lt1]
28
28
  OOXMLDocumentObject.theme.color_scheme[:background2] = OOXMLDocumentObject.theme.color_scheme[:lt2]
@@ -0,0 +1,11 @@
1
+ module OoxmlParser
2
+ # Class for parsing `stretch` tag
3
+ class Stretch < OOXMLDocumentObject
4
+ # Parse Stretch object
5
+ # @param _node [Nokogiri::XML:Element] node to parse
6
+ # @return [Stretch] result of parsing
7
+ def parse(_node)
8
+ self
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'background_properties/stretch'
2
+ module OoxmlParser
3
+ # Class for parsing `bgPr` tag
4
+ class BackgroundProperties < OOXMLDocumentObject
5
+ # @return [BlipFill]
6
+ attr_accessor :blip_fill
7
+
8
+ # Parse BackgroundProperties object
9
+ # @param node [Nokogiri::XML:Element] node to parse
10
+ # @return [BackgroundProperties] result of parsing
11
+ def parse(node)
12
+ node.xpath('*').each do |node_child|
13
+ case node_child.name
14
+ when 'blipFill'
15
+ @blip_fill = BlipFill.new(parent: self).parse(node_child)
16
+ end
17
+ end
18
+ self
19
+ end
20
+ end
21
+ end
@@ -1,19 +1,32 @@
1
+ require_relative 'background/background_properties'
1
2
  module OoxmlParser
3
+ # Class for parsing `bg` tag
2
4
  class Background < OOXMLDocumentObject
3
5
  attr_accessor :fill, :shade_to_title
6
+ # @return [BackgroundProperties] properties
7
+ attr_accessor :properties
4
8
 
5
9
  def initialize(type = nil)
6
10
  @type = type
7
11
  end
8
12
 
9
- def self.parse(background_node)
10
- background = Background.new
11
- background_properties_node = background_node.xpath('p:bgPr').first
13
+ # Parse Background object
14
+ # @param node [Nokogiri::XML:Element] node to parse
15
+ # @return [Background] result of parsing
16
+ def parse(node)
17
+ node.xpath('*').each do |node_child|
18
+ case node_child.name
19
+ when 'bgPr'
20
+ @properties = BackgroundProperties.new(parent: self).parse(node_child)
21
+ end
22
+ end
23
+
24
+ background_properties_node = node.xpath('p:bgPr').first
12
25
  if background_properties_node
13
- background.shade_to_title = OOXMLDocumentObject.option_enabled?(background_properties_node, 'shadeToTitle')
14
- background.fill = PresentationFill.parse(background_properties_node)
26
+ @shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
27
+ @fill = PresentationFill.new(parent: self).parse(background_properties_node)
15
28
  end
16
- background
29
+ self
17
30
  end
18
31
  end
19
32
  end
@@ -1,34 +1,45 @@
1
1
  module OoxmlParser
2
+ # Class for parsing `graphicFrame`
2
3
  class GraphicFrame < OOXMLDocumentObject
3
4
  attr_accessor :properties, :transform, :graphic_data
5
+ # @return [NonVisualShapeProperties] non visual properties
6
+ attr_accessor :non_visual_properties
4
7
 
5
8
  def initialize(graphic_data = [])
6
9
  @graphic_data = graphic_data
7
10
  end
8
11
 
9
- def self.parse(graphic_frame_node)
10
- graphic_frame = GraphicFrame.new
11
- graphic_frame_node.xpath('*').each do |graphic_frame_node_child|
12
- case graphic_frame_node_child.name
13
- when 'nvGraphicFramePr'
12
+ # Parse GraphicFrame object
13
+ # @param node [Nokogiri::XML:Element] node to parse
14
+ # @return [GraphicFrame] result of parsing
15
+ def parse(node)
16
+ node.xpath('*').each do |node_child|
17
+ case node_child.name
14
18
  when 'xfrm'
15
- graphic_frame.transform = TransformEffect.parse(graphic_frame_node_child)
19
+ @transform = DocxShapeSize.new(parent: self).parse(node_child)
16
20
  when 'graphic'
17
21
  graphic_data = []
18
- graphic_frame_node_child.xpath('a:graphicData/*').each do |graphic_node_child|
19
- case graphic_node_child.name
20
- when 'tbl'
21
- graphic_data << Table.parse(graphic_node_child)
22
- when 'chart'
23
- OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
24
- graphic_data << Chart.parse
25
- OOXMLDocumentObject.xmls_stack.pop
22
+ node_child.xpath('*').each do |node_child_child|
23
+ case node_child_child.name
24
+ when 'graphicData'
25
+ node_child_child.xpath('*').each do |graphic_node_child|
26
+ case graphic_node_child.name
27
+ when 'tbl'
28
+ graphic_data << Table.new(parent: self).parse(graphic_node_child)
29
+ when 'chart'
30
+ OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
31
+ graphic_data << Chart.parse
32
+ OOXMLDocumentObject.xmls_stack.pop
33
+ end
34
+ end
26
35
  end
27
36
  end
28
- graphic_frame.graphic_data = graphic_data
37
+ @graphic_data = graphic_data
38
+ when 'nvGraphicFramePr'
39
+ @non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
29
40
  end
30
41
  end
31
- graphic_frame
42
+ self
32
43
  end
33
44
  end
34
45
  end
@@ -1,25 +1,29 @@
1
1
  require_relative 'transition/transition'
2
2
  module OoxmlParser
3
+ # Class for parsing `AlternateContent`
3
4
  class PresentationAlternateContent < OOXMLDocumentObject
4
5
  attr_accessor :transition, :timing, :elements
5
6
 
6
- def initialize(elements = [])
7
+ def initialize(parent: nil)
7
8
  @elements = elements
9
+ @parent = parent
8
10
  end
9
11
 
10
- def self.parse(alternate_content_node)
11
- alternate_content = PresentationAlternateContent.new
12
- alternate_content_node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |choice_node_child|
13
- case choice_node_child.name
12
+ # Parse PresentationAlternateContent object
13
+ # @param node [Nokogiri::XML:Element] node to parse
14
+ # @return [PresentationAlternateContent] result of parsing
15
+ def parse(node)
16
+ node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |node_child|
17
+ case node_child.name
14
18
  when 'timing'
15
- alternate_content.timing = Timing.parse(choice_node_child)
19
+ @timing = Timing.new(parent: self).parse(node_child)
16
20
  when 'transition'
17
- alternate_content.transition = Transition.parse(choice_node_child)
21
+ @transition = Transition.new(parent: self).parse(node_child)
18
22
  when 'sp'
19
- alternate_content.elements << PresentationShape.parse(choice_node_child)
23
+ @elements << DocxShape.new(parent: self).parse(node_child)
20
24
  end
21
25
  end
22
- alternate_content
26
+ self
23
27
  end
24
28
  end
25
29
  end