ooxml_parser 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +55 -48
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/pivot_formats.rb +1 -1
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/plot_area/common_chart_data.rb +1 -1
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/number_string_cache.rb +1 -1
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +6 -10
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +1 -1
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +1 -1
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +4 -6
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +4 -4
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +2 -21
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +51 -4
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +1 -1
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -1
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +1 -1
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -1
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +0 -4
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +0 -4
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +0 -4
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +0 -4
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +0 -4
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +1 -1
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -1
  24. 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 +1 -1
  25. 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 +1 -1
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +1 -1
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -1
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +13 -3
  29. 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 +1 -1
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +10 -3
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +1 -1
  32. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +1 -1
  33. data/lib/ooxml_parser/common_parser/common_data/color.rb +11 -77
  34. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +33 -3
  35. data/lib/ooxml_parser/common_parser/common_data/color/color_indexes.list +66 -0
  36. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +8 -2
  37. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +0 -33
  38. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +1 -1
  39. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +1 -1
  40. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +1 -1
  41. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +1 -1
  42. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +1 -1
  43. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +15 -4
  44. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +5 -1
  45. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +1 -1
  46. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +1 -1
  47. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +1 -1
  48. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +33 -9
  49. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +5 -3
  50. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +1 -1
  51. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +1 -1
  52. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +1 -1
  53. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +1 -1
  54. data/lib/ooxml_parser/common_parser/common_data/relationships.rb +1 -1
  55. data/lib/ooxml_parser/common_parser/common_data/table.rb +1 -1
  56. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +1 -1
  57. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +2 -2
  58. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +1 -1
  59. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -1
  60. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +1 -1
  61. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +2 -0
  62. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/grid_span.rb +1 -7
  63. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +1 -1
  64. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +1 -1
  65. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +1 -1
  66. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +1 -1
  67. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +1 -1
  68. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -3
  69. data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +1 -1
  70. data/lib/ooxml_parser/common_parser/common_document_structure.rb +1 -0
  71. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +15 -7
  72. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb +2 -2
  73. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +1 -1
  74. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb +2 -2
  75. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +1 -1
  76. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +1 -1
  77. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +1 -1
  78. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +5 -9
  79. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +1 -1
  80. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +1 -1
  81. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +1 -1
  82. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +1 -1
  83. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +1 -1
  84. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +1 -1
  85. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +1 -1
  86. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +1 -1
  87. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +1 -1
  88. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +1 -1
  89. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +38 -21
  90. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +1 -1
  91. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +1 -1
  92. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb +1 -1
  93. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +3 -3
  94. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +1 -1
  95. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +5 -8
  96. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +9 -3
  97. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +2 -2
  98. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +1 -1
  99. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +1 -1
  100. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +1 -1
  101. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +4 -1
  102. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +4 -2
  103. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +1 -0
  104. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +1 -1
  105. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +2 -1
  106. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -2
  107. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb +1 -1
  108. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb +1 -1
  109. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -0
  110. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -1
  111. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -3
  112. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +1 -1
  113. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +1 -1
  114. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -2
  115. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +1 -1
  116. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +1 -1
  117. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +1 -1
  118. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +1 -1
  119. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +1 -1
  120. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +1 -1
  121. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition_list.rb +1 -1
  122. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +1 -1
  123. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb +1 -1
  124. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +1 -1
  125. data/lib/ooxml_parser/version.rb +1 -1
  126. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +1 -1
  127. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb +1 -1
  128. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +1 -1
  129. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb +1 -1
  130. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb +5 -5
  131. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +1 -1
  132. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +1 -1
  133. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +1 -1
  134. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +1 -1
  135. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +1 -1
  136. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb +1 -1
  137. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +1 -1
  138. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +1 -1
  139. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/comment_list.rb +1 -1
  140. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +1 -1
  141. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
  142. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +1 -1
  143. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters.rb +1 -1
  144. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +1 -1
  145. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +1 -1
  146. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_columns.rb +1 -1
  147. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +1 -1
  148. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +1 -1
  149. metadata +10 -10
  150. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee9d17ca1564f942a23f3ec27f80e47c92720dcc772f78ce9c05f5b4a083aab4
4
- data.tar.gz: c7aacc7ac67a9e03aab11180a3d0815c985f10e99494e14ddb65dafc0996d722
3
+ metadata.gz: d8e3e91e0a460a222a1b728590f787326cc5dcccbb08ca49609dde048038592a
4
+ data.tar.gz: 75cafd238d3318956e9df7ae7101914d7ab66d7719ecbbb8eac7c6ad620330fd
5
5
  SHA512:
6
- metadata.gz: c9962f8a0a55810dcfe9fccf3f5915059eb1ea89343054fdaefbc835aa8bfdcbd6f492e1684e3944579b90196bf3cde395f34384411f3e8e27fcbb77a89d7e0a
7
- data.tar.gz: c3422025469da1f6a10c385a0b7bb06d499aaa4e8f6c9c897f40b22a4caf0927288bcd9807e9e859b60f1017e5d31e00caba66dfc29b9d928dd156b5f471abd1
6
+ metadata.gz: e6f5ca51269103d59ebb7199dd98dd123dbc6b4a7d007f2a41a08ba7f26f3291433cb5d4188e0218e0d5d87b3066d9e4513b7ce75b3a49b4a74e18252acb465f
7
+ data.tar.gz: a155b362cb64c70a70a367fb99ec499c9b9eb282deeb1451f77a99efecae19a4f549f76178643889011e5dc3831eca2f02ff8cb6b9bbc619a4de3511aa86845c
@@ -38,7 +38,7 @@ module OoxmlParser
38
38
  @legend = nil
39
39
  @axises = []
40
40
  @series = []
41
- @parent = parent
41
+ super
42
42
  end
43
43
 
44
44
  # Parse properties of Chart
@@ -74,94 +74,101 @@ module OoxmlParser
74
74
  extend Gem::Deprecate
75
75
  deprecate :data, 'series points interface', 2020, 1
76
76
 
77
- # Parse Chart
78
- # @param parent [OOOXMLDocumentObject] parent of chart
77
+ # Parse Chart data
79
78
  # @return [Chart] result of parsing
80
- def self.parse(parent: nil)
81
- chart = Chart.new(parent: parent)
82
- chart_xml = chart.parse_xml(OOXMLDocumentObject.current_xml)
79
+ def parse
80
+ chart_xml = parse_xml(OOXMLDocumentObject.current_xml)
83
81
  chart_xml.xpath('*').each do |chart_node|
84
82
  case chart_node.name
85
83
  when 'chartSpace'
86
84
  chart_node.xpath('*').each do |chart_space_node_child|
87
85
  case chart_space_node_child.name
88
86
  when 'AlternateContent'
89
- chart.alternate_content = AlternateContent.new(parent: chart).parse(chart_space_node_child)
87
+ @alternate_content = AlternateContent.new(parent: self).parse(chart_space_node_child)
90
88
  when 'spPr'
91
- chart.shape_properties = DocxShapeProperties.new(parent: chart).parse(chart_space_node_child)
89
+ @shape_properties = DocxShapeProperties.new(parent: self).parse(chart_space_node_child)
92
90
  when 'chart'
93
91
  chart_space_node_child.xpath('*').each do |chart_node_child|
94
92
  case chart_node_child.name
95
93
  when 'plotArea'
96
94
  chart_node_child.xpath('*').each do |plot_area_node_child|
97
- next unless chart.type.empty?
95
+ next unless type.empty?
98
96
 
99
97
  case plot_area_node_child.name
100
98
  when 'barChart'
101
- chart.type = :bar
99
+ @type = :bar
102
100
  bar_dir_node = plot_area_node_child.xpath('c:barDir')
103
- chart.type = :column if bar_dir_node.first.attribute('val').value == 'col'
104
- chart.parse_properties(plot_area_node_child)
101
+ @type = :column if bar_dir_node.first.attribute('val').value == 'col'
102
+ parse_properties(plot_area_node_child)
105
103
  when 'lineChart'
106
- chart.type = :line
107
- chart.parse_properties(plot_area_node_child)
104
+ @type = :line
105
+ parse_properties(plot_area_node_child)
108
106
  when 'areaChart'
109
- chart.type = :area
110
- chart.parse_properties(plot_area_node_child)
107
+ @type = :area
108
+ parse_properties(plot_area_node_child)
111
109
  when 'bubbleChart'
112
- chart.type = :bubble
113
- chart.parse_properties(plot_area_node_child)
110
+ @type = :bubble
111
+ parse_properties(plot_area_node_child)
114
112
  when 'doughnutChart'
115
- chart.type = :doughnut
116
- chart.parse_properties(plot_area_node_child)
113
+ @type = :doughnut
114
+ parse_properties(plot_area_node_child)
117
115
  when 'pieChart'
118
- chart.type = :pie
119
- chart.parse_properties(plot_area_node_child)
116
+ @type = :pie
117
+ parse_properties(plot_area_node_child)
120
118
  when 'scatterChart'
121
- chart.type = :point
122
- chart.parse_properties(plot_area_node_child)
119
+ @type = :point
120
+ parse_properties(plot_area_node_child)
123
121
  when 'radarChart'
124
- chart.type = :radar
125
- chart.parse_properties(plot_area_node_child)
122
+ @type = :radar
123
+ parse_properties(plot_area_node_child)
126
124
  when 'stockChart'
127
- chart.type = :stock
128
- chart.parse_properties(plot_area_node_child)
125
+ @type = :stock
126
+ parse_properties(plot_area_node_child)
129
127
  when 'surface3DChart'
130
- chart.type = :surface_3d
131
- chart.parse_properties(plot_area_node_child)
128
+ @type = :surface_3d
129
+ parse_properties(plot_area_node_child)
132
130
  when 'line3DChart'
133
- chart.type = :line_3d
134
- chart.parse_properties(plot_area_node_child)
131
+ @type = :line_3d
132
+ parse_properties(plot_area_node_child)
135
133
  when 'bar3DChart'
136
- chart.type = :bar_3d
137
- chart.parse_properties(plot_area_node_child)
134
+ @type = :bar_3d
135
+ parse_properties(plot_area_node_child)
138
136
  when 'pie3DChart'
139
- chart.type = :pie_3d
140
- chart.parse_properties(plot_area_node_child)
137
+ @type = :pie_3d
138
+ parse_properties(plot_area_node_child)
141
139
  end
142
140
  end
143
- chart_node_child.xpath('*').each do |plot_area_node_child|
144
- case plot_area_node_child.name
145
- when 'catAx', 'valAx'
146
- chart.axises << ChartAxis.new(parent: chart).parse(plot_area_node_child)
147
- end
148
- end
149
- chart.plot_area = PlotArea.new(parent: chart).parse(chart_node_child)
141
+ parse_axis(chart_node_child)
142
+ @plot_area = PlotArea.new(parent: self).parse(chart_node_child)
150
143
  when 'title'
151
- chart.title = ChartAxisTitle.new(parent: chart).parse(chart_node_child)
144
+ @title = ChartAxisTitle.new(parent: self).parse(chart_node_child)
152
145
  when 'legend'
153
- chart.legend = ChartLegend.new(parent: chart).parse(chart_node_child)
146
+ @legend = ChartLegend.new(parent: self).parse(chart_node_child)
154
147
  when 'view3D'
155
- chart.view_3d = View3D.new(parent: chart).parse(chart_node_child)
148
+ @view_3d = View3D.new(parent: self).parse(chart_node_child)
156
149
  when 'pivotFmts'
157
- chart.pivot_formats = PivotFormats.new(parent: chart).parse(chart_node_child)
150
+ @pivot_formats = PivotFormats.new(parent: self).parse(chart_node_child)
158
151
  end
159
152
  end
160
153
  end
161
154
  end
162
155
  end
163
156
  end
164
- chart
157
+ self
158
+ end
159
+
160
+ private
161
+
162
+ # Perform parsing of axis info
163
+ # @param node [Nokogiri::XML:Element] node to parse
164
+ # @return [void]
165
+ def parse_axis(node)
166
+ node.xpath('*').each do |node_child|
167
+ case node_child.name
168
+ when 'catAx', 'valAx'
169
+ @axises << ChartAxis.new(parent: self).parse(node_child)
170
+ end
171
+ end
165
172
  end
166
173
  end
167
174
  end
@@ -8,8 +8,8 @@ module OoxmlParser
8
8
  attr_reader :pivot_formats_list
9
9
 
10
10
  def initialize(parent: nil)
11
- @parent = parent
12
11
  @pivot_formats_list = []
12
+ super
13
13
  end
14
14
 
15
15
  # @return [Array, PivotFormat] accessor
@@ -10,7 +10,7 @@ module OoxmlParser
10
10
 
11
11
  def initialize(parent: nil)
12
12
  @series = []
13
- @parent = parent
13
+ super
14
14
  end
15
15
 
16
16
  # Parse CommonChartData object
@@ -13,7 +13,7 @@ module OoxmlParser
13
13
 
14
14
  def initialize(parent: nil)
15
15
  @points = []
16
- @parent = parent
16
+ super
17
17
  end
18
18
 
19
19
  # Parse Order
@@ -11,16 +11,12 @@ module OoxmlParser
11
11
  # @return [ValuedChild] the position of the tick labels
12
12
  attr_reader :tick_label_position
13
13
 
14
- def initialize(title = ChartAxisTitle.new,
15
- display = true,
16
- major_grid_lines = false,
17
- minor_grid_lines = false,
18
- parent: nil)
19
- @title = title
20
- @display = display
21
- @minor_grid_lines = minor_grid_lines
22
- @major_grid_lines = major_grid_lines
23
- @parent = parent
14
+ def initialize(params = {})
15
+ @title = params.fetch(:title, ChartAxisTitle.new)
16
+ @display = params.fetch(:display, true)
17
+ @minor_grid_lines = params.fetch(:minor_grid_lines, false)
18
+ @major_grid_lines = params.fetch(:major_grid_lines, false)
19
+ super(parent: params[:parent])
24
20
  end
25
21
 
26
22
  # Parse ChartAxis object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @elements = []
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # @return [Boolean] if chart title is visible
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
  def initialize(parent: nil)
9
9
  @list = ''
10
10
  @points = []
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse ChartCellsRange object
@@ -5,12 +5,10 @@ module OoxmlParser
5
5
  class ChartLegend < OOXMLDocumentObject
6
6
  attr_accessor :position, :overlay
7
7
 
8
- def initialize(position = :right,
9
- overlay = false,
10
- parent: nil)
11
- @position = position
12
- @overlay = overlay
13
- @parent = parent
8
+ def initialize(params = {})
9
+ @position = params.fetch(:position, :right)
10
+ @overlay = params.fetch(:overlay, false)
11
+ super(parent: params[:parent])
14
12
  end
15
13
 
16
14
  # Return combined data from @position and @overlay
@@ -11,10 +11,10 @@ module OoxmlParser
11
11
  # @return [True, False] is label is deleted
12
12
  attr_reader :delete
13
13
 
14
- def initialize(show_legend_key = false, show_values = false, parent: nil)
15
- @show_legend_key = show_legend_key
16
- @show_values = show_values
17
- @parent = parent
14
+ def initialize(params = {})
15
+ @show_legend_key = params.fetch(:show_legend_key, false)
16
+ @show_values = params.fetch(:show_values, false)
17
+ super(parent: params[:parent])
18
18
  end
19
19
 
20
20
  # Parse DisplayLabelsProperties object
@@ -16,7 +16,7 @@ module OoxmlParser
16
16
 
17
17
  def initialize(properties = DocxDrawingProperties.new, parent: nil)
18
18
  @properties = properties
19
- @parent = parent
19
+ super(parent: parent)
20
20
  end
21
21
 
22
22
  # Parse DocxDrawing
@@ -30,34 +30,15 @@ module OoxmlParser
30
30
  when 'inline'
31
31
  @type = :inline
32
32
  end
33
- @properties.distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
34
- @properties.wrap = DocxWrapDrawing.new(parent: self).parse(node_child)
35
- node_child.attributes.each do |key, value|
36
- case key
37
- when 'relativeHeight'
38
- @properties.relative_height = value.value.to_i
39
- end
40
- end
41
33
  node_child.xpath('*').each do |content_node_child|
42
34
  case content_node_child.name
43
- when 'simplePos'
44
- @properties.simple_position = OOXMLCoordinates.parse(content_node_child)
45
- when 'extent'
46
- @properties.object_size = OOXMLCoordinates.parse(content_node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
47
35
  when 'graphic'
48
36
  @graphic = DocxGraphic.new(parent: self).parse(content_node_child)
49
- when 'positionV'
50
- @properties.vertical_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
51
- when 'positionH'
52
- @properties.horizontal_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
53
- when 'sizeRelH'
54
- @properties.size_relative_horizontal = SizeRelativeHorizontal.new(parent: self).parse(content_node_child)
55
- when 'sizeRelV'
56
- @properties.size_relative_vertical = SizeRelativeVertical.new(parent: self).parse(content_node_child)
57
37
  when 'docPr'
58
38
  @doc_properties = DocProperties.new(parent: self).parse(content_node_child)
59
39
  end
60
40
  end
41
+ @properties.parse(node_child)
61
42
  end
62
43
  self
63
44
  end
@@ -8,9 +8,56 @@ require_relative 'docx_wrap_drawing'
8
8
  module OoxmlParser
9
9
  # Docx Drawing Properties
10
10
  class DocxDrawingProperties < OOXMLDocumentObject
11
- attr_accessor :distance_from_text, :simple_position, :wrap, :object_size, :vertical_position, :horizontal_position,
12
- :relative_height
13
- attr_accessor :size_relative_horizontal
14
- attr_accessor :size_relative_vertical
11
+ # @return [DocxDrawingDistanceFromText] distance from text
12
+ attr_reader :distance_from_text
13
+ # @return [DocxWrapDrawing] wrap of drawing
14
+ attr_reader :wrap
15
+ # @return [Integer] relative height of object
16
+ attr_reader :relative_height
17
+ # @return [OOXMLCoordinates] simple position of object
18
+ attr_reader :simple_position
19
+ # @return [OOXMLCoordinates] size of object
20
+ attr_reader :object_size
21
+ # @return [DocxDrawingPosition] vertical position
22
+ attr_reader :vertical_position
23
+ # @return [DocxDrawingPosition] horizontal position
24
+ attr_reader :horizontal_position
25
+ # @return [SizeRelativeHorizontal] size of drawing relative to horizontal
26
+ attr_reader :size_relative_horizontal
27
+ # @return [SizeRelativeVertical] size of drawing relative to vertical
28
+ attr_reader :size_relative_vertical
29
+
30
+ # Parse DocxDrawingProperties
31
+ # @param [Nokogiri::XML:Node] node with DocxDrawingProperties
32
+ # @return [DocxDrawingProperties] result of parsing
33
+ def parse(node)
34
+ @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node)
35
+ @wrap = DocxWrapDrawing.new(parent: self).parse(node)
36
+
37
+ node.attributes.each do |key, value|
38
+ case key
39
+ when 'relativeHeight'
40
+ @relative_height = value.value.to_i
41
+ end
42
+ end
43
+
44
+ node.xpath('*').each do |content_node_child|
45
+ case content_node_child.name
46
+ when 'simplePos'
47
+ @simple_position = OOXMLCoordinates.parse(content_node_child)
48
+ when 'extent'
49
+ @object_size = OOXMLCoordinates.parse(content_node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
50
+ when 'positionV'
51
+ @vertical_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
52
+ when 'positionH'
53
+ @horizontal_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
54
+ when 'sizeRelH'
55
+ @size_relative_horizontal = SizeRelativeHorizontal.new(parent: self).parse(content_node_child)
56
+ when 'sizeRelV'
57
+ @size_relative_vertical = SizeRelativeVertical.new(parent: self).parse(content_node_child)
58
+ end
59
+ end
60
+ self
61
+ end
15
62
  end
16
63
  end
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @wrap_text = :none
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse DocxWrapDrawing object
@@ -20,7 +20,7 @@ module OoxmlParser
20
20
 
21
21
  # @return [String] result of convert of object to string
22
22
  def to_s
23
- '(' + @x.to_s + '; ' + @y.to_s + ')'
23
+ "(#{@x}; #{@y})"
24
24
  end
25
25
 
26
26
  # Compare two OOXMLCoordinates objects
@@ -24,7 +24,7 @@ module OoxmlParser
24
24
  when 'chart'
25
25
  @type = :chart
26
26
  OOXMLDocumentObject.add_to_xmls_stack("#{OOXMLDocumentObject.root_subfolder}/#{OOXMLDocumentObject.get_link_from_rels(node_child.attribute('id').value)}")
27
- @data = Chart.parse(parent: self)
27
+ @data = Chart.new(parent: self).parse
28
28
  OOXMLDocumentObject.xmls_stack.pop
29
29
  when 'wgp'
30
30
  @type = :group
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @elements = []
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse OOXMLTextBox object
@@ -16,10 +16,6 @@ module OoxmlParser
16
16
  # @return [LineReference] line reference
17
17
  attr_reader :line_reference
18
18
 
19
- def initialize(parent: nil)
20
- @parent = parent
21
- end
22
-
23
19
  # Parse ShapeStyle object
24
20
  # @param node [Nokogiri::XML:Element] node to parse
25
21
  # @return [ShapeStyle] result of parsing
@@ -8,10 +8,6 @@ module OoxmlParser
8
8
  # @return [Color] scheme color of EffectReference
9
9
  attr_reader :scheme_color
10
10
 
11
- def initialize(parent: nil)
12
- @parent = parent
13
- end
14
-
15
11
  # Parse EffectReference object
16
12
  # @param node [Nokogiri::XML:Element] node to parse
17
13
  # @return [EffectReference] result of parsing
@@ -8,10 +8,6 @@ module OoxmlParser
8
8
  # @return [Color] scheme color of FillReference
9
9
  attr_reader :scheme_color
10
10
 
11
- def initialize(parent: nil)
12
- @parent = parent
13
- end
14
-
15
11
  # Parse FillReference object
16
12
  # @param node [Nokogiri::XML:Element] node to parse
17
13
  # @return [FillReference] result of parsing