ooxml_parser 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/.overcommit.yml +35 -0
  3. data/Changelog.md +25 -0
  4. data/LICENSE.txt +661 -0
  5. data/README.md +26 -0
  6. data/circle.yml +3 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alingment.rb +56 -0
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +34 -0
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +123 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +34 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +38 -0
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +23 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +33 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_point.rb +11 -0
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +17 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +17 -0
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +26 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +49 -0
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +23 -0
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +35 -0
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +11 -0
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +39 -0
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +32 -0
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +34 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +10 -0
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +34 -0
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +27 -0
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +26 -0
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +25 -0
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +16 -0
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +30 -0
  32. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +37 -0
  33. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +20 -0
  34. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +30 -0
  35. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +6 -0
  36. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +10 -0
  37. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_element.rb +10 -0
  38. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb +44 -0
  39. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +23 -0
  40. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +43 -0
  41. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +54 -0
  42. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +25 -0
  43. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +40 -0
  44. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +31 -0
  45. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +20 -0
  46. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +21 -0
  47. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +5 -0
  48. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +31 -0
  49. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_element.rb +10 -0
  50. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_properties.rb +6 -0
  51. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +26 -0
  52. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +24 -0
  53. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +26 -0
  54. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +24 -0
  55. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +25 -0
  56. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +19 -0
  57. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +20 -0
  58. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +28 -0
  59. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +18 -0
  60. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +15 -0
  61. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +28 -0
  62. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +13 -0
  63. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +26 -0
  64. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +23 -0
  65. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +58 -0
  66. data/lib/ooxml_parser/common_parser/common_data/color.rb +473 -0
  67. data/lib/ooxml_parser/common_parser/common_data/colors/color_alpha_channel.rb +14 -0
  68. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +21 -0
  69. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +150 -0
  70. data/lib/ooxml_parser/common_parser/common_data/colors/image/fill_rectangle.rb +22 -0
  71. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +11 -0
  72. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +32 -0
  73. data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +16 -0
  74. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +15 -0
  75. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +10 -0
  76. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +35 -0
  77. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +22 -0
  78. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +33 -0
  79. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +14 -0
  80. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +22 -0
  81. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +21 -0
  82. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +127 -0
  83. data/lib/ooxml_parser/common_parser/common_data/font_style.rb +101 -0
  84. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +53 -0
  85. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +87 -0
  86. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +48 -0
  87. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +23 -0
  88. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +16 -0
  89. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +79 -0
  90. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +24 -0
  91. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +25 -0
  92. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +69 -0
  93. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +18 -0
  94. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +115 -0
  95. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +35 -0
  96. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +35 -0
  97. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +47 -0
  98. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +20 -0
  99. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +20 -0
  100. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +43 -0
  101. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +49 -0
  102. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +83 -0
  103. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +21 -0
  104. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +19 -0
  105. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +20 -0
  106. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +43 -0
  107. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +142 -0
  108. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -0
  109. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +25 -0
  110. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +125 -0
  111. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +35 -0
  112. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +22 -0
  113. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +33 -0
  114. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +9 -0
  115. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +77 -0
  116. data/lib/ooxml_parser/common_parser/common_data/table.rb +41 -0
  117. data/lib/ooxml_parser/common_parser/common_data/underline.rb +40 -0
  118. data/lib/ooxml_parser/common_parser/common_document_structure.rb +7 -0
  119. data/lib/ooxml_parser/configuration.rb +20 -0
  120. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +28 -0
  121. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +10 -0
  122. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +21 -0
  123. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +70 -0
  124. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +11 -0
  125. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +10 -0
  126. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +11 -0
  127. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +12 -0
  128. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +11 -0
  129. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +11 -0
  130. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +13 -0
  131. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +12 -0
  132. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +12 -0
  133. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +10 -0
  134. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +10 -0
  135. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +13 -0
  136. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +11 -0
  137. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +203 -0
  138. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/offset.rb +10 -0
  139. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shadow.rb +10 -0
  140. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_margins.rb +11 -0
  141. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_size.rb +10 -0
  142. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/stroke.rb +10 -0
  143. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties.rb +16 -0
  144. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +40 -0
  145. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +13 -0
  146. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +22 -0
  147. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +388 -0
  148. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +46 -0
  149. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +87 -0
  150. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +10 -0
  151. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +19 -0
  152. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +35 -0
  153. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +56 -0
  154. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +324 -0
  155. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +37 -0
  156. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +15 -0
  157. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +10 -0
  158. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +37 -0
  159. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +29 -0
  160. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +49 -0
  161. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +42 -0
  162. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +88 -0
  163. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +84 -0
  164. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +232 -0
  165. data/lib/ooxml_parser/docx_parser/docx_parser.rb +16 -0
  166. data/lib/ooxml_parser/helpers/string_helper.rb +22 -0
  167. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment/presentation_comment_author.rb +25 -0
  168. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +31 -0
  169. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +40 -0
  170. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +44 -0
  171. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -0
  172. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +34 -0
  173. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +25 -0
  174. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +23 -0
  175. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/extents.rb +10 -0
  176. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/offset.rb +10 -0
  177. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/paragraph.rb +10 -0
  178. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/text_field.rb +18 -0
  179. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shapes_grouping/shapes_grouping.rb +9 -0
  180. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +16 -0
  181. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +30 -0
  182. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +22 -0
  183. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +28 -0
  184. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +31 -0
  185. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +20 -0
  186. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +26 -0
  187. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +33 -0
  188. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +52 -0
  189. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +23 -0
  190. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound/sound.rb +18 -0
  191. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound_action.rb +18 -0
  192. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +43 -0
  193. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -0
  194. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +110 -0
  195. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +20 -0
  196. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +62 -0
  197. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +15 -0
  198. data/lib/ooxml_parser/version.rb +6 -0
  199. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +27 -0
  200. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +25 -0
  201. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +20 -0
  202. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +43 -0
  203. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +21 -0
  204. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +23 -0
  205. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +18 -0
  206. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +24 -0
  207. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +22 -0
  208. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +22 -0
  209. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +37 -0
  210. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +49 -0
  211. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +30 -0
  212. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +25 -0
  213. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +38 -0
  214. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +95 -0
  215. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +47 -0
  216. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +19 -0
  217. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +30 -0
  218. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +74 -0
  219. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +108 -0
  220. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +15 -0
  221. data/lib/ooxml_parser.rb +35 -0
  222. data/ooxml_parser.gemspec +30 -0
  223. metadata +310 -0
@@ -0,0 +1,388 @@
1
+ # noinspection RubyTooManyInstanceVariablesInspection
2
+ require_relative 'docx_paragraph_run/text_outline'
3
+ require_relative 'docx_paragraph_run/text_fill'
4
+ require_relative 'docx_paragraph_run/shape'
5
+
6
+ module OoxmlParser
7
+ class DocxParagraphRun < OOXMLDocumentObject
8
+ attr_accessor :number, :font, :vertical_align, :size, :font_color, :background_color, :font_style, :text, :drawings,
9
+ :link, :highlight, :shadow, :outline, :imprint, :emboss, :vanish, :effect, :caps, :w,
10
+ :position, :rtl, :em, :cs, :spacing, :break, :touch, :shape, :footnote, :endnote, :fld_char, :style,
11
+ :comments, :alternate_content, :page_number, :text_outline, :text_fill
12
+ # @return [String] type of instruction used for upper level of run
13
+ # http://officeopenxml.com/WPfieldInstructions.php
14
+ attr_accessor :instruction
15
+
16
+ def initialize
17
+ @number = 0
18
+ @font = 'Arial'
19
+ @vertical_align = :baseline
20
+ @size = 11
21
+ @font_color = Color.new
22
+ @background_color = nil
23
+ @font_style = FontStyle.new
24
+ @text = ''
25
+ @drawings = []
26
+ @link = nil
27
+ @highlight = nil
28
+ @shadow = nil
29
+ @outline = nil
30
+ @imprint = nil
31
+ @emboss = nil
32
+ @vanish = nil
33
+ @effect = nil
34
+ @caps = nil
35
+ @w = false
36
+ @position = 0.0
37
+ @rtl = false
38
+ @em = nil
39
+ @cs = false
40
+ @spacing = 0.0
41
+ @break = false
42
+ @touch = nil
43
+ @footnote = nil
44
+ @endnote = nil
45
+ @fld_char = nil
46
+ @style = nil
47
+ @comments = []
48
+ @alternate_content = nil
49
+ @page_number = false
50
+ @text_outline = nil
51
+ @text_fill = nil
52
+ @instruction = nil
53
+ end
54
+
55
+ def drawing
56
+ # TODO: Rewrite all tests without this methos
57
+ @drawings.empty? ? nil : drawings.first
58
+ end
59
+
60
+ def copy
61
+ character = DocxParagraphRun.new
62
+ character.number = number
63
+ character.font = font
64
+ character.vertical_align = vertical_align
65
+ character.size = size
66
+ character.font_color = font_color
67
+ character.background_color = @background_color
68
+ character.font_style = @font_style
69
+ character.text = @text
70
+ character.drawings = @drawings.clone
71
+ character.link = @link
72
+ character.highlight = @highlight
73
+ character.shadow = @shadow
74
+ character.outline = @outline
75
+ character.imprint = @imprint
76
+ character.emboss = @emboss
77
+ character.vanish = @vanish
78
+ character.effect = @effect
79
+ character.caps = @caps
80
+ character.w = @w
81
+ character.position = @position
82
+ character.rtl = @rtl
83
+ character.em = @em
84
+ character.cs = @cs
85
+ character.spacing = @spacing
86
+ character.cs = @cs
87
+ character.break = @break
88
+ character.touch = @touch
89
+ character.footnote = @footnote
90
+ character.endnote = @endnote
91
+ character.fld_char = @fld_char
92
+ character.style = @style
93
+ character.comments = @comments.clone
94
+ character.alternate_content = @alternate_content
95
+ character.page_number = @page_number
96
+ character.text_outline = @text_outline
97
+ character.text_fill = @text_fill
98
+ character.instruction = @instruction
99
+ character
100
+ end
101
+
102
+ def ==(other)
103
+ ignored_attributes = [:@number]
104
+ all_instance_variables = instance_variables
105
+ significan_attribues = all_instance_variables - ignored_attributes
106
+ significan_attribues.each do |current_attributes|
107
+ unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
108
+ return false
109
+ end
110
+ end
111
+ true
112
+ end
113
+
114
+ def self.parse(character_pr_tag, character_style = DocxParagraphRun.new, default_character = @default_character)
115
+ character_style.font_style = FontStyle.new
116
+ character_pr_tag.xpath('w:rStyle').each do |r_style|
117
+ style = get_style_by_id(r_style.attribute('val').value)
118
+ break if style.nil?
119
+ style.xpath('w:rPr').each do |style_rpr|
120
+ character_style = parse(style_rpr, character_style, default_character)
121
+ end
122
+ end
123
+ character_pr_tag.xpath('w:rFonts').each do |r_font|
124
+ r_font.attributes.each do |font_attribute, value|
125
+ case font_attribute
126
+ when 'asciiTheme'
127
+ character_style.font = parse_font_by_theme(r_font.attribute('asciiTheme').value)
128
+ when 'ascii' # , 'hAnsi', 'eastAsia', 'cs'
129
+ character_style.font = value.value
130
+ break
131
+ end
132
+ end
133
+ end
134
+ character_pr_tag.xpath('w:highlight').each do |highlight|
135
+ character_style.highlight = highlight.attribute('val').value
136
+ end
137
+ character_pr_tag.xpath('w:vertAlign').each do |vertical_align|
138
+ character_style.vertical_align = vertical_align.attribute('val').value.to_sym
139
+ end
140
+ character_pr_tag.xpath('w:szCs').each do |sz|
141
+ character_style.size = sz.attribute('val').value.to_i / 2.0
142
+ end
143
+ character_pr_tag.xpath('w:sz').each do |sz|
144
+ character_style.size = sz.attribute('val').value.to_i / 2.0
145
+ end
146
+ character_pr_tag.xpath('w:color').each do |color|
147
+ color.attributes.each do |key, value|
148
+ case key
149
+ when 'val'
150
+ character_style.font_color = Color.from_int16(value.value)
151
+ when 'themeColor'
152
+ unless ThemeColors.list[value.value.to_sym].nil?
153
+ if value.value == 'text2' || value.value == 'background2' || value.value.include?('accent') # Don't know why. Just works
154
+ break
155
+ else
156
+ character_style.font_color = ThemeColors.list[value.value.to_sym].dup
157
+ end
158
+ end
159
+ when 'themeShade'
160
+ character_style.font_color.calculate_with_shade!(value.value.hex.to_f / 255.0)
161
+ when 'themeTint'
162
+ character_style.font_color.calculate_with_tint!(1.0 - (value.value.hex.to_f / 255.0))
163
+ end
164
+ end
165
+ end
166
+ character_pr_tag.xpath('w:shd').each do |shd|
167
+ character_style.background_color = shd.attribute('fill').value
168
+ unless shd.attribute('fill').value == 'auto' || shd.attribute('fill').value == '' || shd.attribute('fill').value == 'null'
169
+ character_style.background_color = Color.from_int16(shd.attribute('fill').value)
170
+ end
171
+ end
172
+ character_pr_tag.xpath('w:uCs').each do |u|
173
+ character_style.font_style.underlined = Underline.new
174
+ if !u.attribute('val').nil? && u.attribute('val').value != 'none' && u.attribute('val').value != false
175
+ character_style.font_style.underlined.style = u.attribute('val').value
176
+ unless u.attribute('color').nil?
177
+ character_style.font_style.underlined.color = Color.from_int16(u.attribute('color').value)
178
+ end
179
+ else
180
+ character_style.font_style.underlined = Underline.new
181
+ end
182
+ end
183
+ character_pr_tag.xpath('w:u').each do |u|
184
+ character_style.font_style.underlined = Underline.new
185
+ if !u.attribute('val').nil? && u.attribute('val').value != 'none' && u.attribute('val').value != false
186
+ character_style.font_style.underlined.style = u.attribute('val').value
187
+ unless u.attribute('color').nil?
188
+ character_style.font_style.underlined.color = Color.from_int16(u.attribute('color').value)
189
+ end
190
+ else
191
+ character_style.font_style.underlined = Underline.new
192
+ end
193
+ end
194
+ character_pr_tag.xpath('w:bCs').each do |b|
195
+ character_style.font_style.bold = if b.attribute('val').nil? || b.attribute('val').value != 'false'
196
+ true
197
+ else
198
+ false
199
+ end
200
+ end
201
+ character_pr_tag.xpath('w:b').each do |b|
202
+ character_style.font_style.bold = if b.attribute('val').nil? || b.attribute('val').value != 'false'
203
+ true
204
+ else
205
+ false
206
+ end
207
+ end
208
+ character_pr_tag.xpath('w:iCs').each do |i|
209
+ next if i.attribute('val').nil?
210
+ character_style.font_style.italic = if i.attribute('val').value != 'false'
211
+ true
212
+ else
213
+ false
214
+ end
215
+ end
216
+ character_pr_tag.xpath('w:i').each do |i|
217
+ character_style.font_style.italic = if i.attribute('val').nil? || i.attribute('val').value != 'false'
218
+ true
219
+ else
220
+ false
221
+ end
222
+ end
223
+ character_pr_tag.xpath('w:strike').each do |strike|
224
+ character_style.font_style.strike = if strike.attribute('val').nil? || strike.attribute('val').value != 'false' && strike.attribute('val').value != '0'
225
+ :single
226
+ else
227
+ :none
228
+ end
229
+ end
230
+ character_pr_tag.xpath('w:dstrike').each do |dstrike|
231
+ if dstrike.attribute('val').nil?
232
+ character_style.font_style.strike = :double
233
+ elsif dstrike.attribute('val').value == '0' || dstrike.attribute('val').value == 'false'
234
+ else
235
+ character_style.font_style.strike = :double
236
+ end
237
+ end
238
+ character_pr_tag.xpath('w:shadow').each do
239
+ character_style.shadow = true
240
+ end
241
+ character_pr_tag.xpath('w:outline').each do
242
+ character_style.outline = true
243
+ end
244
+ character_pr_tag.xpath('w:imprint').each do
245
+ character_style.imprint = true
246
+ end
247
+ character_pr_tag.xpath('w:emboss').each do
248
+ character_style.emboss = true
249
+ end
250
+ character_pr_tag.xpath('w:vanish').each do
251
+ character_style.vanish = true
252
+ end
253
+ character_pr_tag.xpath('w:effect').each do |effect|
254
+ character_style.effect = effect.attribute('val').value
255
+ end
256
+ character_pr_tag.xpath('w:caps').each do |caps|
257
+ if caps.attribute('val').nil?
258
+ character_style.caps = :caps
259
+ elsif caps.attribute('val').value == 'false'
260
+ else
261
+ character_style.caps = :caps
262
+ end
263
+ end
264
+ character_pr_tag.xpath('w:smallCaps').each do |small_caps|
265
+ if small_caps.attribute('val').nil?
266
+ character_style.caps = :small_caps
267
+ elsif small_caps.attribute('val').value == 'false'
268
+ else
269
+ character_style.caps = :small_caps
270
+ end
271
+ end
272
+ character_pr_tag.xpath('w:position').each do |position|
273
+ character_style.position = (position.attribute('val').value.to_f / (28.0 + 1.0 / 3.0) / 2.0).round(1)
274
+ end
275
+ character_pr_tag.xpath('w:rtl').each do |rtl|
276
+ character_style.rtl = OOXMLDocumentObject.option_enabled?(rtl)
277
+ end
278
+ character_pr_tag.xpath('w:em').each do |em|
279
+ character_style.em = em.attribute('val').value
280
+ end
281
+ character_pr_tag.xpath('w:cs').each do |cs|
282
+ character_style.cs = OOXMLDocumentObject.option_enabled?(cs)
283
+ end
284
+ character_pr_tag.xpath('w:spacing').each do |spacing|
285
+ character_style.spacing = (spacing.attribute('val').value.to_f / 566.9).round(1)
286
+ end
287
+ character_pr_tag.xpath('w14:textOutline', 'xmlns:w14' => 'http://schemas.microsoft.com/office/word/2010/wordml').each do |text_outline|
288
+ character_style.text_outline = TextOutline.parse(text_outline)
289
+ text_outline.xpath('w14:prstDash', 'xmlns:w14' => 'http://schemas.microsoft.com/office/word/2010/wordml').each do |outline_style|
290
+ character_style.touch = outline_style.attribute('val').value
291
+ end
292
+ end
293
+ character_pr_tag.xpath('w14:textFill', 'xmlns:w14' => 'http://schemas.microsoft.com/office/word/2010/wordml').each do |text_fill|
294
+ character_style.text_fill = TextFill.parse(text_fill)
295
+ end
296
+ character_style
297
+ end
298
+
299
+ def self.parse_character(r_tag, character_style, char_number)
300
+ r_tag.xpath('*').each do |r_node_child|
301
+ case r_node_child.name
302
+ when 'rPr'
303
+ DocxParagraphRun.parse(r_node_child, character_style, @default_character)
304
+ when 'instrText'
305
+ if r_node_child.text.include?('HYPERLINK')
306
+ hyperlink = Hyperlink.new(r_node_child.text.sub('HYPERLINK ', '').split(' \\o ').first, r_node_child.text.sub('HYPERLINK', '').split(' \\o ').last)
307
+ character_style.link = hyperlink
308
+ elsif r_node_child.text[/PAGE\s+\\\*/]
309
+ character_style.text = '*PAGE NUMBER*'
310
+ end
311
+ when 'fldChar'
312
+ character_style.fld_char = r_node_child.attribute('fldCharType').value.to_sym
313
+ when 't'
314
+ character_style.text += r_node_child.text
315
+ when 'noBreakHyphen'
316
+ character_style.text += '–'
317
+ when 'tab'
318
+ character_style.text += "\t"
319
+ when 'drawing'
320
+ character_style.drawings << DocxDrawing.parse(r_node_child)
321
+ when 'AlternateContent'
322
+ character_style.alternate_content = AlternateContent.parse(r_node_child)
323
+ when 'br'
324
+ if r_node_child.attribute('type').nil?
325
+ character_style.break = :line
326
+ character_style.text += "\r"
327
+ else
328
+ case r_node_child.attribute('type').value
329
+ when 'page', 'column'
330
+ character_style.break = r_node_child.attribute('type').value.to_sym
331
+ end
332
+ end
333
+ when 'footnoteReference'
334
+ character_style.footnote = HeaderFooter.new(:header)
335
+ character_style.footnote.id = r_node_child.attribute('id').value
336
+ character_style.footnote.parse('footnote', character_style.footnote.id, @default_paragraph, @default_character)
337
+ when 'endnoteReference'
338
+ character_style.endnote = HeaderFooter.new(:footer)
339
+ character_style.endnote.id = r_node_child.attribute('id').value
340
+ character_style.endnote.parse('endnote', character_style.endnote.id, @default_paragraph, @default_character)
341
+ when 'pict'
342
+ r_node_child.xpath('*').each do |pict_node_child|
343
+ case pict_node_child.name
344
+ when 'shape'
345
+ character_style.shape = Shape.parse(pict_node_child, :shape, OOXMLDocumentObject.path_to_folder)
346
+ when 'rect'
347
+ character_style.shape = Shape.parse(pict_node_child, :rectangle, OOXMLDocumentObject.path_to_folder)
348
+ when 'oval'
349
+ character_style.shape = Shape.parse(pict_node_child, :oval, OOXMLDocumentObject.path_to_folder)
350
+ when 'shapetype'
351
+ end
352
+ end
353
+ end
354
+ end
355
+ character_style.number = char_number
356
+ character_style
357
+ end
358
+
359
+ def self.parse_font_by_theme(theme)
360
+ doc = Nokogiri::XML(File.open("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/theme/theme1.xml"))
361
+ doc.search('//a:fontScheme').each do |font_scheme|
362
+ if theme.include?('major')
363
+ font_scheme.xpath('a:majorFont').each do |major_font|
364
+ major_font.xpath('a:latin').each do |latin|
365
+ return latin.attribute('typeface').value
366
+ end
367
+ end
368
+ elsif theme.include?('minor')
369
+ font_scheme.xpath('a:minorFont').each do |minor_font|
370
+ minor_font.xpath('a:latin').each do |latin|
371
+ return latin.attribute('typeface').value
372
+ end
373
+ end
374
+ end
375
+ end
376
+ end
377
+
378
+ def self.get_style_by_id(id)
379
+ doc = Nokogiri::XML(File.open("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/styles.xml"))
380
+ doc.search('//w:styles').each do |styles|
381
+ styles.xpath('w:style').each do |style|
382
+ return style if style.attribute('styleId').value == id
383
+ end
384
+ end
385
+ nil
386
+ end
387
+ end
388
+ end
@@ -0,0 +1,46 @@
1
+ module OoxmlParser
2
+ class FrameProperties
3
+ attr_accessor :drop_cap, :lines, :wrap, :vertical_anchor, :horizontal_anchor, :width, :height, :height_rule,
4
+ :horizontal_align, :vertical_align, :anchor_lock, :vertical_space, :horizontal_space,
5
+ :horizontal_position, :vertical_position
6
+
7
+ def self.parse(frame_pr_node)
8
+ frame_properties = FrameProperties.new
9
+ frame_pr_node.attributes.each do |key, value|
10
+ case key
11
+ when 'dropCap'
12
+ frame_properties.drop_cap = value.value.to_sym
13
+ when 'lines'
14
+ frame_properties.lines = value.value.to_i
15
+ when 'wrap'
16
+ frame_properties.lines = value.value.to_sym
17
+ when 'vAnchor'
18
+ frame_properties.vertical_anchor = value.value.to_sym
19
+ when 'hAnchor'
20
+ frame_properties.horizontal_anchor = value.value.to_sym
21
+ when 'w'
22
+ frame_properties.width = (value.value.to_f / 566.9).round(2)
23
+ when 'h'
24
+ frame_properties.height = (value.value.to_f / 566.9).round(2)
25
+ when 'hRule'
26
+ frame_properties.height_rule = value.value.to_s.sub('atLeast', 'at_least').to_sym
27
+ when 'xAlign'
28
+ frame_properties.horizontal_align = value.value.to_sym
29
+ when 'yAlign'
30
+ frame_properties.vertical_align = value.value.to_sym
31
+ when 'anchorLock'
32
+ frame_properties.anchor_lock = OOXMLDocumentObject.option_enabled?(frame_pr_node, anchorLock)
33
+ when 'vSpace'
34
+ frame_properties.vertical_space = (value.value.to_f / 566.9).round(2)
35
+ when 'hSpace'
36
+ frame_properties.horizontal_space = (value.value.to_f / 566.9).round(2)
37
+ when 'x'
38
+ frame_properties.horizontal_position = (value.value.to_f / 566.9).round(2)
39
+ when 'y'
40
+ frame_properties.vertical_position = (value.value.to_f / 566.9).round(2)
41
+ end
42
+ end
43
+ frame_properties
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,87 @@
1
+ module OoxmlParser
2
+ class Indents
3
+ attr_accessor :first_line_indent, :left_indent, :right_indent, :hanging_indent
4
+
5
+ def initialize(first_line_indent = 0.0, left_indent = 0.0, right_indent = 0.0, hanging_indent = nil)
6
+ @first_line_indent = first_line_indent
7
+ @left_indent = left_indent
8
+ @right_indent = right_indent
9
+ @hanging_indent = hanging_indent
10
+ end
11
+
12
+ def ==(other)
13
+ if self.class != NilClass && other.class != NilClass
14
+ if @first_line_indent.to_f == other.first_line_indent.to_f &&
15
+ @left_indent.to_f.round(2) == other.left_indent.to_f.round(2) &&
16
+ @right_indent.to_f.round(1) == other.right_indent.to_f.round(1)
17
+ return true if @hanging_indent.nil? || other.hanging_indent.nil?
18
+ @hanging_indent.to_f == other.hanging_indent.to_f
19
+ else
20
+ false
21
+ end
22
+ else
23
+ is_a?(NilClass) && other.is_a?(NilClass)
24
+ end
25
+ end
26
+
27
+ def equal_with_round(other, delta = 0.02)
28
+ if is_a?(NilClass) && other.is_a?(NilClass)
29
+ true
30
+ else
31
+ @first_line_indent.to_f.round(2) == other.first_line_indent.to_f.round(2) &&
32
+ @left_indent.to_f.round(2) == other.left_indent.to_f.round(2) &&
33
+ @right_indent.to_f.round(2) == other.right_indent.to_f.round(2) &&
34
+ (@hanging_indent.to_f.round(2) - other.hanging_indent.to_f.round(2)).to_f.abs < delta
35
+ end
36
+ end
37
+
38
+ def to_s
39
+ "first line indent: #{@first_line_indent}, left indent: #{@left_indent},
40
+ right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
41
+ end
42
+
43
+ # Parse hash with indents
44
+ # @return [Indents] parsed class
45
+ def self.parse_indents_hash(hash)
46
+ Indents.new(hash['first_line_indent'], hash['left_indent'], hash['right_indent'], hash['hanging_indent'])
47
+ end
48
+
49
+ # Increases indent, depending on clicks to "increase indent" button in canvas
50
+ # @param [Integer] count count of clicks (default = 1)
51
+ def increase_indent_by_button(count = 1)
52
+ count.times { @left_indent += 1.25 }
53
+ end
54
+
55
+ # @return [Indents
56
+ def copy
57
+ Indents.new(@first_line_indent, @left_indent, @right_indent, @hanging_indent)
58
+ end
59
+
60
+ def round(digits_after_dot = 0)
61
+ [:first_line_indent, :left_indent, :right_indent, :hanging_indent].each do |ind|
62
+ send("#{ind}=", send(ind).round(digits_after_dot)) unless send(ind).nil?
63
+ end
64
+ self
65
+ end
66
+
67
+ # Parse Indents
68
+ # @param [Nokogiri::XML:Element] node with Indents
69
+ # @return [Indents] value of Indents
70
+ def self.parse(node)
71
+ indents = Indents.new
72
+ unless node.attribute('firstLine').nil?
73
+ indents.first_line_indent = (node.attribute('firstLine').value.to_f / 566.9).round(2)
74
+ end
75
+ unless node.attribute('left').nil?
76
+ indents.left_indent = (node.attribute('left').value.to_f / 566.9).round(2)
77
+ end
78
+ unless node.attribute('right').nil?
79
+ indents.right_indent = (node.attribute('right').value.to_f / 566.9).round(2)
80
+ end
81
+ unless node.attribute('hanging').nil?
82
+ indents.hanging_indent = (node.attribute('hanging').value.to_f / 566.9).round(2)
83
+ end
84
+ indents
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,10 @@
1
+ module OoxmlParser
2
+ class Bookmark
3
+ attr_accessor :id, :name
4
+
5
+ def initialize(id = nil, name = nil)
6
+ @id = id
7
+ @name = name
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module OoxmlParser
2
+ class ParagraphTab < OOXMLDocumentObject
3
+ attr_accessor :align, :position
4
+
5
+ def initialize(align, position)
6
+ @align = align
7
+ @position = position
8
+ end
9
+
10
+ def self.parse(tabs_node)
11
+ tabs = []
12
+ tabs_node.xpath('a:tab').each do |tab_node|
13
+ tabs << ParagraphTab.new(Alignment.parse(tab_node.attribute('algn')),
14
+ (tab_node.attribute('pos').value.to_f / 360_000.0).round(2))
15
+ end
16
+ tabs
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ # Style Parameter Data
2
+ module OoxmlParser
3
+ class StyleParametres
4
+ attr_accessor :q_format, :hidden, :name
5
+
6
+ def initialize(name = nil, q_format = false, hidden = false)
7
+ @name = name
8
+ @q_format = q_format
9
+ @hidden = hidden
10
+ end
11
+
12
+ def ==(other)
13
+ all_instance_variables = instance_variables
14
+ all_instance_variables.each do |current_attributes|
15
+ unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
16
+ return false
17
+ end
18
+ end
19
+ true
20
+ end
21
+
22
+ def self.parse(style_tag)
23
+ style = StyleParametres.new
24
+ style_tag.xpath('w:name').each do |name|
25
+ style.name = name.attribute('val').value
26
+ end
27
+ style_tag.xpath('w:qFormat').each do |q_format|
28
+ next if q_format.attribute('val').nil?
29
+ next if q_format.attribute('val').value == false || q_format.attribute('val').value == 'off' || q_format.attribute('val').value == '0'
30
+ style.q_format = true
31
+ end
32
+ style
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,56 @@
1
+ require_relative 'paragraph_style/bookmark'
2
+ require_relative 'paragraph_style/style_parametres'
3
+ require_relative 'paragraph_style/paragraph_tab'
4
+ # Paragraph Style Data
5
+ module OoxmlParser
6
+ class ParagraphStyle
7
+ attr_accessor :name,
8
+ :font_name,
9
+ :font_size,
10
+ :font_style,
11
+ :spacing,
12
+ :indent,
13
+ :borders,
14
+ :background
15
+
16
+ def initialize(style_name = nil, font_name = nil, font_size = nil, font_style = nil, spacing = nil,
17
+ indent = nil, borders = nil, background = nil)
18
+ @name = style_name if style_name
19
+ @font_name = font_name if font_name
20
+ @font_size = font_size if font_size
21
+ @font_style = font_style if font_style
22
+ @spacing = spacing if spacing
23
+ @indent = indent if indent
24
+ @borders = borders if borders
25
+ @background = background if background
26
+ end
27
+
28
+ def string_style_name
29
+ @name.to_s.tr('_', ' ')
30
+ end
31
+
32
+ def self.init_by_name(style_name, object = :docx_paragraph)
33
+ found_style = nil
34
+ AllTestData.paragraph_settings::PARAGRAPH_STYLE_DATA.each do |style|
35
+ found_style = style.clone if style.name == style_name
36
+ end
37
+
38
+ raise "Cannot find this style name - #{style_name}" if found_style.nil?
39
+
40
+ case object
41
+ when :table
42
+ found_style.spacing = Spacing.new(found_style.spacing.before, 0, 1, found_style.spacing.line_rule)
43
+ when :list
44
+ found_style.indent = Indents.new(-0.635, 1.27, 0)
45
+ end
46
+
47
+ found_style
48
+ end
49
+
50
+ def ==(other)
51
+ # FIXME, correct border comparision
52
+ @font_name == other.font_name && @font_size.to_f == other.font_size.to_f && @font_style == other.font_style &&
53
+ @spacing == other.spacing && @indent == other.indent && @background == other.background # && @border == other.border
54
+ end
55
+ end
56
+ end