Class: OoxmlParser::CellProperties

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

Overview

Class for parsing ‘w:tcPr’ element

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#anchorObject

Returns the value of attribute anchor.



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

def anchor
  @anchor
end

#bordersObject

Returns the value of attribute borders.



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

def borders
  @borders
end

#borders_propertiesObject Also known as: table_cell_borders

Returns the value of attribute borders_properties.



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

def borders_properties
  @borders_properties
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#fillObject

Returns the value of attribute fill.



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

def fill
  @fill
end

#grid_spanGridSpan

Returns data about grid span.

Returns:



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 9

def grid_span
  @grid_span
end

#marginsParagraphMargins

Returns margins of text in cell.

Returns:



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

def margins
  @margins
end

#no_wrapTrue, False

wrapping in the cell under certain conditions. If the cell width is fixed, then noWrap specifies that the cell will not be smaller than that fixed value when other cells in the row are not at their minimum. If the cell width is set to auto or pct, then the content of the cell will not wrap. > ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference 17.4.30.

Returns:

  • (True, False)

    This element will prevent text from



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

def no_wrap
  @no_wrap
end

#shadeShade

Returns shade of cell.

Returns:

  • (Shade)

    shade of cell



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

def shade
  @shade
end

#table_cell_marginTableMargins

Returns margins of cell.

Returns:



17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 17

def table_cell_margin
  @table_cell_margin
end

#table_cell_widthObject

Returns the value of attribute table_cell_width.



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

def table_cell_width
  @table_cell_width
end

#text_directionObject

Returns the value of attribute text_direction.



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

def text_direction
  @text_direction
end

#vertical_align_objectValuedChild (readonly)

Returns vertical align type.

Returns:



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

def vertical_align_object
  @vertical_align_object
end

#vertical_mergeTableMargins

Returns margins.

Returns:



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 11

def vertical_merge
  @vertical_merge
end

Instance Method Details

#parse(node) ⇒ CellProperties

Parse CellProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



33
34
35
36
37
38
39
40
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
81
82
83
84
85
86
87
88
89
90
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 33

def parse(node)
  @borders_properties = Borders.new
  @margins = ParagraphMargins.new(parent: self).parse(node)
  @color = PresentationFill.new(parent: self).parse(node)
  @borders = Borders.new(parent: self).parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'vMerge'
      @vertical_merge = ValuedChild.new(:symbol, parent: self).parse(node_child)
    when 'vAlign'
      @vertical_align_object = ValuedChild.new(:symbol, parent: self).parse(node_child)
    when 'gridSpan'
      @grid_span = GridSpan.new(parent: self).parse(node_child)
    when 'tcW'
      @table_cell_width = OoxmlSize.new.parse(node_child)
    when 'tcMar'
      @table_cell_margin = TableMargins.new(parent: self).parse(node_child)
    when 'textDirection'
      @text_direction_object = ValuedChild.new(:string, parent: self).parse(node_child)
      @text_direction = value_to_symbol(@text_direction_object)
    when 'noWrap'
      @no_wrap = option_enabled?(node_child)
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'fill'
      @fill = DocxColorScheme.new(parent: self).parse(node_child)
    when 'tcBdr'
      @borders_properties = Borders.new(parent: self).parse(node_child)
    when 'tcBorders'
      node_child.xpath('*').each do |border_child|
        case border_child.name
        when 'top'
          @borders_properties.top = BordersProperties.new(parent: self).parse(border_child)
        when 'right'
          @borders_properties.right = BordersProperties.new(parent: self).parse(border_child)
        when 'left'
          @borders_properties.left = BordersProperties.new(parent: self).parse(border_child)
        when 'bottom'
          @borders_properties.bottom = BordersProperties.new(parent: self).parse(border_child)
        when 'tl2br'
          @borders_properties.top_left_to_bottom_right = BordersProperties.new(parent: self).parse(border_child)
        when 'tr2bl'
          @borders_properties.top_right_to_bottom_left = BordersProperties.new(parent: self).parse(border_child)
        end
      end
    end
  end

  node.attributes.each do |key, value|
    case key
    when 'vert'
      @text_direction = value.value.to_sym
    when 'anchor'
      @anchor = value_to_symbol(value)
    end
  end
  self
end

#vertical_alignnil, Symbol

Returns vertical align of cell.

Returns:

  • (nil, Symbol)

    vertical align of cell



93
94
95
96
97
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 93

def vertical_align
  return nil unless @vertical_align_object

  @vertical_align_object.value
end