ooxml_parser 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) 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/chart/chart.rb +6 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +2 -2
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +0 -2
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -0
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +4 -1
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +1 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +4 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +0 -2
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -3
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -0
  14. 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
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -3
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +1 -3
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +1 -3
  19. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +3 -0
  20. data/lib/ooxml_parser/common_parser/common_data/color.rb +36 -4
  21. data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
  22. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +11 -0
  23. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +1 -0
  24. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +4 -0
  25. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +2 -0
  26. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_default.rb +3 -0
  27. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_override.rb +3 -0
  28. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +7 -0
  29. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +24 -2
  30. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +3 -0
  31. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +0 -8
  32. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +2 -0
  33. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +1 -0
  34. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +16 -13
  35. data/lib/ooxml_parser/common_parser/common_data/table.rb +2 -0
  36. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +3 -0
  37. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +7 -0
  38. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +1 -0
  39. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +4 -4
  40. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -7
  41. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +6 -0
  42. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +3 -0
  43. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -0
  44. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +27 -3
  45. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +3 -0
  46. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +2 -0
  47. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +22 -1
  48. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_end.rb +1 -1
  49. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/comment_range_start.rb +1 -0
  50. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +3 -0
  51. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +13 -3
  52. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +4 -1
  53. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +0 -2
  54. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +3 -0
  55. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +2 -0
  56. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +0 -2
  57. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +5 -0
  58. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +3 -0
  59. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +1 -0
  60. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -0
  61. data/lib/ooxml_parser/docx_parser/docx_parser.rb +3 -0
  62. data/lib/ooxml_parser/name.rb +1 -0
  63. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +2 -0
  64. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +3 -0
  65. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +3 -0
  66. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -0
  67. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +3 -0
  68. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +15 -1
  69. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +3 -0
  70. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +3 -0
  71. data/lib/ooxml_parser/version.rb +2 -1
  72. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +21 -2
  73. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +3 -0
  74. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb +41 -0
  75. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +37 -0
  76. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb +33 -0
  77. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb +26 -0
  78. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +2 -0
  79. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
  80. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +2 -0
  81. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +3 -0
  82. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
  83. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +4 -0
  84. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +4 -0
  85. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +3 -0
  86. metadata +64 -4
@@ -11,6 +11,7 @@ module OoxmlParser
11
11
  @parent = parent
12
12
  end
13
13
 
14
+ # @return [String] result of convert of object to string
14
15
  def to_s
15
16
  @converted_color.to_s
16
17
  end
@@ -6,6 +6,10 @@ module OoxmlParser
6
6
  # @return [Hash] list of colors
7
7
  attr_accessor :list
8
8
 
9
+ # Parse color theme
10
+ # @param theme [String] name of theme
11
+ # @param tint [Integer] tint of theme
12
+ # @return [Color] color of theme
9
13
  def parse_color_theme(theme, tint)
10
14
  themes_array = root_object.theme.color_scheme.values
11
15
  # TODO: if no swap performed - incorrect color parsing. But don't know why it needed
@@ -18,6 +18,8 @@ module OoxmlParser
18
18
  @content_types_list[key]
19
19
  end
20
20
 
21
+ # Parse ContentTypes object
22
+ # @return [ContentTypes] result of parsing
21
23
  def parse
22
24
  doc = Nokogiri::XML.parse(File.open("#{OOXMLDocumentObject.path_to_folder}/[Content_Types].xml"))
23
25
  node = doc.xpath('*').first
@@ -8,6 +8,9 @@ module OoxmlParser
8
8
  # @return [String] extension
9
9
  attr_reader :extension
10
10
 
11
+ # Parse ContentTypeDefault object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [ContentTypeDefault] result of parsing
11
14
  def parse(node)
12
15
  node.attributes.each do |key, value|
13
16
  case key
@@ -8,6 +8,9 @@ module OoxmlParser
8
8
  # @return [String] part name
9
9
  attr_reader :part_name
10
10
 
11
+ # Parse ContentTypeOverride object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [ContentTypeOverride] result of parsing
11
14
  def parse(node)
12
15
  node.attributes.each do |key, value|
13
16
  case key
@@ -29,6 +29,9 @@ module OoxmlParser
29
29
  coordinates
30
30
  end
31
31
 
32
+ # Parse range of coordinates
33
+ # @param arguments_string [String] data to parse
34
+ # @return [Array] result
32
35
  def parser_coordinates_range(arguments_string)
33
36
  return parse_coordinates_array(arguments_string) if arguments_string.include?(',')
34
37
  return warn "Formulas with # is unsupported: #{arguments_string}" if arguments_string.include?('#')
@@ -133,6 +136,7 @@ module OoxmlParser
133
136
  column_number > other_cell.column_number
134
137
  end
135
138
 
139
+ # @return [String] result of convert of object to string
136
140
  def to_s
137
141
  "#{@column}#{@row} #{@list ? "list: #{@list}" : ''}"
138
142
  end
@@ -141,6 +145,9 @@ module OoxmlParser
141
145
  @column.nil? && @list.nil? && @row.nil?
142
146
  end
143
147
 
148
+ # Compare this object to other
149
+ # @param other [Object] any other object
150
+ # @return [True, False] result of comparision
144
151
  def ==(other)
145
152
  other.is_a?(Coordinates) ? (@row == other.row && @column == other.column) : false
146
153
  end
@@ -19,7 +19,12 @@ module OoxmlParser
19
19
  @parent = parent
20
20
  end
21
21
 
22
+ # Compare this object to other
23
+ # @param other [Object] any other object
24
+ # @return [True, False] result of comparision
22
25
  def ==(other)
26
+ return false if self.class != other.class
27
+
23
28
  instance_variables.each do |current_attribute|
24
29
  next if current_attribute == :@parent
25
30
  return false unless instance_variable_get(current_attribute) == other.instance_variable_get(current_attribute)
@@ -44,9 +49,11 @@ module OoxmlParser
44
49
  attr_accessor :path_to_folder
45
50
 
46
51
  # @param path_to_file [String] file
52
+ # @param ignore_system [True, False] should host system be ignored, since
53
+ # this method is OS-dependent
47
54
  # @return [True, False] Check if file is protected by password on open
48
- def encrypted_file?(path_to_file)
49
- if Gem.win_platform?
55
+ def encrypted_file?(path_to_file, ignore_system: false)
56
+ if Gem.win_platform? || ignore_system
50
57
  warn 'FileMagic and checking file for encryption is not supported on Windows'
51
58
  return false
52
59
  end
@@ -63,6 +70,9 @@ module OoxmlParser
63
70
  false
64
71
  end
65
72
 
73
+ # Copy this file and rename to zip
74
+ # @param path [String] path to file
75
+ # @return [String] path to result zip
66
76
  def copy_file_and_rename_to_zip(path)
67
77
  file_name = File.basename(path)
68
78
  tmp_folder = Dir.mktmpdir('ruby-ooxml-parser')
@@ -75,6 +85,10 @@ module OoxmlParser
75
85
  file_path
76
86
  end
77
87
 
88
+ # Unzip specified file
89
+ # @param path_to_file [String] path to zip file
90
+ # @param destination [String] folder to extract
91
+ # @return [void]
78
92
  def unzip_file(path_to_file, destination)
79
93
  Zip.warn_invalid_date = false
80
94
  Zip::File.open(path_to_file) do |zip_file|
@@ -88,14 +102,19 @@ module OoxmlParser
88
102
  end
89
103
  end
90
104
 
105
+ # @return [String] dir to base of file
91
106
  def dir
92
107
  OOXMLDocumentObject.path_to_folder + File.dirname(OOXMLDocumentObject.xmls_stack.last) + '/'
93
108
  end
94
109
 
110
+ # @return [String] path to current xml file
95
111
  def current_xml
96
112
  OOXMLDocumentObject.path_to_folder + OOXMLDocumentObject.xmls_stack.last
97
113
  end
98
114
 
115
+ # Add file to parsing stack
116
+ # @param path [String] path of file to add to stack
117
+ # @return [void]
99
118
  def add_to_xmls_stack(path)
100
119
  OOXMLDocumentObject.xmls_stack << if path.include?('..')
101
120
  "#{File.dirname(OOXMLDocumentObject.xmls_stack.last)}/#{path}"
@@ -106,6 +125,9 @@ module OoxmlParser
106
125
  end
107
126
  end
108
127
 
128
+ # Get link to file from rels file
129
+ # @param id [String] file to get
130
+ # @return [String] result
109
131
  def get_link_from_rels(id)
110
132
  rels_path = dir + "_rels/#{File.basename(OOXMLDocumentObject.xmls_stack.last)}.rels"
111
133
  raise LoadError, "Cannot find .rels file by path: #{rels_path}" unless File.exist?(rels_path)
@@ -40,14 +40,17 @@ module OoxmlParser
40
40
  text.empty?
41
41
  end
42
42
 
43
+ # @return [String] instruction applied to paragraph
43
44
  def instruction
44
45
  parent.instruction
45
46
  end
46
47
 
48
+ # @return [True, False] is page number applyed
47
49
  def page_number
48
50
  parent.page_numbering?
49
51
  end
50
52
 
53
+ # @return [Hyperlink] link of run
51
54
  def link
52
55
  parent.parent.hyperlink
53
56
  end
@@ -29,10 +29,6 @@ module OoxmlParser
29
29
  attr_accessor :shade
30
30
  # @return [RunStyle] run style
31
31
  attr_accessor :run_style
32
- # @return [Float]
33
- # This element specifies the font size which shall be applied to all
34
- # complex script characters in the contents of this run when displayed
35
- attr_accessor :font_size_complex
36
32
 
37
33
  def initialize(parent: nil)
38
34
  @font_name = ''
@@ -50,8 +46,6 @@ module OoxmlParser
50
46
  case key
51
47
  when 'sz'
52
48
  @font_size = value.value.to_f / 100.0
53
- when 'szCs'
54
- @font_size_complex = node.attribute('val').value.to_i / 2.0
55
49
  when 'spc'
56
50
  @space = OoxmlSize.new(value.value.to_f, :one_100th_point)
57
51
  when 'b'
@@ -66,8 +60,6 @@ module OoxmlParser
66
60
  case value.value.to_i
67
61
  when -25_000, -30_000
68
62
  @baseline = :subscript
69
- when 30_000
70
- @baseline = :superscript
71
63
  when 0
72
64
  @baseline = :baseline
73
65
  end
@@ -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}, "\
@@ -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)
@@ -74,14 +77,8 @@ module OoxmlParser
74
77
 
75
78
  node.attributes.each do |key, value|
76
79
  case key
77
- when 'vert'
78
- @text_direction = value.value.to_sym
79
80
  when 'anchor'
80
81
  @anchor = value_to_symbol(value)
81
- when 'anchorCtr'
82
- @anchor_center = value.value
83
- when 'horzOverflow'
84
- @horizontal_overflow = value.value.to_sym
85
82
  end
86
83
  end
87
84
  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