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,17 +1,23 @@
1
1
  # noinspection RubyTooManyInstanceVariablesInspection
2
+ require_relative 'docx_paragraph/bookmark'
2
3
  require_relative 'docx_paragraph/docx_paragraph_run'
3
4
  require_relative 'docx_paragraph/indents'
5
+ require_relative 'docx_paragraph/inserted'
4
6
  require_relative 'docx_paragraph/frame_properties'
5
7
  require_relative 'docx_paragraph/docx_formula'
6
- require_relative 'docx_paragraph/paragraph_style'
8
+ require_relative 'docx_paragraph/style_parametres'
7
9
  module OoxmlParser
8
10
  class DocxParagraph < OOXMLDocumentObject
9
11
  attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :background_color, :ind, :numbering,
10
12
  :character_style_array, :horizontal_line, :page_break, :kinoku, :borders, :keep_lines,
11
13
  :contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
12
- :orphan_control, :tabs, :frame_properties
14
+ :orphan_control, :frame_properties
15
+ # @return [ParagraphProperties] Properties of current paragraph
16
+ attr_accessor :paragraph_properties
17
+ # @return [Inserted] data inserted by review
18
+ attr_accessor :inserted
13
19
 
14
- def initialize
20
+ def initialize(parent: nil)
15
21
  @number = 0
16
22
  @bookmark_start = []
17
23
  @bookmark_end = []
@@ -33,8 +39,8 @@ module OoxmlParser
33
39
  @style = nil
34
40
  @keep_next = false
35
41
  @orphan_control = true
36
- @tabs = []
37
42
  @frame_properties = nil
43
+ @parent = parent
38
44
  end
39
45
 
40
46
  def copy
@@ -45,7 +51,7 @@ module OoxmlParser
45
51
  paragraph.align = @align
46
52
  paragraph.spacing = @spacing.copy
47
53
  paragraph.background_color = @background_color
48
- paragraph.ind = @ind.copy
54
+ paragraph.ind = @ind.dup
49
55
  paragraph.numbering = @numbering
50
56
  paragraph.character_style_array = @character_style_array
51
57
  paragraph.horizontal_line = @horizontal_line
@@ -60,21 +66,33 @@ module OoxmlParser
60
66
  paragraph.style = @style
61
67
  paragraph.keep_next = @keep_next
62
68
  paragraph.orphan_control = @orphan_control
63
- paragraph.tabs = @tabs.dup
64
69
  paragraph.frame_properties = @frame_properties
70
+ paragraph.paragraph_properties = @paragraph_properties
71
+ paragraph.inserted = @inserted
65
72
  paragraph
66
73
  end
67
74
 
68
75
  def nonempty_runs
69
76
  @character_style_array.select do |cur_run|
70
77
  if cur_run.is_a?(DocxParagraphRun)
71
- (!cur_run.text.empty? || !cur_run.alternate_content.nil? || !cur_run.drawing.nil?)
78
+ (!cur_run.text.empty? ||
79
+ !cur_run.alternate_content.nil? ||
80
+ !cur_run.drawing.nil? ||
81
+ !cur_run.object.nil? ||
82
+ !cur_run.footnote.nil? ||
83
+ !cur_run.endnote.nil?
84
+ )
72
85
  elsif cur_run.is_a?(DocxFormula)
73
86
  true
74
87
  end
75
88
  end
76
89
  end
77
90
 
91
+ # @return [True, false] if structure contain any user data
92
+ def with_data?
93
+ !nonempty_runs.empty?
94
+ end
95
+
78
96
  def remove_empty_runs
79
97
  nonempty = nonempty_runs
80
98
  @character_style_array.each do |cur_run|
@@ -83,13 +101,7 @@ module OoxmlParser
83
101
  end
84
102
 
85
103
  def ==(other)
86
- character_style_array.each do |current_run|
87
- character_style_array.delete(current_run) if current_run.text.empty?
88
- end
89
- other.character_style_array.each do |current_run|
90
- other.character_style_array.delete(current_run) if current_run.text.empty?
91
- end
92
- ignored_attributes = [:@number]
104
+ ignored_attributes = [:@number, :@parent]
93
105
  all_instance_variables = instance_variables
94
106
  significan_attribues = all_instance_variables - ignored_attributes
95
107
  significan_attribues.each do |current_attributes|
@@ -100,210 +112,172 @@ module OoxmlParser
100
112
  true
101
113
  end
102
114
 
103
- def self.parse(p_tag, par_number = 0, default_paragraph = DocxParagraph.new, default_character = DocxParagraphRun.new)
104
- paragraph_style = default_paragraph.copy
115
+ def parse(node, par_number = 0, default_character = DocxParagraphRun.new, parent: nil)
116
+ @parent = parent
105
117
  default_character_style = default_character.copy
106
118
  character_styles_array = []
107
- custom_character_style = DocxParagraphRun.new
119
+ custom_character_style = default_character_style.copy
108
120
  char_number = 0
109
121
  comments = []
110
- p_tag.xpath('w:bookmarkStart').each do |bookmark_start|
111
- paragraph_style.bookmark_start << Bookmark.new(bookmark_start.attribute('id').value, bookmark_start.attribute('name').value)
112
- end
113
- p_tag.xpath('w:bookmarkEnd').each do |bookmark_end|
114
- paragraph_style.bookmark_end << Bookmark.new(bookmark_end.attribute('id').value)
115
- end
116
- p_tag.xpath('*').each do |p_element|
117
- if p_element.name == 'pPr'
118
- p_props = p_tag.xpath('w:pPr')
119
- DocxParagraph.parse_paragraph_style(p_props, paragraph_style, custom_character_style)
120
- p_tag.xpath('w:pict').each do |pict|
122
+ node.xpath('*').each do |node_child|
123
+ case node_child.name
124
+ when 'bookmarkStart'
125
+ @bookmark_start << Bookmark.new(parent: self).parse(node_child)
126
+ when 'bookmarkEnd'
127
+ @bookmark_end << Bookmark.new(parent: self).parse(node_child)
128
+ when 'pPr'
129
+ parse_paragraph_style(node_child, custom_character_style)
130
+ node.xpath('w:pict').each do |pict|
121
131
  pict.xpath('v:rect').each do
122
- paragraph_style.horizontal_line = true
132
+ @horizontal_line = true
123
133
  end
124
134
  end
125
- elsif p_element.name == 'commentRangeStart'
126
- comments << p_element.attribute('id').value
127
- elsif p_element.name == 'fldSimple'
128
- instruction = p_element.attribute('instr').to_s
129
- paragraph_style.page_numbering = true if instruction.include?('PAGE')
130
- p_element.xpath('w:r').each do |r_tag|
131
- character_style = DocxParagraphRun.parse_character(r_tag, default_character_style.copy, char_number)
132
- character_style.page_number = paragraph_style.page_numbering
135
+ @paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
136
+ when 'commentRangeStart'
137
+ comments << node_child.attribute('id').value
138
+ when 'fldSimple'
139
+ instruction = node_child.attribute('instr').to_s
140
+ @page_numbering = true if instruction.include?('PAGE')
141
+ node_child.xpath('w:r').each do |r_tag|
142
+ character_style = default_character_style.copy
143
+ character_style.parse(r_tag, char_number, parent: parent)
144
+ character_style.page_number = @page_numbering
133
145
  character_style.instruction = instruction
134
146
  character_styles_array << character_style.copy
135
147
  char_number += 1
136
148
  end
137
- elsif p_element.name == 'r'
149
+ when 'r'
138
150
  character_style = custom_character_style.copy
139
- p_element.xpath('w:instrText').each do |insrt_text|
140
- if insrt_text.text.include?('PAGE')
141
- paragraph_style.page_numbering = true
142
- end
151
+ node_child.xpath('w:instrText').each do |insrt_text|
152
+ @page_numbering = true if insrt_text.text.include?('PAGE')
143
153
  end
144
- character_style = DocxParagraphRun.parse_character(p_element, character_style, char_number)
154
+ character_style.parse(node_child, char_number, parent: self)
145
155
  character_style.comments = comments.dup
146
156
  character_styles_array << character_style.copy
147
157
  unless character_style.shape.nil?
148
158
  character_styles_array.last.shape = character_style.shape
149
159
  end
150
160
  char_number += 1
151
- elsif p_element.name == 'hyperlink'
161
+ when 'hyperlink'
152
162
  character_style = default_character_style.copy
153
- if !p_element.attribute('id').nil?
154
- character_style.link = Hyperlink.parse(p_element)
163
+ if !node_child.attribute('id').nil?
164
+ character_style.link = Hyperlink.new(parent: character_style).parse(node_child)
155
165
  else
156
- unless p_element.attribute('anchor').nil?
157
- character_style.link = p_element.attribute('anchor').value
166
+ unless node_child.attribute('anchor').nil?
167
+ character_style.link = node_child.attribute('anchor').value
158
168
  end
159
169
  end
160
- p_element.xpath('w:r').each do |r_tag|
161
- character_style = DocxParagraphRun.parse_character(r_tag, character_style, char_number)
170
+ node_child.xpath('w:r').each do |r_tag|
171
+ character_style.parse(r_tag, char_number, parent: parent)
162
172
  character_styles_array << character_style.copy
163
173
  char_number += 1
164
174
  end
165
- p_element.xpath('w:fldSimple').each do |simple_field|
175
+ node_child.xpath('w:fldSimple').each do |simple_field|
166
176
  instruction = simple_field.attribute('instr').to_s
167
- paragraph_style.page_numbering = true if instruction.include?('PAGE')
177
+ @page_numbering = true if instruction.include?('PAGE')
168
178
  simple_field.xpath('w:r').each do |r_tag|
169
- character_style = DocxParagraphRun.parse_character(r_tag, character_style.copy, char_number)
170
- character_style.page_number = paragraph_style.page_numbering
179
+ character_style.parse(r_tag, char_number, parent: self)
180
+ character_style.page_number = @page_numbering
171
181
  character_style.instruction = instruction
172
182
  character_styles_array << character_style.copy
173
183
  char_number += 1
174
184
  end
175
185
  end
176
- elsif p_element.name == 'oMathPara'
177
- p_element.xpath('m:oMath').each do |o_math|
178
- character_styles_array << DocxFormula.parse(o_math)
186
+ when 'oMathPara'
187
+ node_child.xpath('m:oMath').each do |o_math|
188
+ character_styles_array << DocxFormula.new(parent: self).parse(o_math)
179
189
  end
180
- elsif p_element.name == 'commentRangeEnd'
190
+ when 'commentRangeEnd'
181
191
  comments.each_with_index do |comment, index|
182
- if comment == p_element.attribute('id').value
192
+ if comment == node_child.attribute('id').value
183
193
  comments.delete_at(index)
184
194
  break
185
195
  end
186
196
  end
197
+ when 'ins'
198
+ @inserted = Inserted.new(parent: self).parse(node_child)
187
199
  end
188
200
  end
189
- paragraph_style.number = par_number
201
+ @number = par_number
190
202
  if character_styles_array.last.class == DocxParagraphRun
191
203
  character_styles_array.last.text = character_styles_array.last.text.rstrip
192
204
  end
193
- paragraph_style.character_style_array = character_styles_array
194
- paragraph_style
205
+ @character_style_array = character_styles_array
206
+ @parent = parent
207
+ self
195
208
  end
196
209
 
197
- def self.parse_paragraph_style(paragraph_pr_tag, paragraph_style = DocxParagraph.new, default_char_style = DocxParagraphRun.new)
198
- paragraph_pr_tag.xpath('w:tabs').each do |tabs_node|
199
- tabs_node.xpath('w:tab').each { |tab_node| paragraph_style.tabs << ParagraphTab.new(tab_node.attribute('val').value.to_sym, (tab_node.attribute('pos').value.to_f / 566.9).round(2)) }
200
- end
201
- paragraph_pr_tag.xpath('w:pageBreakBefore').each do |page_break_before|
202
- if page_break_before.attribute('val').nil? || page_break_before.attribute('val').value != 'false'
203
- paragraph_style.page_break = true
204
- end
205
- end
206
- paragraph_pr_tag.xpath('w:pBdr').each do |paragraph_br|
207
- paragraph_style.borders = Borders.new
208
- paragraph_br.xpath('w:bottom').each do |bottom|
209
- paragraph_style.borders.bottom = BordersProperties.parse(bottom)
210
- end
211
- paragraph_br.xpath('w:left').each do |left|
212
- paragraph_style.borders.left = BordersProperties.parse(left)
213
- end
214
- paragraph_br.xpath('w:top').each do |top|
215
- paragraph_style.borders.top = BordersProperties.parse(top)
216
- end
217
- paragraph_br.xpath('w:right').each do |right|
218
- paragraph_style.borders.right = BordersProperties.parse(right)
219
- end
220
- paragraph_br.xpath('w:between').each do |between|
221
- paragraph_style.borders.between = BordersProperties.parse(between)
222
- end
223
- paragraph_br.xpath('w:bar').each do |bar|
224
- paragraph_style.borders.bar = BordersProperties.parse(bar)
225
- end
226
- end
227
- paragraph_pr_tag.xpath('w:keepLines').each do |keep_lines|
228
- if keep_lines.attribute('val').nil?
229
- paragraph_style.keep_lines = true
230
- else
231
- unless keep_lines.attribute('val').value == 'false'
232
- paragraph_style.keep_lines = true
210
+ def parse_paragraph_style(node, default_char_style = DocxParagraphRun.new)
211
+ node.xpath('*').each do |node_child|
212
+ case node_child.name
213
+ when 'pageBreakBefore'
214
+ if node_child.attribute('val').nil? || node_child.attribute('val').value != 'false'
215
+ @page_break = true
233
216
  end
217
+ when 'pBdr'
218
+ @borders = ParagraphBorders.new(parent: self).parse(node_child)
219
+ when 'keepLines'
220
+ if node_child.attribute('val').nil?
221
+ @keep_lines = true
222
+ else
223
+ unless node_child.attribute('val').value == 'false'
224
+ @keep_lines = true
225
+ end
226
+ end
227
+ when 'widowControl'
228
+ @orphan_control = option_enabled?(node_child)
229
+ when 'keepNext'
230
+ @keep_next = true
231
+ when 'contextualSpacing'
232
+ @contextual_spacing = true
233
+ when 'shd'
234
+ background_color_string = node_child.attribute('fill').value
235
+ @background_color = Color.new(parent: self).parse_hex_string(background_color_string)
236
+ unless node_child.attribute('val').nil?
237
+ @background_color.set_style(node_child.attribute('val').value)
238
+ end
239
+ when 'pStyle'
240
+ DocxParagraph.parse_paragraph_style_xml(node_child.attribute('val').value, self, default_char_style)
241
+ when 'ind'
242
+ @ind = DocumentStructure.default_paragraph_style.ind.dup.parse(node_child)
243
+ when 'kinoku'
244
+ @kinoku = true
245
+ when 'framePr'
246
+ @frame_properties = FrameProperties.new(parent: self).parse(node_child)
247
+ when 'numPr'
248
+ @numbering = NumberingProperties.new(parent: self).parse(node_child)
249
+ when 'jc'
250
+ @align = node_child.attribute('val').value.to_sym unless node_child.attribute('val').nil?
251
+ @align = :justify if node_child.attribute('val').value == 'both'
252
+ when 'spacing'
253
+ unless node_child.attribute('before').nil?
254
+ @spacing.before = (node_child.attribute('before').value.to_f / 566.9).round(2)
255
+ end
256
+ unless node_child.attribute('after').nil?
257
+ @spacing.after = (node_child.attribute('after').value.to_f / 566.9).round(2)
258
+ end
259
+ unless node_child.attribute('lineRule').nil?
260
+ @spacing.line_rule = node_child.attribute('lineRule').value.sub('atLeast', 'at_least').to_sym
261
+ end
262
+ unless node_child.attribute('line').nil?
263
+ @spacing.line = (@spacing.line_rule == :auto ? (node_child.attribute('line').value.to_f / 240.0).round(2) : (node_child.attribute('line').value.to_f / 566.9).round(2))
264
+ end
265
+ when 'sectPr'
266
+ @sector_properties = PageProperties.new(parent: self).parse(node_child, self, default_char_style)
267
+ @section_break = case @sector_properties.type
268
+ when 'oddPage'
269
+ 'Odd page'
270
+ when 'evenPage'
271
+ 'Even page'
272
+ when 'continuous'
273
+ 'Current Page'
274
+ else
275
+ 'Next Page'
276
+ end
234
277
  end
235
278
  end
236
- paragraph_pr_tag.xpath('w:widowControl').each do |widow_control_node|
237
- paragraph_style.orphan_control = OOXMLDocumentObject.option_enabled?(widow_control_node)
238
- end
239
- paragraph_pr_tag.xpath('w:keepNext').each do |_|
240
- paragraph_style.keep_next = true
241
- end
242
- paragraph_style.contextual_spacing = true unless paragraph_pr_tag.xpath('w:contextualSpacing').empty?
243
- paragraph_pr_tag.xpath('w:shd').each do |shd|
244
- background_color_string = shd.attribute('fill').value
245
- paragraph_style.background_color = Color.from_int16(background_color_string)
246
- unless shd.attribute('val').nil?
247
- paragraph_style.background_color.set_style(shd.attribute('val').value)
248
- end
249
- end
250
- paragraph_pr_tag.xpath('w:pStyle').each do |p_style|
251
- parse_paragraph_style_xml(p_style.attribute('val').value, paragraph_style, default_char_style)
252
- end
253
- paragraph_pr_tag.xpath('w:ind').each do |ind|
254
- paragraph_style.ind = Indents.parse(ind)
255
- end
256
- paragraph_pr_tag.xpath('w:kinoku').each do
257
- paragraph_style.kinoku = true
258
- end
259
- paragraph_pr_tag.xpath('w:framePr').each do |frame_pr_node|
260
- paragraph_style.frame_properties = FrameProperties.parse(frame_pr_node)
261
- end
262
- paragraph_pr_tag.xpath('w:numPr').each do |num_pr|
263
- numbering = Numbering.new
264
- num_pr.xpath('w:ilvl').each do |ilvl|
265
- numbering.ilvl = ilvl.attribute('val').value
266
- end
267
- num_pr.xpath('w:numId').each do |num_id|
268
- numbering.numbering_properties = NumberingProperties.parse(num_id.attribute('val').value) if File.exist?(OOXMLDocumentObject.path_to_folder + 'word/numbering.xml')
269
- end
270
- paragraph_style.numbering = numbering
271
- end
272
- paragraph_pr_tag.xpath('w:jc').each do |jc|
273
- paragraph_style.align = jc.attribute('val').value.to_sym unless jc.attribute('val').nil?
274
- paragraph_style.align = :justify if jc.attribute('val').value == 'both'
275
- end
276
- paragraph_pr_tag.xpath('w:framePr').each do |frame_pr_node|
277
- paragraph_style.frame_properties = FrameProperties.parse(frame_pr_node)
278
- end
279
- paragraph_pr_tag.xpath('w:spacing').each do |spacing|
280
- unless spacing.attribute('before').nil?
281
- paragraph_style.spacing.before = (spacing.attribute('before').value.to_f / 566.9).round(2)
282
- end
283
- unless spacing.attribute('after').nil?
284
- paragraph_style.spacing.after = (spacing.attribute('after').value.to_f / 566.9).round(2)
285
- end
286
- unless spacing.attribute('lineRule').nil?
287
- paragraph_style.spacing.line_rule = spacing.attribute('lineRule').value.sub('atLeast', 'at_least').to_sym
288
- end
289
- unless spacing.attribute('line').nil?
290
- paragraph_style.spacing.line = (paragraph_style.spacing.line_rule == :auto ? (spacing.attribute('line').value.to_f / 240.0).round(2) : (spacing.attribute('line').value.to_f / 566.9).round(2))
291
- end
292
- end
293
- paragraph_pr_tag.xpath('w:sectPr').each do |sect_pr|
294
- paragraph_style.sector_properties = PageProperties.parse(sect_pr, paragraph_style, default_char_style)
295
- paragraph_style.section_break = case paragraph_style.sector_properties.type
296
- when 'oddPage'
297
- 'Odd page'
298
- when 'evenPage'
299
- 'Even page'
300
- when 'continuous'
301
- 'Current Page'
302
- else
303
- 'Next Page'
304
- end
305
- end
306
- paragraph_style
279
+ @parent = parent
280
+ self
307
281
  end
308
282
 
309
283
  def self.parse_paragraph_style_xml(id, paragraph_style, character_style)
@@ -311,11 +285,11 @@ module OoxmlParser
311
285
  doc.search('//w:style').each do |style|
312
286
  next unless style.attribute('styleId').value == id
313
287
  style.xpath('w:pPr').each do |p_pr|
314
- parse_paragraph_style(p_pr, paragraph_style, character_style)
315
- paragraph_style.style = StyleParametres.parse(style)
288
+ paragraph_style.parse_paragraph_style(p_pr, character_style)
289
+ paragraph_style.style = StyleParametres.new(parent: paragraph_style).parse(style)
316
290
  end
317
291
  style.xpath('w:rPr').each do |r_pr|
318
- DocxParagraphRun.parse(r_pr, character_style, @default_character)
292
+ character_style.parse_properties(r_pr, DocumentStructure.default_run_style)
319
293
  end
320
294
  break
321
295
  end
@@ -1,37 +1,56 @@
1
1
  module OoxmlParser
2
+ # Class Header Footer classes
2
3
  class HeaderFooter < OOXMLDocumentObject
3
- attr_accessor :id, :description, :type
4
+ attr_accessor :id, :elements, :type
5
+ attr_accessor :path_suffix
4
6
 
5
- def initialize(type = :header)
7
+ def initialize(type = :header, parent: nil)
6
8
  @type = type
9
+ @elements = []
10
+ @parent = parent
7
11
  end
8
12
 
9
- def parse(type, id, default_paragraph, default_character)
10
- if type == :header
11
- doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/footnotes.xml'))
12
- doc.search('//w:footnote').each do |footnote|
13
- next unless footnote.attribute('id').value == id
14
- description = []
15
- paragraph_number = 0
16
- footnote.xpath('w:p').each do |paragraph|
17
- description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
18
- paragraph_number += 1
19
- end
20
- return description
21
- end
22
- elsif type == :header
23
- doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/endnotes.xml'))
24
- doc.search('//w:endnote').each do |footnote|
25
- next unless footnote.attribute('id').value == id
26
- description = []
27
- paragraph_number = 0
28
- footnote.xpath('w:p').each do |paragraph|
29
- description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
30
- paragraph_number += 1
31
- end
32
- return description
13
+ # @return [String] string for search of xpath
14
+ def xpath_for_search
15
+ "//w:#{path_suffix}"
16
+ end
17
+
18
+ # @return [String] string with xml path
19
+ def xml_path
20
+ "word/#{path_suffix}s.xml"
21
+ end
22
+
23
+ # Parse type and path suffix by node type
24
+ # @param [Nokogiri::XML:Node] node with HeaderFooter
25
+ def parse_type(node)
26
+ case node.name
27
+ when 'footnoteReference'
28
+ @path_suffix = 'footnote'
29
+ @type = :header
30
+ when 'endnoteReference'
31
+ @path_suffix = 'endnote'
32
+ @type = :footer
33
+ else
34
+ warn "Unknown HeaderFooter type: #{node.name}"
35
+ end
36
+ end
37
+
38
+ # Parse HeaderFooter
39
+ # @param [Nokogiri::XML:Node] node with HeaderFooter
40
+ # @return [HeaderFooter] result of parsing
41
+ def parse(node)
42
+ @id = node.attribute('id').value.to_i
43
+ parse_type(node)
44
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + xml_path))
45
+ doc.search(xpath_for_search).each do |footnote|
46
+ next unless footnote.attribute('id').value.to_i == @id
47
+ paragraph_number = 0
48
+ footnote.xpath('w:p').each do |paragraph|
49
+ @elements << DocumentStructure.default_paragraph_style.copy.parse(paragraph, paragraph_number, DocumentStructure.default_run_style, parent: self)
50
+ paragraph_number += 1
33
51
  end
34
52
  end
53
+ self
35
54
  end
36
55
  end
37
56
  end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # This element specifies the type of numbering defined by a given abstract numbering type
3
+ class MultilevelType < OOXMLDocumentObject
4
+ # @return [String] value of Multilevel Type
5
+ attr_accessor :value
6
+
7
+ # Parse MultilevelType
8
+ # @param [Nokogiri::XML:Node] node with MultilevelType
9
+ # @return [MultilevelType] result of parsing
10
+ def parse(node)
11
+ node.attributes.each do |key, value|
12
+ case key
13
+ when 'val'
14
+ @value = value_to_symbol(value)
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for storing Level Justification, `lvlJc` tag
3
+ class LevelJustification < OOXMLDocumentObject
4
+ # @return [String] value of start
5
+ attr_accessor :value
6
+
7
+ # Parse LevelJustification
8
+ # @param [Nokogiri::XML:Node] node with LevelJustification
9
+ # @return [LevelJustification] 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
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for storing Level Text, `lvlText` tag
3
+ class LevelText < OOXMLDocumentObject
4
+ # @return [String] value of start
5
+ attr_accessor :value
6
+
7
+ # Parse LevelText
8
+ # @param [Nokogiri::XML:Node] node with LevelText
9
+ # @return [LevelText] 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
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for storing Numbering Format data, `numFmt` tag
3
+ class NumberingFormat < OOXMLDocumentObject
4
+ # @return [String] value of start
5
+ attr_accessor :value
6
+
7
+ # Parse NumberingFormat
8
+ # @param [Nokogiri::XML:Node] node with NumberingFormat
9
+ # @return [NumberingFormat] 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
@@ -0,0 +1,20 @@
1
+ module OoxmlParser
2
+ # Class for storing Start data, `start` tag
3
+ class Start < OOXMLDocumentObject
4
+ # @return [Integer] value of start
5
+ attr_accessor :value
6
+
7
+ # Parse Start
8
+ # @param [Nokogiri::XML:Node] node with Start
9
+ # @return [Start] 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_f
15
+ end
16
+ end
17
+ self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ module OoxmlParser
2
+ # Class for storing Suffix `w:suff`
3
+ # This element specifies the content which
4
+ # shall be added between a given numbering level's text and the text of
5
+ # every numbered paragraph which references that numbering level.
6
+ # If this element is omitted, then its value shall be assumed to be tab.
7
+ # >ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference 17.9.29.
8
+ class Suffix < OOXMLDocumentObject
9
+ # @return [String] value of suffix
10
+ attr_accessor :value
11
+
12
+ def initialize(value = :tab,
13
+ parent: nil)
14
+ @value = value
15
+ @parent = parent
16
+ end
17
+
18
+ # Parse Suffix
19
+ # @param [Nokogiri::XML:Node] node with Suffix
20
+ # @return [Suffix] result of parsing
21
+ def parse(node)
22
+ node.attributes.each do |key, value|
23
+ case key
24
+ when 'val'
25
+ @value = value.value.to_sym
26
+ end
27
+ end
28
+ self
29
+ end
30
+ end
31
+ end