Class: OoxmlParser::TableRow

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/table/row/row.rb

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Constructor Details

#initialize(cells = []) ⇒ TableRow

Returns a new instance of TableRow.



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 7

def initialize(cells = [])
  @cells = cells
end

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 5

def cells
  @cells
end

#cells_spacingObject

Returns the value of attribute cells_spacing.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 5

def cells_spacing
  @cells_spacing
end

#heightObject Also known as: table_row_height

Returns the value of attribute height.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 5

def height
  @height
end

#table_row_propertiesObject

Returns the value of attribute table_row_properties.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 5

def table_row_properties
  @table_row_properties
end

Class Method Details

.parse(row_node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 13

def self.parse(row_node)
  row = TableRow.new
  row.height = (row_node.attribute('h').value.to_f / 360_000.0).round(2) unless row_node.attribute('h').nil?
  row_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:trPr").each do |table_prop_node|
    row.table_row_properties = TableRowProperties.parse(table_prop_node)
  end
  row_node.xpath('*').each do |row_node_child|
    row_node_child.xpath('*').each do |row_properties|
      case row_properties.name
      when 'tblCellSpacing'
        row.cells_spacing = (row_properties.attribute('w').value.to_f / 283.3).round(2)
      end
    end
  end
  Presentation.current_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
  row_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:tc").each { |cell_node| row.cells << TableCell.parse(cell_node) }
  Presentation.current_font_style = FontStyle.new
  row
end