Class: OoxmlParser::TableProperties

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

Overview

Class for parsing ‘w:tblPr` tags

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, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ TableProperties

Returns a new instance of TableProperties.



32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 32

def initialize(parent: nil)
  @jc = :left
  @table_borders = TableBorders.new
  @parent = parent
end

Instance Attribute Details

#captionValuedChild

Returns caption of table.

Returns:



26
27
28
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 26

def caption
  @caption
end

#column_banding_sizeObject

Returns the value of attribute column_banding_size.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def column_banding_size
  @column_banding_size
end

#descriptionValuedChild

Returns description of table.

Returns:



28
29
30
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 28

def description
  @description
end

#grid_columnObject

Returns the value of attribute grid_column.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def grid_column
  @grid_column
end

#jcObject

Returns the value of attribute jc.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def jc
  @jc
end

#row_banding_sizeObject

Returns the value of attribute row_banding_size.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def row_banding_size
  @row_banding_size
end

#shadeShade

Returns shade color of table.

Returns:

  • (Shade)

    shade color of table



24
25
26
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 24

def shade
  @shade
end

#stretchingObject

Returns the value of attribute stretching.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def stretching
  @stretching
end

#styleObject

Returns the value of attribute style.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def style
  @style
end

#table_bordersObject

Returns the value of attribute table_borders.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_borders
  @table_borders
end

#table_cell_marginObject

Returns the value of attribute table_cell_margin.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_cell_margin
  @table_cell_margin
end

#table_cell_spacingOoxmlSize

Returns table cell spacing.

Returns:



22
23
24
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 22

def table_cell_spacing
  @table_cell_spacing
end

#table_indentObject

Returns the value of attribute table_indent.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_indent
  @table_indent
end

#table_layoutTableLayout

Returns table layout.

Returns:



20
21
22
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 20

def table_layout
  @table_layout
end

#table_lookObject

Returns the value of attribute table_look.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_look
  @table_look
end

#table_positonObject Also known as: table_properties

Returns the value of attribute table_positon.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_positon
  @table_positon
end

#table_styleObject

Returns the value of attribute table_style.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_style
  @table_style
end

#table_style_column_band_sizeTableStyleColumnBandSize

Returns table style column band size.

Returns:



16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 16

def table_style_column_band_size
  @table_style_column_band_size
end

#table_style_row_band_sizeTableStyleRowBandSize

Returns table style row band size.

Returns:



18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 18

def table_style_row_band_size
  @table_style_row_band_size
end

#table_widthObject

Returns the value of attribute table_width.



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 13

def table_width
  @table_width
end

Instance Method Details

#parse(node) ⇒ TableProperties

Parse TableProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 41

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'tableStyleId'
      @style = TableStyle.new(parent: self).parse(style_id: node_child.text)
    when 'tblBorders'
      @table_borders = TableBorders.new(parent: self).parse(node_child)
    when 'tblStyle'
      @table_style = root_object.document_style_by_id(node_child.attribute('val').value)
    when 'tblW'
      @table_width = OoxmlSize.new.parse(node_child)
    when 'jc'
      @jc = node_child.attribute('val').text.to_sym
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'tblLook'
      @table_look = TableLook.new(parent: self).parse(node_child)
    when 'tblInd'
      @table_indent = OoxmlSize.new(node_child.attribute('w').text.to_f)
    when 'tblpPr'
      @table_positon = TablePosition.new(parent: self).parse(node_child)
    when 'tblCellMar'
      @table_cell_margin = TableMargins.new(parent: table_properties).parse(node_child)
    when 'tblStyleColBandSize'
      @table_style_column_band_size = TableStyleColumnBandSize.new(parent: self).parse(node_child)
    when 'tblStyleRowBandSize'
      @table_style_row_band_size = TableStyleRowBandSize.new(parent: self).parse(node_child)
    when 'tblLayout'
      @table_layout = TableLayout.new(parent: self).parse(node_child)
    when 'tblCellSpacing'
      @table_cell_spacing = OoxmlSize.new.parse(node_child)
    when 'tblCaption'
      @caption = ValuedChild.new(:string, parent: self).parse(node_child)
    when 'tblDescription'
      @description = ValuedChild.new(:string, parent: self).parse(node_child)
    end
  end
  @table_look = TableLook.new(parent: self).parse(node) if @table_look.nil?
  self
end