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,22 +1,28 @@
1
1
  module OoxmlParser
2
+ # Class for parsing `pattFill` tag
2
3
  class PresentationPattern < OOXMLDocumentObject
3
4
  attr_accessor :preset, :foreground_color, :background_color
4
5
 
5
- def initialize(preset = nil)
6
- @preset = preset
7
- end
6
+ # Parse PresentationPattern object
7
+ # @param node [Nokogiri::XML:Element] node to parse
8
+ # @return [PresentationPattern] result of parsing
9
+ def parse(node)
10
+ node.attributes.each do |key, value|
11
+ case key
12
+ when 'prst'
13
+ @preset = value.value.to_sym
14
+ end
15
+ end
8
16
 
9
- def self.parse(pattern_node)
10
- pattern = PresentationPattern.new(pattern_node.attribute('prst').value.to_sym)
11
- pattern_node.xpath('*').each do |color_node|
17
+ node.xpath('*').each do |color_node|
12
18
  case color_node.name
13
19
  when 'fgClr'
14
- pattern.foreground_color = Color.parse_color(color_node.xpath('*').first)
20
+ @foreground_color = Color.parse_color(color_node.xpath('*').first)
15
21
  when 'bgClr'
16
- pattern.background_color = Color.parse_color(color_node.xpath('*').first)
22
+ @background_color = Color.parse_color(color_node.xpath('*').first)
17
23
  end
18
24
  end
19
- pattern
25
+ self
20
26
  end
21
27
  end
22
28
  end
@@ -5,29 +5,32 @@ module OoxmlParser
5
5
  class PresentationFill < OOXMLDocumentObject
6
6
  attr_accessor :type, :image, :color, :pattern
7
7
 
8
- def self.parse(parent_fill_node)
9
- fill = PresentationFill.new
10
- return nil if parent_fill_node.xpath('*').empty?
11
- parent_fill_node.xpath('*').each do |fill_node|
12
- case fill_node.name
8
+ # Parse PresentationFill object
9
+ # @param node [Nokogiri::XML:Element] node to parse
10
+ # @return [PresentationFill] result of parsing
11
+ def parse(node)
12
+ return nil if node.xpath('*').empty?
13
+ node.xpath('*').each do |node_child|
14
+ case node_child.name
13
15
  when 'gradFill'
14
- fill.type = :gradient
15
- fill.color = GradientColor.parse(fill_node)
16
+ @type = :gradient
17
+ @color = GradientColor.new(parent: self).parse(node_child)
16
18
  when 'solidFill'
17
- fill.type = :solid
18
- fill.color = Color.parse_color(fill_node.xpath('*').first)
19
+ @type = :solid
20
+ @color = Color.parse_color(node_child.xpath('*').first)
19
21
  when 'blipFill'
20
- fill.type = :image
21
- fill.image = ImageFill.parse(fill_node)
22
+ @type = :image
23
+ @image = ImageFill.new(parent: self).parse(node_child)
22
24
  when 'pattFill'
23
- fill.type = :pattern
24
- fill.pattern = PresentationPattern.parse(fill_node)
25
+ @type = :pattern
26
+ @pattern = PresentationPattern.new(parent: self).parse(node_child)
25
27
  when 'noFill'
26
- fill.type = :noneColor
27
- fill.color = :none
28
+ @type = :noneColor
29
+ @color = :none
28
30
  end
29
31
  end
30
- fill
32
+ return nil if @type.nil?
33
+ self
31
34
  end
32
35
  end
33
36
  end
@@ -1,21 +1,25 @@
1
1
  module OoxmlParser
2
+ # Class for parsing `tile` tag
2
3
  class Tile < OOXMLDocumentObject
3
4
  attr_accessor :offset, :ratio, :flip, :align
4
5
 
5
- def initialize(offset = nil, ratio = nil)
6
+ def initialize(offset = nil, ratio = nil, parent: nil)
6
7
  @offset = offset
7
8
  @ratio = ratio
9
+ @parent = parent
8
10
  end
9
11
 
10
- def self.parse(tile_node)
11
- tile = Tile.new(OOXMLShift.parse(tile_node, 'tx', 'ty'), OOXMLShift.parse(tile_node, 'sx', 'sy'))
12
- tile_node.attributes.each do |key, value|
12
+ # Parse Tile object
13
+ # @param node [Nokogiri::XML:Element] node to parse
14
+ # @return [Tile] result of parsing
15
+ def parse(node)
16
+ node.attributes.each do |key, value|
13
17
  case key
14
18
  when 'algn'
15
- tile.align = Alignment.parse(value)
19
+ @align = value_to_symbol(value)
16
20
  end
17
21
  end
18
- tile
22
+ self
19
23
  end
20
24
  end
21
25
  end
@@ -22,80 +22,20 @@ module OoxmlParser
22
22
  def initialize(bold = false, italic = false, underlined = Underline.new(:none), strike = :none)
23
23
  @bold = bold
24
24
  @italic = italic
25
- @underlined = (underlined == false || underlined.nil?) ? Underline.new(:none) : underlined
25
+ @underlined = underlined == false || underlined.nil? ? Underline.new(:none) : underlined
26
26
  @strike = strike
27
27
  end
28
28
 
29
- class << self
30
- # Generate all possible combination of styles without parameter stoke (8)
31
- # @return [Array] with all FontStyle
32
- def generate_all_styles_without_stroke
33
- styles_array = []
34
- styles_array << FontStyle.new(true, true, Underline.new(:single), :none)
35
- styles_array << FontStyle.new(true, true, nil, :none)
36
- styles_array << FontStyle.new(true, false, Underline.new(:single), :none)
37
- styles_array << FontStyle.new(true, false, nil, :none)
38
-
39
- styles_array << FontStyle.new(false, true, Underline.new(:single), :none)
40
- styles_array << FontStyle.new(false, true, nil, :none)
41
- styles_array << FontStyle.new(false, false, Underline.new(:single), :none)
42
- styles_array << FontStyle.new(false, false, nil, :none)
43
- end
44
-
45
- # Generate all possible combination of styles (16)
46
- # @return [Array] with all FontStyle
47
- def generate_all_styles
48
- styles_array = []
49
- styles_array << generate_all_styles_without_stroke
50
-
51
- styles_array << FontStyle.new(true, true, Underline.new(:single), :single)
52
- styles_array << FontStyle.new(true, true, nil, :single)
53
- styles_array << FontStyle.new(true, false, Underline.new(:single), :single)
54
- styles_array << FontStyle.new(false, true, Underline.new(:single), :single)
55
-
56
- styles_array << FontStyle.new(true, false, nil, :single)
57
- styles_array << FontStyle.new(false, false, Underline.new(:single), :single)
58
- styles_array << FontStyle.new(false, true, nil, :single)
59
- styles_array << FontStyle.new(false, false, nil, :single)
60
- styles_array.flatten
61
- end
62
- end
63
-
64
29
  # Default == operator
65
30
  # @return [true, false] true if two same, false if different
66
31
  def ==(other)
67
32
  (@bold == other.bold) && (@italic == other.italic) && (@underlined == other.underlined) && (@strike == other.strike)
68
33
  end
69
34
 
70
- # Default + operator
71
- # @return [FontStyle] the result of overlapping of two styles
72
- def +(other)
73
- result = FontStyle.new
74
- result.bold = (other.bold == @bold) ? @bold : other.bold
75
- result.italic = (other.italic == @italic) ? @italic : other.italic
76
- result.underlined = (other.underlined == @underlined) ? @underlined : other.underlined
77
- result.strike = (other.strike == @strike) ? @strike : other.strike
78
- result
79
- end
80
-
81
35
  # Default to_s operator
82
36
  # @return [String] with text representation
83
37
  def to_s
84
38
  "Bold: #{@bold}, Italic: #{@italic}, Underlined: #{@underlined}, Strike: #{@strike}"
85
39
  end
86
-
87
- def copy
88
- return dup if underlined.nil?
89
- other = FontStyle.new
90
- instance_variables.each do |variable|
91
- case variable
92
- when @underlined
93
- other.instance_variable_set(variable, underlined.copy)
94
- else
95
- other.instance_variable_set(variable, instance_variable_get(variable))
96
- end
97
- end
98
- other
99
- end
100
40
  end
101
41
  end
@@ -1,11 +1,18 @@
1
1
  module OoxmlParser
2
+ # Class for parsing `hlinkClick`, `hyperlink` tags
2
3
  class Hyperlink < OOXMLDocumentObject
3
4
  attr_accessor :url, :tooltip, :coordinates, :id, :highlight_click, :action
5
+ attr_accessor :action_link
6
+ attr_accessor :id
4
7
 
5
- def initialize(link = nil, tooltip = nil, coordinates = nil)
8
+ def initialize(link = nil,
9
+ tooltip = nil,
10
+ coordinates = nil,
11
+ parent: nil)
6
12
  @url = link
7
13
  @tooltip = tooltip
8
14
  @coordinates = coordinates
15
+ @parent = parent
9
16
  end
10
17
 
11
18
  alias link url
@@ -13,46 +20,46 @@ module OoxmlParser
13
20
  alias link= url=
14
21
  alias link_to= url=
15
22
 
16
- def self.parse(on_click_hyperlink_node)
17
- hyperlink = Hyperlink.new
18
- on_click_hyperlink_node.attributes.each do |key, value|
23
+ # Parse Hyperlink object
24
+ # @param node [Nokogiri::XML:Element] node to parse
25
+ # @return [Hyperlink] result of parsing
26
+ def parse(node)
27
+ node.attributes.each do |key, value|
19
28
  case key
20
29
  when 'location'
21
- hyperlink.url = Coordinates.parse_coordinates_from_string(value.value)
30
+ @url = Coordinates.parse_coordinates_from_string(value.value)
22
31
  when 'id'
23
- hyperlink.url = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value)
32
+ @id = value.value
33
+ @url = OOXMLDocumentObject.get_link_from_rels(@id)
24
34
  when 'tooltip'
25
- hyperlink.tooltip = value.value
35
+ @tooltip = value.value
26
36
  when 'ref'
27
- hyperlink.coordinates = Coordinates.parse_coordinates_from_string(value.value)
37
+ @coordinates = Coordinates.parse_coordinates_from_string(value.value)
38
+ when 'action'
39
+ @action_link = value.value
40
+ when 'highlightClick'
41
+ @highlight_click = attribute_enabled?(value)
28
42
  end
29
43
  end
30
- action = on_click_hyperlink_node.attribute('action').value unless on_click_hyperlink_node.attribute('action').nil?
31
- case action
44
+ case @action_link
32
45
  when 'ppaction://hlinkshowjump?jump=previousslide'
33
- hyperlink.action = :previous_slide
46
+ @action = :previous_slide
34
47
  when 'ppaction://hlinkshowjump?jump=nextslide'
35
- hyperlink.action = :next_slide
48
+ @action = :next_slide
36
49
  when 'ppaction://hlinkshowjump?jump=firstslide'
37
- hyperlink.action = :first_slide
50
+ @action = :first_slide
38
51
  when 'ppaction://hlinkshowjump?jump=lastslide'
39
- hyperlink.action = :last_slide
52
+ @action = :last_slide
40
53
  when 'ppaction://hlinksldjump'
41
- hyperlink.action = :slide
42
- hyperlink.link_to = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value).scan(/\d+/).join('').to_i
54
+ @action = :slide
55
+ @url = OOXMLDocumentObject.get_link_from_rels(@id).scan(/\d+/).join('').to_i
43
56
  else
44
- unless on_click_hyperlink_node.attribute('id').nil?
45
- hyperlink.action = :external_link
46
- hyperlink.link_to = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value)
57
+ unless @id.nil?
58
+ @action = :external_link
59
+ @url = OOXMLDocumentObject.get_link_from_rels(@id)
47
60
  end
48
61
  end
49
- return hyperlink unless on_click_hyperlink_node.attribute('highlightClick')
50
- hyperlink.highlight_click = if on_click_hyperlink_node.attribute('highlightClick').value == '1'
51
- true
52
- else
53
- false
54
- end
55
- hyperlink
62
+ self
56
63
  end
57
64
  end
58
65
  end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+ # Module for helper methods for OOXMLDocumentObject
3
+ module OoxmlDocumentObjectHelper
4
+ private
5
+
6
+ VALUE_TO_SYMBOL_HASH = { l: :left,
7
+ ctr: :center,
8
+ r: :right,
9
+ just: :justify,
10
+ b: :bottom,
11
+ t: :top,
12
+ tr: :top_right,
13
+ tl: :top_left,
14
+ br: :bottom_right,
15
+ bl: :bottom_left,
16
+ dist: :distributed,
17
+ tb: :horizontal,
18
+ rl: :rotate_on_90,
19
+ lr: :rotate_on_270,
20
+ inset: :in,
21
+ lu: :left_up,
22
+ ru: :right_up,
23
+ ld: :left_down,
24
+ rd: :right_down,
25
+ d: :down,
26
+ u: :up,
27
+ lg: :large,
28
+ med: :medium,
29
+ sm: :small,
30
+ beneathText: :beneath_text,
31
+ pageBottom: :page_bottom,
32
+ sectEnd: :section_end,
33
+ docEnd: :document_end,
34
+ eachSect: :each_section,
35
+ eachPage: :each_page,
36
+ sngStrike: :single,
37
+ dblStrike: :double,
38
+ noStrike: :none,
39
+ lgDash: :large_dash,
40
+ dashDot: :dash_dot,
41
+ dashDotDot: :dash_dot_dot,
42
+ mediumDashed: :medium_dashed,
43
+ mediumDashDot: :medium_dash_dot,
44
+ mediumDashDotDot: :medium_dash_dot_dot,
45
+ lgDashDot: :large_dash_dot,
46
+ lgDashDotDot: :large_dash_dot_dot,
47
+ sysDash: :system_dash,
48
+ sysDot: :system_dot,
49
+ sysDashDot: :system_dash_dot,
50
+ sysDashDotDot: :system_dash_dot_dot,
51
+ rightMargin: :right_margin,
52
+ leftMargin: :left_margin,
53
+ bottomMargin: :bottom_margin,
54
+ topMargin: :top_margin,
55
+ undOvr: :under_over,
56
+ subSup: :subscript_superscript,
57
+ lrTb: :left_to_right_top_to_bottom,
58
+ tbRl: :top_to_bottom_right_to_left,
59
+ btLr: :bottom_to_top_left_to_right,
60
+ singlelevel: :single_level,
61
+ multilevel: :multi_level,
62
+ hybridMultilevel: :hybrid_multi_level,
63
+ rnd: :round,
64
+ sq: :square }.freeze
65
+
66
+ # Convert value to human readable symbol
67
+ # @param [String] value to convert
68
+ # @return [Symbol]
69
+ def value_to_symbol(value)
70
+ symbol = VALUE_TO_SYMBOL_HASH[value.value.to_sym]
71
+ return value.value.to_sym if symbol.nil?
72
+ symbol
73
+ end
74
+
75
+ def option_enabled?(node, attribute_name = 'val')
76
+ return true if node.attributes.empty?
77
+ return true if node.to_s == '1'
78
+ return false if node.to_s == '0'
79
+ return false if node.attribute(attribute_name).nil?
80
+ status = node.attribute(attribute_name).value
81
+ !(status == 'false' || status == 'off' || status == '0')
82
+ end
83
+
84
+ def attribute_enabled?(node, attribute_name = 'val')
85
+ return true if node.to_s == '1'
86
+ return false if node.to_s == '0'
87
+ return false if node.attribute(attribute_name).nil?
88
+ status = node.attribute(attribute_name).value
89
+ status == 'true' || status == 'on' || status == '1'
90
+ end
91
+
92
+ def root_object
93
+ tree_object = self
94
+ tree_object = tree_object.parent until tree_object.parent.nil?
95
+ tree_object
96
+ end
97
+ end
@@ -1,14 +1,22 @@
1
+ require 'filemagic'
1
2
  require 'securerandom'
2
3
  require 'nokogiri'
3
- require 'xmlsimple'
4
4
  require 'zip'
5
+ require_relative 'ooxml_document_object/ooxml_document_object_helper'
5
6
 
6
7
  module OoxmlParser
7
8
  class OOXMLDocumentObject
8
- DEFAULT_DIRECTORY_FOR_MEDIA = '/tmp'.freeze
9
+ include OoxmlDocumentObjectHelper
10
+ # @return [OOXMLDocumentObject] object which hold current object
11
+ attr_accessor :parent
12
+
13
+ def initialize(parent: nil)
14
+ @parent = parent
15
+ end
9
16
 
10
17
  def ==(other)
11
18
  instance_variables.each do |current_attribute|
19
+ next if current_attribute == :@parent
12
20
  unless instance_variable_get(current_attribute) == other.instance_variable_get(current_attribute)
13
21
  return false
14
22
  end
@@ -16,8 +24,12 @@ module OoxmlParser
16
24
  true
17
25
  end
18
26
 
27
+ # @return [True, false] if structure contain any user data
28
+ def with_data?
29
+ true
30
+ end
31
+
19
32
  class << self
20
- attr_accessor :namespace_prefix
21
33
  attr_accessor :root_subfolder
22
34
  attr_accessor :theme
23
35
  attr_accessor :xmls_stack
@@ -26,11 +38,11 @@ module OoxmlParser
26
38
  # @param path_to_file [String] file
27
39
  # @return [True, False] Check if file is protected by password on open
28
40
  def encrypted_file?(path_to_file)
29
- file_result = `file "#{path_to_file}"`
41
+ file_result = FileMagic.new(:mime).file(path_to_file)
30
42
  # Support of Encrtypted status in `file` util was introduced in file v5.20
31
43
  # but LTS version of ubuntu before 16.04 uses older `file` and it return `Composite Document`
32
44
  # https://github.com/file/file/blob/master/ChangeLog#L217
33
- if file_result.include?('Encrypted') || file_result.include?('Composite Document File V2 Document, No summary info')
45
+ if file_result.include?('encrypted') || file_result.include?('Composite Document File V2 Document, No summary info')
34
46
  warn("File #{path_to_file} is encrypted. Can't parse it")
35
47
  return true
36
48
  end
@@ -39,11 +51,10 @@ module OoxmlParser
39
51
 
40
52
  def copy_file_and_rename_to_zip(path)
41
53
  file_name = File.basename(path)
42
- tmp_folder = "/tmp/office_open_xml_parser_#{SecureRandom.uuid}"
54
+ tmp_folder = Dir.mktmpdir('ruby-ooxml-parser')
43
55
  file_path = "#{tmp_folder}/#{file_name}"
44
56
  FileUtils.rm_rf(tmp_folder) if File.directory?(tmp_folder)
45
57
  FileUtils.mkdir_p(tmp_folder)
46
- path = "#{Dir.pwd}/#{path}" unless path[0] == '/'
47
58
  raise "Cannot find file by path #{path}" unless File.exist?(path)
48
59
  FileUtils.cp path, tmp_folder
49
60
  file_path
@@ -72,43 +83,18 @@ module OoxmlParser
72
83
  def add_to_xmls_stack(path)
73
84
  OOXMLDocumentObject.xmls_stack << if path.include?('..')
74
85
  "#{File.dirname(OOXMLDocumentObject.xmls_stack.last)}/#{path}"
75
- else
86
+ elsif path.start_with?(OOXMLDocumentObject.root_subfolder)
76
87
  path
88
+ else
89
+ OOXMLDocumentObject.root_subfolder + path
77
90
  end
78
91
  end
79
92
 
80
93
  def get_link_from_rels(id)
81
94
  rels_path = dir + "_rels/#{File.basename(OOXMLDocumentObject.xmls_stack.last)}.rels"
82
95
  raise LoadError, "Cannot find .rels file by path: #{rels_path}" unless File.exist?(rels_path)
83
- relationships = XmlSimple.xml_in(File.open(rels_path))
84
- relationships['Relationship'].each { |relationship| return relationship['Target'] if id == relationship['Id'] }
85
- end
86
-
87
- def media_folder
88
- path = "#{DEFAULT_DIRECTORY_FOR_MEDIA}/media_from_#{@file_name}"
89
- FileUtils.mkdir(path) unless File.exist?(path)
90
- path + '/'
91
- end
92
-
93
- def option_enabled?(node, attribute_name = 'val')
94
- return true if node.to_s == '1'
95
- return false if node.to_s == '0'
96
- return false if node.attribute(attribute_name).nil?
97
- status = node.attribute(attribute_name).value
98
- status == 'true' || status == 'on' || status == '1'
99
- end
100
-
101
- def copy_media_file(path_to_file)
102
- folder_to_save_media = '/tmp/media_from_' + File.basename(OOXMLDocumentObject.path_to_folder)
103
- path_to_copied_file = folder_to_save_media + '/' + File.basename(path_to_file)
104
- full_path_to_file = OOXMLDocumentObject.path_to_folder + path_to_file
105
- unless File.exist?(full_path_to_file)
106
- warn "Couldn't find #{full_path_to_file} file on filesystem. Possible problem in original document"
107
- return nil
108
- end
109
- FileUtils.mkdir(folder_to_save_media) unless File.exist?(folder_to_save_media)
110
- FileUtils.copy_file(full_path_to_file, path_to_copied_file)
111
- path_to_copied_file
96
+ relationships = Relationships.parse_rels(rels_path)
97
+ relationships.target_by_id(id)
112
98
  end
113
99
  end
114
100
  end
@@ -1,48 +1,96 @@
1
+ require_relative 'paragrpah_properties/numbering_properties'
2
+ require_relative 'paragrpah_properties/paragraph_borders'
3
+ require_relative 'paragrpah_properties/paragraph_spacing'
1
4
  require_relative 'paragrpah_properties/spacing'
2
- require_relative 'paragrpah_properties/numbering'
5
+ require_relative 'paragrpah_properties/tab_list'
6
+ require_relative 'paragrpah_properties/tabs'
3
7
  module OoxmlParser
4
8
  class ParagraphProperties < OOXMLDocumentObject
5
- attr_accessor :align, :numbering, :level, :spacing, :spacing_before, :spacing_after, :indent, :margin_left, :margin_right,
6
- :tabs
9
+ attr_accessor :align, :numbering, :level, :spacing, :spacing_before, :spacing_after, :indent, :margin_left, :margin_right
10
+ # @return [Tabs] list of tabs
11
+ attr_accessor :tabs
12
+ # @return [RunProperties] properties of run
13
+ attr_accessor :run_properties
14
+ # @return [Borders] borders of paragraph
15
+ attr_accessor :paragraph_borders
16
+ # @return [True, False] Specifies that the paragraph
17
+ # (or at least part of it) should be rendered on
18
+ # the same page as the next paragraph when possible
19
+ attr_accessor :keep_next
20
+ # @return [PageProperties] properties of section
21
+ attr_accessor :section_properties
22
+ # @return [True, False] This element specifies that any space specified
23
+ # before or after this paragraph, specified using the spacing element (17.3.1.33),
24
+ # should not be applied when the preceding and following paragraphs are of
25
+ # the same paragraph style, affecting the top and bottom spacing respectively
26
+ attr_accessor :contextual_spacing
27
+ # @return [Symbol] The alignment or justification to be applied to a paragraph
28
+ attr_accessor :justification
7
29
 
8
- def initialize(numbering = Numbering.new)
30
+ def initialize(numbering = NumberingProperties.new, parent: nil)
9
31
  @numbering = numbering
10
- @spacing = Spacing.new(0, 0, 1, :multiple)
32
+ @spacing = Spacing.new(OoxmlSize.new(0),
33
+ OoxmlSize.new(0),
34
+ OoxmlSize.new(1, :centimeter),
35
+ :multiple)
36
+ @keep_next = false
37
+ @tabs = []
38
+ @parent = parent
11
39
  end
12
40
 
13
- def self.parse(paragraph_props_node)
14
- paragraph_properties = ParagraphProperties.new
15
- paragraph_properties.spacing.parse(paragraph_props_node)
16
- paragraph_props_node.attributes.each do |key, value|
41
+ # Parse ParagraphProperties object
42
+ # @param node [Nokogiri::XML:Element] node to parse
43
+ # @return [ParagraphProperties] result of parsing
44
+ def parse(node)
45
+ @spacing.parse(node)
46
+ node.attributes.each do |key, value|
17
47
  case key
18
48
  when 'algn'
19
- paragraph_properties.align = Alignment.parse(value)
49
+ @align = value_to_symbol(value)
20
50
  when 'lvl'
21
- paragraph_properties.level = value.value.to_i
51
+ @level = value.value.to_i
22
52
  when 'indent'
23
- paragraph_properties.indent = (value.value.to_f / 360_000.0).round(2)
53
+ @indent = OoxmlSize.new(value.value.to_f, :emu)
24
54
  when 'marR'
25
- paragraph_properties.margin_right = (value.value.to_f / 360_000.0).round(2)
55
+ @margin_right = OoxmlSize.new(value.value.to_f, :emu)
26
56
  when 'marL'
27
- paragraph_properties.margin_left = (value.value.to_f / 360_000.0).round(2)
57
+ @margin_left = OoxmlSize.new(value.value.to_f, :emu)
28
58
  end
29
59
  end
30
- paragraph_props_node.xpath('*').each do |properties_element|
31
- case properties_element.name
60
+ node.xpath('*').each do |node_child|
61
+ case node_child.name
32
62
  when 'buSzPct'
33
- paragraph_properties.numbering.size = properties_element.attribute('val').value
63
+ @numbering.size = node_child.attribute('val').value
34
64
  when 'buFont'
35
- paragraph_properties.numbering.font = properties_element.attribute('typeface').value
65
+ @numbering.font = node_child.attribute('typeface').value
36
66
  when 'buChar'
37
- paragraph_properties.numbering.symbol = properties_element.attribute('char').value
67
+ @numbering.symbol = node_child.attribute('char').value
38
68
  when 'buAutoNum'
39
- paragraph_properties.numbering.type = properties_element.attribute('type').value.to_sym
40
- paragraph_properties.numbering.start_at = properties_element.attribute('startAt').value if properties_element.attribute('startAt')
69
+ @numbering.type = node_child.attribute('type').value.to_sym
70
+ @numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
71
+ when 'tabs'
72
+ @tabs = Tabs.new(parent: self).parse(node_child)
41
73
  when 'tabLst'
42
- paragraph_properties.tabs = ParagraphTab.parse(properties_element)
74
+ @tabs = TabList.new(parent: self).parse(node_child)
75
+ when 'ind'
76
+ @indent = Indents.new(parent: self).parse(node_child)
77
+ when 'rPr'
78
+ @run_properties = RunProperties.new(parent: self).parse(node_child)
79
+ when 'pBdr'
80
+ @paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
81
+ when 'keepNext'
82
+ @keep_next = true
83
+ when 'sectPr'
84
+ @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
85
+ when 'spacing'
86
+ @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
87
+ when 'jc'
88
+ @justification = value_to_symbol(node_child.attribute('val'))
89
+ when 'contextualSpacing'
90
+ @contextual_spacing = option_enabled?(node_child)
43
91
  end
44
92
  end
45
- paragraph_properties
93
+ self
46
94
  end
47
95
  end
48
96
  end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w:lang` object
3
+ class Language < OOXMLDocumentObject
4
+ # @return [String] value of language
5
+ attr_accessor :value
6
+
7
+ # Parse Language
8
+ # @param [Nokogiri::XML:Node] node with Language
9
+ # @return [Language] result of parsing
10
+ def parse(node)
11
+ node.attributes.each do |key, value|
12
+ case key
13
+ when 'val'
14
+ @value = value.value.to_s
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end