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

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ TableProperties

Returns a new instance of TableProperties.



40
41
42
43
44
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 40

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

Instance Attribute Details

#captionValuedChild

Returns caption of table.

Returns:



30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 30

def caption
  @caption
end

#column_banding_sizeObject

Returns the value of attribute column_banding_size.



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

def column_banding_size
  @column_banding_size
end

#descriptionValuedChild

Returns description of table.

Returns:



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

def description
  @description
end

#fillColor (readonly)

Returns fill type.

Returns:



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

def fill
  @fill
end

#grid_columnObject

Returns the value of attribute grid_column.



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

def grid_column
  @grid_column
end

#jcObject

Returns the value of attribute jc.



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

def jc
  @jc
end

#row_banding_sizeObject

Returns the value of attribute row_banding_size.



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

def row_banding_size
  @row_banding_size
end

#shadeShade

Returns shade color of table.

Returns:

  • (Shade)

    shade color of table



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

def shade
  @shade
end

#stretchingObject

Returns the value of attribute stretching.



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

def stretching
  @stretching
end

#table_bordersObject

Returns the value of attribute table_borders.



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

def table_borders
  @table_borders
end

#table_cell_marginObject

Returns the value of attribute table_cell_margin.



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

def table_cell_margin
  @table_cell_margin
end

#table_cell_spacingOoxmlSize

Returns table cell spacing.

Returns:



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

def table_cell_spacing
  @table_cell_spacing
end

#table_indentObject

Returns the value of attribute table_indent.



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

def table_indent
  @table_indent
end

#table_layoutTableLayout

Returns table layout.

Returns:



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

def table_layout
  @table_layout
end

#table_lookObject

Returns the value of attribute table_look.



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

def table_look
  @table_look
end

#table_positonObject Also known as: table_properties

Returns the value of attribute table_positon.



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

def table_positon
  @table_positon
end

#table_style_column_band_sizeTableStyleColumnBandSize

Returns table style column band size.

Returns:



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

def table_style_column_band_size
  @table_style_column_band_size
end

#table_style_elementTableStyle (readonly)

Returns element of table style.

Returns:



36
37
38
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 36

def table_style_element
  @table_style_element
end

#table_style_idString (readonly)

Returns id of table style.

Returns:

  • (String)

    id of table style



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

def table_style_id
  @table_style_id
end

#table_style_row_band_sizeTableStyleRowBandSize

Returns table style row band size.

Returns:



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

def table_style_row_band_size
  @table_style_row_band_size
end

#table_widthObject

Returns the value of attribute table_width.



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

def table_width
  @table_width
end

Instance Method Details

#parse(node) ⇒ TableProperties

Parse TableProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 49

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'tableStyleId'
      @table_style_id = node_child.text
    when 'tblBorders'
      @table_borders = TableBorders.new(parent: self).parse(node_child)
    when 'tblStyle'
      # TODO: Incorrect but to keep compatibility
      @table_style_element = TableStyle.new(parent: self).parse(node_child)
    when 'tblW'
      @table_width = OoxmlSize.new.parse(node_child)
    when 'jc'
      @justification_object = ValuedChild.new(:symbol, parent: self).parse(node_child)
      @jc = @justification_object.value
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'solidFill'
      @fill = PresentationFill.new(parent: self).parse(node)
    when 'tblLook'
      @table_look = TableLook.new(parent: self).parse(node_child)
    when 'tblInd'
      @table_indent = OoxmlSize.new(parent: self).parse(node_child)
    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

#styleTableStyle

Returns style of table.

Returns:



95
96
97
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 95

def style
  root_object.table_styles.style_by_id(table_style_id)
end

#table_styleDocumentStyle

For compatibility reasons

Returns:



101
102
103
# File 'lib/ooxml_parser/common_parser/common_data/table/table_properties.rb', line 101

def table_style
  root_object.document_style_by_id(table_style_element.value)
end