ooxml_parser 0.7.1 → 0.9.1

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 +31 -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 -5
  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 +9 -9
  150. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
@@ -18,12 +18,23 @@ module OoxmlParser
18
18
  class DocumentStructure < CommonDocumentStructure
19
19
  include DocumentStyleHelper
20
20
  include DocumentStructureHelpers
21
- attr_accessor :elements, :page_properties, :notes, :background, :document_properties, :comments
22
-
21
+ # @return [Array<OOXMLDocumentObject>] list of elements
22
+ attr_accessor :elements
23
+ # @return [PageProperties] properties of document
24
+ attr_accessor :page_properties
25
+ # @return [Note] notes of document
26
+ attr_accessor :notes
27
+ # @return [DocumentBackground] background of document
28
+ attr_accessor :background
29
+ # @return [DocumentProperties] properties of document
30
+ attr_accessor :document_properties
31
+ # @return [Comments] comment of document
32
+ attr_accessor :comments
23
33
  # @return [Numbering] store numbering data
24
34
  attr_accessor :numbering
25
35
  # @return [Styles] styles of document
26
36
  attr_accessor :styles
37
+ # @return [PresentationTheme] theme of docx
27
38
  attr_accessor :theme
28
39
  # @return [Relationships] relationships
29
40
  attr_accessor :relationships
@@ -206,7 +217,7 @@ module OoxmlParser
206
217
  # Parse default style
207
218
  # @return [void]
208
219
  def parse_default_style
209
- doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
220
+ doc = parse_xml("#{OOXMLDocumentObject.path_to_folder}word/styles.xml")
210
221
  doc.search('//w:style').each do |style|
211
222
  next if style.attribute('default').nil?
212
223
 
@@ -273,10 +284,7 @@ module OoxmlParser
273
284
  end
274
285
 
275
286
  class << self
276
- attr_accessor :default_table_run_style
277
- attr_accessor :default_table_paragraph_style
278
- attr_accessor :default_paragraph_style
279
- attr_accessor :default_run_style
287
+ attr_accessor :default_table_run_style, :default_table_paragraph_style, :default_paragraph_style, :default_run_style
280
288
  end
281
289
  end
282
290
  end
@@ -9,8 +9,8 @@ module OoxmlParser
9
9
 
10
10
  def initialize(params = {})
11
11
  @comments_array = []
12
- @parent = params[:parent]
13
- @file = params.fetch(:file, OOXMLDocumentObject.path_to_folder + 'word/comments.xml')
12
+ @file = params.fetch(:file, "#{OOXMLDocumentObject.path_to_folder}word/comments.xml")
13
+ super(parent: params[:parent])
14
14
  end
15
15
 
16
16
  # @return [Comment] accessor
@@ -11,7 +11,7 @@ module OoxmlParser
11
11
  def initialize(id = nil, paragraphs = [], parent: nil)
12
12
  @id = id
13
13
  @paragraphs = paragraphs
14
- @parent = parent
14
+ super(parent: parent)
15
15
  end
16
16
 
17
17
  # Parse Comment object
@@ -6,7 +6,7 @@ module OoxmlParser
6
6
  class CommentsExtended < OOXMLDocumentObject
7
7
  def initialize(parent: nil)
8
8
  @comments_extended_array = []
9
- @parent = parent
9
+ super
10
10
  end
11
11
 
12
12
  # @return [Array, CommentsExtended] accessor
@@ -17,7 +17,7 @@ module OoxmlParser
17
17
  # Parse CommentsExtended object
18
18
  # @return [CommentsExtended] result of parsing
19
19
  def parse
20
- file_to_parse = OOXMLDocumentObject.path_to_folder + 'word/commentsExtended.xml'
20
+ file_to_parse = "#{OOXMLDocumentObject.path_to_folder}word/commentsExtended.xml"
21
21
  return nil unless File.exist?(file_to_parse)
22
22
 
23
23
  doc = parse_xml(file_to_parse)
@@ -12,7 +12,7 @@ module OoxmlParser
12
12
  def initialize(parent: nil)
13
13
  @color1 = nil
14
14
  @type = 'simple'
15
- @parent = parent
15
+ super
16
16
  end
17
17
 
18
18
  # Parse DocumentBackground object
@@ -9,7 +9,7 @@ module OoxmlParser
9
9
  # Parse Settings object
10
10
  # @return [DocumentSettings] result of parsing
11
11
  def parse
12
- settings_path = OOXMLDocumentObject.path_to_folder + 'word/settings.xml'
12
+ settings_path = "#{OOXMLDocumentObject.path_to_folder}word/settings.xml"
13
13
  return nil unless File.exist?(settings_path)
14
14
 
15
15
  doc = parse_xml(settings_path)
@@ -41,7 +41,7 @@ module OoxmlParser
41
41
  def initialize(parent: nil)
42
42
  @q_format = false
43
43
  @table_style_properties_list = []
44
- @parent = parent
44
+ super
45
45
  end
46
46
 
47
47
  # @return [String] result of convert of object to string
@@ -52,7 +52,7 @@ module OoxmlParser
52
52
  @page_numbering = false
53
53
  @keep_next = false
54
54
  @orphan_control = true
55
- @parent = parent
55
+ super
56
56
  end
57
57
 
58
58
  alias elements character_style_array
@@ -71,14 +71,10 @@ module OoxmlParser
71
71
  # @return [Array<OOXMLDocumentObject>] array of child objects that contains data
72
72
  def nonempty_runs
73
73
  @character_style_array.select do |cur_run|
74
- if cur_run.is_a?(DocxParagraphRun) || cur_run.is_a?(ParagraphRun)
74
+ case cur_run
75
+ when DocxParagraphRun, ParagraphRun
75
76
  !cur_run.empty?
76
- elsif cur_run.is_a?(DocxFormula) ||
77
- cur_run.is_a?(StructuredDocumentTag) ||
78
- cur_run.is_a?(BookmarkStart) ||
79
- cur_run.is_a?(BookmarkEnd) ||
80
- cur_run.is_a?(CommentRangeStart) ||
81
- cur_run.is_a?(CommentRangeEnd)
77
+ when DocxFormula, StructuredDocumentTag, BookmarkStart, BookmarkEnd, CommentRangeStart, CommentRangeEnd
82
78
  true
83
79
  end
84
80
  end
@@ -251,7 +247,7 @@ module OoxmlParser
251
247
  # @param character_style [DocxParagraphRun] style to parse
252
248
  # @return [void]
253
249
  def parse_paragraph_style_xml(id, character_style)
254
- doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
250
+ doc = parse_xml("#{OOXMLDocumentObject.path_to_folder}word/styles.xml")
255
251
  doc.search('//w:style').each do |style|
256
252
  next unless style.attribute('styleId').value == id
257
253
 
@@ -24,7 +24,7 @@ module OoxmlParser
24
24
 
25
25
  def initialize(parent: nil)
26
26
  @formula_run = []
27
- @parent = parent
27
+ super
28
28
  end
29
29
 
30
30
  # Parse DocxFormula object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @position = :bottom
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse Bar object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @borders = false
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse Box object
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
  def initialize(parent: nil)
9
9
  @begin_character = '('
10
10
  @end_character = ')'
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse Delimiter object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @type = :upper
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse Limit object
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
 
9
9
  def initialize(parent: nil)
10
10
  @break = false
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse MathRunProperties
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
 
9
9
  def initialize(parent: nil)
10
10
  @rows = []
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse Matrix object
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(columns_count = 1, parent: nil)
9
9
  @columns = Array.new(columns_count)
10
- @parent = parent
10
+ super(parent: parent)
11
11
  end
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ module OoxmlParser
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @degree = 2
10
- @parent = parent
10
+ super
11
11
  end
12
12
 
13
13
  # Parse Radical object
@@ -38,7 +38,7 @@ module OoxmlParser
38
38
  @break = false
39
39
  @comments = []
40
40
  @page_number = false
41
- @parent = parent
41
+ super
42
42
  end
43
43
 
44
44
  # Constructor for copy of object
@@ -51,33 +51,14 @@ module OoxmlParser
51
51
  when 'smallCaps'
52
52
  self.caps = :small_caps if option_enabled?(node_child)
53
53
  when 'color'
54
- node_child.attributes.each do |key, value|
55
- case key
56
- when 'val'
57
- self.font_color = Color.new(parent: self).parse_hex_string(value.value)
58
- when 'themeColor'
59
- if root_object.theme && root_object.theme.color_scheme[value.value.to_sym]
60
- break if value.value == 'text2' || value.value == 'background2' || value.value.include?('accent') # Don't know why. Just works
61
-
62
- self.font_color = root_object.theme.color_scheme[value.value.to_sym].color.dup
63
- end
64
- when 'themeShade'
65
- font_color.calculate_with_shade!(value.value.hex.to_f / 255.0)
66
- when 'themeTint'
67
- font_color.calculate_with_tint!(1.0 - (value.value.hex.to_f / 255.0))
68
- end
69
- end
54
+ parse_color_tag(node_child)
70
55
  when 'shd'
71
56
  self.background_color = node_child.attribute('fill').value
72
57
  unless node_child.attribute('fill').value == 'auto' || node_child.attribute('fill').value == '' || node_child.attribute('fill').value == 'null'
73
58
  self.background_color = Color.new(parent: self).parse_hex_string(node_child.attribute('fill').value)
74
59
  end
75
60
  when 'u', 'uCs'
76
- font_style.underlined = Underline.new
77
- if option_enabled?(node_child)
78
- font_style.underlined.style = node_child.attribute('val').value
79
- font_style.underlined.color = Color.new(parent: font_style.underlined).parse_hex_string(node_child.attribute('color').value) unless node_child.attribute('color').nil?
80
- end
61
+ parse_underline(node_child)
81
62
  when 'strike'
82
63
  font_style.strike = :single if option_enabled?(node_child)
83
64
  when 'dstrike'
@@ -86,5 +67,41 @@ module OoxmlParser
86
67
  end
87
68
  self
88
69
  end
70
+
71
+ private
72
+
73
+ # Parse `color` tag
74
+ # @param node [Nokogiri::XML:Element] node to parse
75
+ # @return [nil]
76
+ def parse_color_tag(node)
77
+ node.attributes.each do |key, value|
78
+ case key
79
+ when 'val'
80
+ self.font_color = Color.new(parent: self).parse_hex_string(value.value)
81
+ when 'themeColor'
82
+ if root_object.theme && root_object.theme.color_scheme[value.value.to_sym]
83
+ break if value.value == 'text2' || value.value == 'background2' || value.value.include?('accent') # Don't know why. Just works
84
+
85
+ self.font_color = root_object.theme.color_scheme[value.value.to_sym].color.dup
86
+ end
87
+ when 'themeShade'
88
+ font_color.calculate_with_shade!(value.value.hex.to_f / 255.0)
89
+ when 'themeTint'
90
+ font_color.calculate_with_tint!(1.0 - (value.value.hex.to_f / 255.0))
91
+ end
92
+ end
93
+ end
94
+
95
+ # Parse `u` or `uCs` tag
96
+ # @param node [Nokogiri::XML:Element] node to parse
97
+ # @return [nil]
98
+ def parse_underline(node)
99
+ font_style.underlined = Underline.new
100
+
101
+ return unless option_enabled?(node)
102
+
103
+ font_style.underlined.style = node.attribute('val').value
104
+ font_style.underlined.color = Color.new(parent: font_style.underlined).parse_hex_string(node.attribute('color').value) unless node.attribute('color').nil?
105
+ end
89
106
  end
90
107
  end
@@ -13,7 +13,7 @@ module OoxmlParser
13
13
  @type = type
14
14
  @properties = properties
15
15
  @elements = elements
16
- @parent = parent
16
+ super(parent: parent)
17
17
  end
18
18
 
19
19
  # Parse Shape object
@@ -9,7 +9,7 @@ module OoxmlParser
9
9
  def initialize(parent: nil)
10
10
  @width = OoxmlSize.new(0)
11
11
  @color_scheme = :none
12
- @parent = parent
12
+ super
13
13
  end
14
14
 
15
15
  # Parse TextOutline object
@@ -10,7 +10,7 @@ module OoxmlParser
10
10
 
11
11
  def initialize(parent: nil)
12
12
  @runs = []
13
- @parent = parent
13
+ super
14
14
  end
15
15
 
16
16
  # Parse FieldSimple object
@@ -14,7 +14,7 @@ module OoxmlParser
14
14
  @left_indent = left_indent
15
15
  @right_indent = right_indent
16
16
  @hanging_indent = hanging_indent
17
- @parent = parent
17
+ super(parent: parent)
18
18
  end
19
19
 
20
20
  alias first_line first_line_indent
@@ -25,8 +25,8 @@ module OoxmlParser
25
25
  # Convert to string
26
26
  # @return [String] result of conversion
27
27
  def to_s
28
- "first line indent: #{@first_line_indent}, left indent: #{@left_indent},
29
- right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
28
+ "first line indent: #{@first_line_indent}, left indent: #{@left_indent}, "\
29
+ "right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
30
30
  end
31
31
 
32
32
  # Parse Indents
@@ -8,7 +8,7 @@ module OoxmlParser
8
8
 
9
9
  def initialize(parent: nil)
10
10
  @elements = []
11
- @parent = parent
11
+ super
12
12
  end
13
13
 
14
14
  # Parse SDTContent object
@@ -5,14 +5,11 @@ module OoxmlParser
5
5
  class StyleParametres < OOXMLDocumentObject
6
6
  attr_accessor :q_format, :hidden, :name
7
7
 
8
- def initialize(name = nil,
9
- q_format = false,
10
- hidden = false,
11
- parent: nil)
12
- @name = name
13
- @q_format = q_format
14
- @hidden = hidden
15
- @parent = parent
8
+ def initialize(params = {})
9
+ @name = params[:name]
10
+ @q_format = params.fetch(:q_format, false)
11
+ @hidden = params.fetch(:hidden, false)
12
+ super(parent: params[:parent])
16
13
  end
17
14
 
18
15
  # Parse StyleParametres data
@@ -3,13 +3,19 @@
3
3
  module OoxmlParser
4
4
  # Class Header Footer classes
5
5
  class HeaderFooter < OOXMLDocumentObject
6
- attr_accessor :id, :elements, :type
7
- attr_accessor :path_suffix
6
+ # @return [Integer] id of header-footer
7
+ attr_reader :id
8
+ # @return [Array<OOXMLDocumentObject>] list of elements if object
9
+ attr_reader :elements
10
+ # @return [Symbol] `:header` or `:footer`
11
+ attr_reader :type
12
+ # @return [String] suffix for object files
13
+ attr_reader :path_suffix
8
14
 
9
15
  def initialize(type = :header, parent: nil)
10
16
  @type = type
11
17
  @elements = []
12
- @parent = parent
18
+ super(parent: parent)
13
19
  end
14
20
 
15
21
  # @return [String] string for search of xpath
@@ -14,7 +14,7 @@ module OoxmlParser
14
14
  def initialize(parent: nil)
15
15
  @abstract_numbering_list = []
16
16
  @numbering_definition_list = []
17
- @parent = parent
17
+ super
18
18
  end
19
19
 
20
20
  # Get properties by number id
@@ -38,7 +38,7 @@ module OoxmlParser
38
38
  # Parse Numbering data
39
39
  # @return [Numbering] result of parse
40
40
  def parse
41
- numbering_xml = OOXMLDocumentObject.path_to_folder + 'word/numbering.xml'
41
+ numbering_xml = "#{OOXMLDocumentObject.path_to_folder}word/numbering.xml"
42
42
  return nil unless File.exist?(numbering_xml)
43
43
 
44
44
  node = parse_xml(File.open(numbering_xml))