Class: OoxmlParser::TableStyle

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

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#banding_1_horizontalObject

Returns the value of attribute banding_1_horizontal.



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

def banding_1_horizontal
  @banding_1_horizontal
end

#banding_1_verticalObject

Returns the value of attribute banding_1_vertical.



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

def banding_1_vertical
  @banding_1_vertical
end

#banding_2_horizontalObject

Returns the value of attribute banding_2_horizontal.



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

def banding_2_horizontal
  @banding_2_horizontal
end

#banding_2_verticalObject

Returns the value of attribute banding_2_vertical.



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

def banding_2_vertical
  @banding_2_vertical
end

#first_columnObject

Returns the value of attribute first_column.



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

def first_column
  @first_column
end

#first_rowObject

Returns the value of attribute first_row.



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

def first_row
  @first_row
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#last_columnObject

Returns the value of attribute last_column.



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

def last_column
  @last_column
end

#last_rowObject

Returns the value of attribute last_row.



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

def last_row
  @last_row
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#northeast_cellObject

Returns the value of attribute northeast_cell.



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

def northeast_cell
  @northeast_cell
end

#northwest_cellObject

Returns the value of attribute northwest_cell.



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

def northwest_cell
  @northwest_cell
end

#southeast_cellObject

Returns the value of attribute southeast_cell.



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

def southeast_cell
  @southeast_cell
end

#southwest_cellObject

Returns the value of attribute southwest_cell.



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

def southwest_cell
  @southwest_cell
end

#whole_tableObject

Returns the value of attribute whole_table.



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

def whole_table
  @whole_table
end

Instance Method Details

#get_style_node(style_id) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 49

def get_style_node(style_id)
  begin
    doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'ppt/tableStyles.xml'))
  rescue StandardError
    raise 'Can\'t find tableStyles.xml in ' + OOXMLDocumentObject.path_to_folder.to_s + '/ppt folder'
  end
  doc.xpath('a:tblStyleLst/a:tblStyle').each { |table_style_node| return table_style_node if table_style_node.attribute('styleId').value == style_id }
  nil
end

#parse(style_id: nil) ⇒ TableStyle

Parse TableStyle object

Parameters:

  • style_id (String) (defaults to: nil)

    id to parse

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 12

def parse(style_id: nil)
  nodes = get_style_node(style_id)
  return nil unless nodes
  nodes.xpath('*').each do |style_node_child|
    case style_node_child.name
    when 'wholeTbl'
      @whole_table = TableElement.new(parent: self).parse(style_node_child)
    when 'band1H'
      @banding_1_horizontal = TableElement.new(parent: self).parse(style_node_child)
    when 'band2H', 'band2Horz'
      @banding_2_horizontal = TableElement.new(parent: self).parse(style_node_child)
    when 'band1V'
      @banding_1_vertical = TableElement.new(parent: self).parse(style_node_child)
    when 'band2V'
      @banding_2_vertical = TableElement.new(parent: self).parse(style_node_child)
    when 'lastCol'
      @last_column = TableElement.new(parent: self).parse(style_node_child)
    when 'firstCol'
      @first_column = TableElement.new(parent: self).parse(style_node_child)
    when 'lastRow'
      @last_row = TableElement.new(parent: self).parse(style_node_child)
    when 'firstRow'
      @first_row = TableElement.new(parent: self).parse(style_node_child)
    when 'seCell'
      @southeast_cell = TableElement.new(parent: self).parse(style_node_child)
    when 'swCell'
      @southwest_cell = TableElement.new(parent: self).parse(style_node_child)
    when 'neCell'
      @northeast_cell = TableElement.new(parent: self).parse(style_node_child)
    when 'nwCell'
      @northwest_cell = TableElement.new(parent: self).parse(style_node_child)
    end
  end
  @id = style_id
  self
end