Class: OoxmlParser::CellProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::CellProperties
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#anchor ⇒ Object
Returns the value of attribute anchor.
-
#anchor_center ⇒ Object
Returns the value of attribute anchor_center.
-
#borders ⇒ Object
Returns the value of attribute borders.
-
#borders_properties ⇒ Object
Returns the value of attribute borders_properties.
-
#color ⇒ Object
Returns the value of attribute color.
-
#fill ⇒ Object
Returns the value of attribute fill.
-
#horizontal_overflow ⇒ Object
Returns the value of attribute horizontal_overflow.
-
#margins ⇒ Object
(also: #table_cell_margin)
Returns the value of attribute margins.
-
#merge ⇒ Object
Returns the value of attribute merge.
-
#shd ⇒ Object
Returns the value of attribute shd.
-
#table_cell_width ⇒ Object
Returns the value of attribute table_cell_width.
-
#text_direction ⇒ Object
Returns the value of attribute text_direction.
-
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(borders = nil, color = nil) ⇒ CellProperties
constructor
A new instance of CellProperties.
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(borders = nil, color = nil) ⇒ CellProperties
Returns a new instance of CellProperties.
6 7 8 9 10 11 12 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 6 def initialize(borders = nil, color = nil) @borders = borders @color = color @fill = fill @shd = :none @merge = false end |
Instance Attribute Details
#anchor ⇒ Object
Returns the value of attribute anchor.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def anchor @anchor end |
#anchor_center ⇒ Object
Returns the value of attribute anchor_center.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def anchor_center @anchor_center end |
#borders ⇒ Object
Returns the value of attribute borders.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def borders @borders end |
#borders_properties ⇒ Object
Returns the value of attribute borders_properties.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def borders_properties @borders_properties end |
#color ⇒ Object
Returns the value of attribute color.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def color @color end |
#fill ⇒ Object
Returns the value of attribute fill.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def fill @fill end |
#horizontal_overflow ⇒ Object
Returns the value of attribute horizontal_overflow.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def horizontal_overflow @horizontal_overflow end |
#margins ⇒ Object Also known as: table_cell_margin
Returns the value of attribute margins.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def margins @margins end |
#merge ⇒ Object
Returns the value of attribute merge.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def merge @merge end |
#shd ⇒ Object
Returns the value of attribute shd.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def shd @shd end |
#table_cell_width ⇒ Object
Returns the value of attribute table_cell_width.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def table_cell_width @table_cell_width end |
#text_direction ⇒ Object
Returns the value of attribute text_direction.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def text_direction @text_direction end |
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 4 def vertical_align @vertical_align end |
Class Method Details
.parse(cell_properties_node) ⇒ Object
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 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 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb', line 17 def self.parse(cell_properties_node) cell_properties = CellProperties.new(Borders.parse(cell_properties_node), PresentationFill.parse(cell_properties_node)) cell_properties.margins = ParagraphMargins.parse(cell_properties_node) cell_properties_node.attributes.each do |key, value| case key when 'vert' cell_properties.text_direction = value.value.to_sym when 'anchor' cell_properties.anchor = Alignment.parse(value) when 'anchorCtr' cell_properties.anchor_center = value.value when 'horzOverflow' cell_properties.horizontal_overflow = value.value.to_sym end end cell_borders = Borders.new cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:vMerge").each do |v_merge| cell_properties.merge = CellMerge.parse(v_merge) end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:vAlign").each do |valign_node| cell_properties.vertical_align = valign_node.attribute('val').value.to_sym end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:gridSpan").each do |grid_span| cell_properties.merge = CellMerge.new('horizontal', grid_span.attribute('val').value) end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:tcW").each do |table_cell_width| cell_properties.table_cell_width = table_cell_width.attribute('w').value.to_f / 567.5 end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:tcMar").each do |cell_margins_node| cell_properties.table_cell_margin = TableMargins.parse(cell_margins_node) end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:textDirection").each do |text_direction| cell_properties.text_direction = Alignment.parse(text_direction.attribute('val')) end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:tcBorders").each do |tc_boders| tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:top").each do |top| cell_borders.top = BordersProperties.parse(top) end tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:right").each do |right| cell_borders.right = BordersProperties.parse(right) end tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:left").each do |left| cell_borders.left = BordersProperties.parse(left) end tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:bottom").each do |bottom| cell_borders.bottom = BordersProperties.parse(bottom) end tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:tl2br").each do |tl2br| cell_borders.top_left_to_bottom_right = BordersProperties.parse(tl2br) end tc_boders.xpath("#{OOXMLDocumentObject.namespace_prefix}:tr2bl").each do |tr2bl| cell_borders.top_right_to_bottom_left = BordersProperties.parse(tr2bl) end end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:shd").each do |shd| next if shd.attribute('val').value == 'nil' cell_properties.shd = shd.attribute('fill').value if !shd.attribute('fill').nil? && shd.attribute('fill').value != 'auto' cell_properties.shd = Color.from_int16(shd.attribute('fill').value) end end cell_properties_node.xpath("#{OOXMLDocumentObject.namespace_prefix}:fill").each do |fill| cell_properties.fill = DocxColorScheme.parse(fill) end cell_properties.borders_properties = cell_borders cell_properties end |