ooxml_parser 0.5.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser.rb +1 -0
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice.rb +1 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text.rb +1 -0
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text/math_paragraph.rb +1 -0
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +6 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +2 -2
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +0 -2
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +4 -1
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +1 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +4 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +0 -2
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +3 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -3
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +42 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +35 -0
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +35 -0
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +35 -0
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +35 -0
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -0
  23. 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 +0 -2
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -3
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +1 -3
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +1 -3
  28. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +3 -0
  29. data/lib/ooxml_parser/common_parser/common_data/color.rb +39 -7
  30. data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
  31. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +11 -0
  32. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +1 -0
  33. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +4 -0
  34. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +2 -0
  35. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_default.rb +3 -0
  36. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_override.rb +3 -0
  37. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +7 -0
  38. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +24 -2
  39. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +3 -0
  40. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +0 -6
  41. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +2 -0
  42. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +1 -0
  43. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +16 -13
  44. data/lib/ooxml_parser/common_parser/common_data/table.rb +2 -0
  45. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +3 -0
  46. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +7 -0
  47. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +1 -0
  48. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -0
  49. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +4 -4
  50. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -5
  51. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +6 -0
  52. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +3 -0
  53. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -0
  54. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +27 -3
  55. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +3 -0
  56. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +3 -0
  57. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +22 -1
  58. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_end.rb +1 -1
  59. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/comment_range_start.rb +1 -0
  60. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +3 -0
  61. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +13 -3
  62. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +4 -1
  63. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +0 -2
  64. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +3 -0
  65. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +2 -0
  66. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +0 -2
  67. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +5 -0
  68. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +1 -0
  69. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +3 -0
  70. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +1 -0
  71. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -0
  72. data/lib/ooxml_parser/docx_parser/docx_parser.rb +3 -0
  73. data/lib/ooxml_parser/name.rb +1 -0
  74. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +2 -0
  75. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +3 -0
  76. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +3 -0
  77. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -0
  78. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +3 -0
  79. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +15 -1
  80. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +3 -0
  81. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +3 -0
  82. data/lib/ooxml_parser/version.rb +2 -1
  83. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +21 -2
  84. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +3 -0
  85. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb +41 -0
  86. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +37 -0
  87. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb +33 -0
  88. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb +26 -0
  89. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +2 -0
  90. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
  91. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +2 -0
  92. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +3 -0
  93. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
  94. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +4 -0
  95. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +4 -0
  96. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +3 -0
  97. metadata +69 -4
@@ -10,6 +10,7 @@ module OoxmlParser
10
10
  @parent = parent
11
11
  end
12
12
 
13
+ # @return [AbstractNumbering] AbstractNumbering of current properties
13
14
  def abstruct_numbering
14
15
  root_object.numbering.properties_by_num_id(@numbering_properties)
15
16
  end
@@ -29,6 +30,7 @@ module OoxmlParser
29
30
  self
30
31
  end
31
32
 
33
+ # @return [AbstractNumbering] level list of current numbering
32
34
  def numbering_level_current
33
35
  abstruct_numbering.level_list.each do |current_ilvl|
34
36
  return current_ilvl if current_ilvl.ilvl == @ilvl
@@ -16,6 +16,7 @@ module OoxmlParser
16
16
  # @return [BordersProperties] bar properties
17
17
  attr_accessor :bar
18
18
 
19
+ # @return [Symbol] type of border in visual editor
19
20
  def border_visual_type
20
21
  result = []
21
22
  result << :left if @left.val == :single
@@ -24,28 +24,26 @@ module OoxmlParser
24
24
  @line_rule = line_rule
25
25
  end
26
26
 
27
+ # Compare this object to other
28
+ # @param other [Object] any other object
29
+ # @return [True, False] result of comparision
27
30
  def ==(other)
28
31
  self.line_rule = :at_least if line_rule == 'atLeast'
29
32
  self.line_rule = :multiple if line_rule == :auto
30
33
  other.line_rule = :multiple if other.line_rule == :auto
31
- if self.class == NilClass || other.class == NilClass
32
- return true if self.class == NilClass && other.class == NilClass
34
+ self.line_rule = line_rule.to_sym if line_rule.instance_of?(String)
33
35
 
34
- false
36
+ if @before == other.before &&
37
+ @after == other.after &&
38
+ @line == other.line &&
39
+ @line_rule.to_s == other.line_rule.to_s
40
+ true
35
41
  else
36
- self.line_rule = line_rule.to_sym if line_rule.instance_of?(String)
37
-
38
- if @before == other.before &&
39
- @after == other.after &&
40
- @line == other.line &&
41
- @line_rule.to_s == other.line_rule.to_s
42
- true
43
- else
44
- false
45
- end
42
+ false
46
43
  end
47
44
  end
48
45
 
46
+ # @return [String] result of convert of object to string
49
47
  def to_s
50
48
  result_string = ''
51
49
  variables = instance_variables
@@ -55,10 +53,15 @@ module OoxmlParser
55
53
  result_string
56
54
  end
57
55
 
56
+ # Method to copy object
57
+ # @return [Spacing] copied object
58
58
  def copy
59
59
  Spacing.new(@before, @after, @line, @line_rule)
60
60
  end
61
61
 
62
+ # Round value of spacing
63
+ # @param count_of_digits [Integer] how digits to left
64
+ # @return [Spacing] result of round
62
65
  def round(count_of_digits = 1)
63
66
  before = @before.to_f.round(count_of_digits)
64
67
  after = @after.to_f.round(count_of_digits)
@@ -17,10 +17,12 @@ module OoxmlParser
17
17
 
18
18
  alias table_properties properties
19
19
 
20
+ # @return [String] result of convert of object to string
20
21
  def to_s
21
22
  "Rows: #{@rows.join(',')}"
22
23
  end
23
24
 
25
+ # @return [String] inspect of object for debug means
24
26
  def inspect
25
27
  to_s
26
28
  end
@@ -15,6 +15,9 @@ module OoxmlParser
15
15
  @parent = parent
16
16
  end
17
17
 
18
+ # Parse ParagraphMargins object
19
+ # @param text_body_props_node [Nokogiri::XML:Element] node to parse
20
+ # @return [ParagraphMargins] result of parsing
18
21
  def parse(text_body_props_node)
19
22
  text_body_props_node.attributes.each do |key, value|
20
23
  case key
@@ -15,6 +15,9 @@ module OoxmlParser
15
15
  end
16
16
 
17
17
  # TODO: Separate @is_default attribute and remove this method
18
+ # Compare this object to other
19
+ # @param other [Object] any other object
20
+ # @return [True, False] result of comparision
18
21
  def ==(other)
19
22
  instance_variables.each do |current_attribute|
20
23
  next if current_attribute == :@parent
@@ -24,10 +27,14 @@ module OoxmlParser
24
27
  true
25
28
  end
26
29
 
30
+ # @return [String] result of convert of object to string
27
31
  def to_s
28
32
  'Default: ' + is_default.to_s + ' top: ' + @top.to_s + ', bottom: ' + @bottom.to_s + ', left: ' + @left.to_s + ', right: ' + @right.to_s
29
33
  end
30
34
 
35
+ # Parse TableMargins object
36
+ # @param margin_node [Nokogiri::XML:Element] node to parse
37
+ # @return [TableMargins] result of parsing
31
38
  def parse(margin_node)
32
39
  margin_node.xpath('*').each do |cell_margin_node|
33
40
  case cell_margin_node.name
@@ -6,6 +6,7 @@ module OoxmlParser
6
6
  attr_accessor :left, :right, :top, :bottom, :position_x, :position_y, :horizontal_anchor, :vertical_anchor, :vertical_align_from_anchor,
7
7
  :horizontal_align_from_anchor
8
8
 
9
+ # @return [String] result of convert of object to string
9
10
  def to_s
10
11
  "Table position left: #{left}, "\
11
12
  "right: #{right}, "\
@@ -16,6 +16,7 @@ module OoxmlParser
16
16
  attr_reader :table_row_properties
17
17
  # @return [ParagraphProperties] properties of paragraph
18
18
  attr_accessor :paragraph_properties
19
+
19
20
  alias cell_properties table_cell_properties
20
21
 
21
22
  def initialize(type: nil, parent: nil)
@@ -3,6 +3,7 @@
3
3
  module OoxmlParser
4
4
  # Helper method for working with TableStyleProperties
5
5
  module TableStylePropertiesHelper
6
+ # [Hash] short names for table styles
6
7
  TABLE_STYLES_NAMES_HASH = { first_column: :firstCol,
7
8
  last_column: :lastCol,
8
9
  whole_table: :wholeTbl,
@@ -17,12 +18,11 @@ module OoxmlParser
17
18
  first_row: :firstRow,
18
19
  last_row: :lastRow }.freeze
19
20
 
20
- TABLE_STYLES_NAMES_HASH.each_key do |table_style_name|
21
- define_method(table_style_name) do
21
+ TABLE_STYLES_NAMES_HASH.each do |key, value|
22
+ define_method(key) do
22
23
  @table_style_properties_list.each do |table_style|
23
- return table_style if table_style.type == TABLE_STYLES_NAMES_HASH[table_style_name]
24
+ return table_style if table_style.type == value
24
25
  end
25
- nil
26
26
  end
27
27
  end
28
28
 
@@ -4,7 +4,7 @@ require_relative 'grid_span'
4
4
  module OoxmlParser
5
5
  # Class for parsing 'w:tcPr' element
6
6
  class CellProperties < OOXMLDocumentObject
7
- attr_accessor :fill, :color, :borders, :text_direction, :anchor, :anchor_center, :horizontal_overflow, :table_cell_width, :borders_properties, :vertical_align
7
+ attr_accessor :fill, :color, :borders, :text_direction, :anchor, :table_cell_width, :borders_properties, :vertical_align
8
8
  # @return [GridSpan] data about grid span
9
9
  attr_accessor :grid_span
10
10
  # @return [TableMargins] margins
@@ -25,6 +25,9 @@ module OoxmlParser
25
25
 
26
26
  alias table_cell_borders borders_properties
27
27
 
28
+ # Parse CellProperties object
29
+ # @param node [Nokogiri::XML:Element] node to parse
30
+ # @return [CellProperties] result of parsing
28
31
  def parse(node)
29
32
  @borders_properties = Borders.new
30
33
  @margins = ParagraphMargins.new(parent: self).parse(node)
@@ -78,10 +81,6 @@ module OoxmlParser
78
81
  @text_direction = value.value.to_sym
79
82
  when 'anchor'
80
83
  @anchor = value_to_symbol(value)
81
- when 'anchorCtr'
82
- @anchor_center = value.value
83
- when 'horzOverflow'
84
- @horizontal_overflow = value.value.to_sym
85
84
  end
86
85
  end
87
86
  self
@@ -18,6 +18,8 @@ module OoxmlParser
18
18
  @parent = parent
19
19
  end
20
20
 
21
+ # Method to copy object
22
+ # @return [Borders] copied object
21
23
  def copy
22
24
  new_borders = Borders.new
23
25
  new_borders.left = @left if @left
@@ -32,6 +34,9 @@ module OoxmlParser
32
34
  new_borders
33
35
  end
34
36
 
37
+ # Compare this object to other
38
+ # @param other [Object] any other object
39
+ # @return [True, False] result of comparision
35
40
  def ==(other)
36
41
  @left == other.left && @right == other.right && @top == other.top && @bottom == other.bottom if other.is_a?(Borders)
37
42
  end
@@ -52,6 +57,7 @@ module OoxmlParser
52
57
  yield(top)
53
58
  end
54
59
 
60
+ # @return [String] result of convert of object to string
55
61
  def to_s
56
62
  "Left border: #{left}, Right: #{right}, Top: #{top}, Bottom: #{bottom}"
57
63
  end
@@ -12,6 +12,9 @@ module OoxmlParser
12
12
  @parent = parent
13
13
  end
14
14
 
15
+ # Compare this object to other
16
+ # @param other [Object] any other object
17
+ # @return [True, False] result of comparision
15
18
  def ==(other)
16
19
  @columns.each_with_index do |cur_column, index|
17
20
  return false unless cur_column == other.columns[index]
@@ -11,6 +11,9 @@ module OoxmlParser
11
11
  @parent = parent
12
12
  end
13
13
 
14
+ # Compare this object to other
15
+ # @param other [Object] any other object
16
+ # @return [True, False] result of comparision
14
17
  def ==(other)
15
18
  if other.is_a? Underline
16
19
  @style.to_sym == other.style.to_sym && @color == other.color
@@ -21,6 +24,7 @@ module OoxmlParser
21
24
  end
22
25
  end
23
26
 
27
+ # @return [String] result of convert of object to string
24
28
  def to_s
25
29
  if @color.nil?
26
30
  @style.to_s
@@ -44,6 +44,9 @@ module OoxmlParser
44
44
 
45
45
  alias theme_colors theme
46
46
 
47
+ # Compare this object to other
48
+ # @param other [Object] any other object
49
+ # @return [True, False] result of comparision
47
50
  def ==(other)
48
51
  @elements == other.elements &&
49
52
  @page_properties == other.page_properties &&
@@ -53,6 +56,10 @@ module OoxmlParser
53
56
  @comments == other.comments
54
57
  end
55
58
 
59
+ # Get element by it's type
60
+ # @param location [Symbol] location of object
61
+ # @param type [Symbol] type of object
62
+ # @return [OOXMLDocumentObject]
56
63
  def element_by_description(location: :canvas, type: :docx_paragraph)
57
64
  case location
58
65
  when :canvas
@@ -95,6 +102,9 @@ module OoxmlParser
95
102
  end
96
103
  end
97
104
 
105
+ # Get note by it's description
106
+ # @param type [Symbol] note type
107
+ # @return [Note]
98
108
  def note_by_description(type)
99
109
  notes.each do |note|
100
110
  return note if note.type.to_sym == type
@@ -102,6 +112,11 @@ module OoxmlParser
102
112
  raise 'There isn\'t this type of the note'
103
113
  end
104
114
 
115
+ # Detect numbering type
116
+ # @param location [Symbol] location of object
117
+ # @param type [Symbol] type of object
118
+ # @param paragraph_number [Integer] number of object
119
+ # @return [Array<String,String>] type of numbering
105
120
  def recognize_numbering(location: :canvas, type: :simple, paragraph_number: 0)
106
121
  elements = element_by_description(location: location, type: type)
107
122
  lvl_text = elements[paragraph_number].numbering.abstruct_numbering.level_list[0].text.value
@@ -109,6 +124,11 @@ module OoxmlParser
109
124
  [num_format, lvl_text]
110
125
  end
111
126
 
127
+ # Return outline type
128
+ # @param location [Symbol] location of object
129
+ # @param type [Symbol] type of object
130
+ # @param levels_count [Integer] count of levels to detect
131
+ # @return [Array<String,String>] type of outline
112
132
  def outline(location: :canvas, type: :simple, levels_count: 1)
113
133
  elements = element_by_description(location: location, type: type)
114
134
  set = []
@@ -124,6 +144,8 @@ module OoxmlParser
124
144
  styles.styles
125
145
  end
126
146
 
147
+ # Parse docx file
148
+ # @return [DocumentStructure] parsed structure
127
149
  def self.parse
128
150
  doc_structure = DocumentStructure.new
129
151
  doc_structure.content_types = ContentTypes.new(parent: doc_structure).parse
@@ -181,6 +203,8 @@ module OoxmlParser
181
203
  doc_structure
182
204
  end
183
205
 
206
+ # Parse default style
207
+ # @return [void]
184
208
  def parse_default_style
185
209
  doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
186
210
  doc.search('//w:style').each do |style|
@@ -194,14 +218,14 @@ module OoxmlParser
194
218
  DocumentStructure.default_paragraph_style = DocxParagraph.new.parse_paragraph_style(paragraph_pr_tag, DocumentStructure.default_run_style)
195
219
  end
196
220
  style.xpath('w:rPr').each do |character_pr_tag|
197
- DocumentStructure.default_run_style.parse_properties(character_pr_tag, DocumentStructure.default_run_style)
221
+ DocumentStructure.default_run_style.parse_properties(character_pr_tag)
198
222
  end
199
223
  elsif (style.attribute('default').value == '1' ||
200
224
  style.attribute('default').value == 'on' ||
201
225
  style.attribute('default').value == 'true') &&
202
226
  style.attribute('type').value == 'character'
203
227
  style.xpath('w:rPr').each do |character_pr_tag|
204
- DocumentStructure.default_run_style.parse_properties(character_pr_tag, DocumentStructure.default_run_style)
228
+ DocumentStructure.default_run_style.parse_properties(character_pr_tag)
205
229
  end
206
230
  end
207
231
  end
@@ -216,7 +240,7 @@ module OoxmlParser
216
240
  style.attribute('type').value == 'table'
217
241
 
218
242
  style.xpath('w:rPr').each do |table_character_pr_tag|
219
- DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag, DocumentStructure.default_run_style)
243
+ DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag)
220
244
  end
221
245
  end
222
246
  end
@@ -14,6 +14,9 @@ module OoxmlParser
14
14
  @parent = parent
15
15
  end
16
16
 
17
+ # Parse Comment object
18
+ # @param node [Nokogiri::XML:Element] node to parse
19
+ # @return [Comment] result of parsing
17
20
  def parse(node)
18
21
  node.attributes.each do |key, value|
19
22
  case key
@@ -35,6 +35,7 @@ module OoxmlParser
35
35
  # Used to determine if current style is visible in style list in editors
36
36
  # According to http://www.wordarticles.com/Articles/WordStyles/LatentStyles.php
37
37
  attr_accessor :q_format
38
+
38
39
  alias visible? q_format
39
40
 
40
41
  def initialize(parent: nil)
@@ -43,10 +44,12 @@ module OoxmlParser
43
44
  @parent = parent
44
45
  end
45
46
 
47
+ # @return [String] result of convert of object to string
46
48
  def to_s
47
49
  "Table style properties list: #{@table_style_properties_list.join(',')}"
48
50
  end
49
51
 
52
+ # @return [String] inspect of object for debug means
50
53
  def inspect
51
54
  to_s
52
55
  end
@@ -57,6 +57,9 @@ module OoxmlParser
57
57
 
58
58
  alias elements character_style_array
59
59
 
60
+ # Constructor for copy of object
61
+ # @param source [DocxParagraph] original object
62
+ # @return [void]
60
63
  def initialize_copy(source)
61
64
  super
62
65
  @bookmark_start = source.bookmark_start.clone
@@ -65,6 +68,7 @@ module OoxmlParser
65
68
  @spacing = source.spacing.clone
66
69
  end
67
70
 
71
+ # @return [Array<OOXMLDocumentObject>] array of child objects that contains data
68
72
  def nonempty_runs
69
73
  @character_style_array.select do |cur_run|
70
74
  if cur_run.is_a?(DocxParagraphRun) || cur_run.is_a?(ParagraphRun)
@@ -87,6 +91,9 @@ module OoxmlParser
87
91
  !nonempty_runs.empty? || paragraph_properties.section_properties
88
92
  end
89
93
 
94
+ # Compare this object to other
95
+ # @param other [Object] any other object
96
+ # @return [True, False] result of comparision
90
97
  def ==(other)
91
98
  ignored_attributes = %i[@number @parent]
92
99
  all_instance_variables = instance_variables
@@ -97,6 +104,12 @@ module OoxmlParser
97
104
  true
98
105
  end
99
106
 
107
+ # Parse object
108
+ # @param node [Nokogiri::XML:Node] node with DocxParagraph
109
+ # @param par_number [Integer] number of paragraph
110
+ # @param default_character [DocxParagraphRun] style for paragraph
111
+ # @param parent [OOXMLDocumentObject] parent of run
112
+ # @return [DocxParagraph] result of parse
100
113
  def parse(node, par_number = 0, default_character = DocxParagraphRun.new, parent: nil)
101
114
  @parent ||= parent
102
115
  default_character_style = default_character.dup
@@ -174,6 +187,10 @@ module OoxmlParser
174
187
  self
175
188
  end
176
189
 
190
+ # Parse style
191
+ # @param node [Nokogiri::XML:Node] node with style
192
+ # @param default_char_style [DocxParagraphRun] style for paragraph
193
+ # @return [DocxParagraph] result of parse
177
194
  def parse_paragraph_style(node, default_char_style = DocxParagraphRun.new(parent: self))
178
195
  node.xpath('*').each do |node_child|
179
196
  case node_child.name
@@ -229,6 +246,10 @@ module OoxmlParser
229
246
  self
230
247
  end
231
248
 
249
+ # Parse style xml
250
+ # @param id [String] id of style to parse
251
+ # @param character_style [DocxParagraphRun] style to parse
252
+ # @return [void]
232
253
  def parse_paragraph_style_xml(id, character_style)
233
254
  doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
234
255
  doc.search('//w:style').each do |style|
@@ -239,7 +260,7 @@ module OoxmlParser
239
260
  @style = StyleParametres.new(parent: self).parse(style)
240
261
  end
241
262
  style.xpath('w:rPr').each do |r_pr|
242
- character_style.parse_properties(r_pr, DocumentStructure.default_run_style)
263
+ character_style.parse_properties(r_pr)
243
264
  end
244
265
  break
245
266
  end