Class: OoxmlParser::TableStyle
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::TableStyle
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#banding_1_horizontal ⇒ Object
Returns the value of attribute banding_1_horizontal.
-
#banding_1_vertical ⇒ Object
Returns the value of attribute banding_1_vertical.
-
#banding_2_horizontal ⇒ Object
Returns the value of attribute banding_2_horizontal.
-
#banding_2_vertical ⇒ Object
Returns the value of attribute banding_2_vertical.
-
#first_column ⇒ Object
Returns the value of attribute first_column.
-
#first_row ⇒ Object
Returns the value of attribute first_row.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_column ⇒ Object
Returns the value of attribute last_column.
-
#last_row ⇒ Object
Returns the value of attribute last_row.
-
#name ⇒ Object
Returns the value of attribute name.
-
#northeast_cell ⇒ Object
Returns the value of attribute northeast_cell.
-
#northwest_cell ⇒ Object
Returns the value of attribute northwest_cell.
-
#southeast_cell ⇒ Object
Returns the value of attribute southeast_cell.
-
#southwest_cell ⇒ Object
Returns the value of attribute southwest_cell.
-
#whole_table ⇒ Object
Returns the value of attribute whole_table.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id = nil) ⇒ TableStyle
constructor
A new instance of TableStyle.
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(id = nil) ⇒ TableStyle
Returns a new instance of TableStyle.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 10 def initialize(id = nil) @id = id @banding_1_horizontal = TableStyleElement.new @banding_2_horizontal = TableStyleElement.new @banding_1_vertical = TableStyleElement.new @banding_2_vertical = TableStyleElement.new @last_column = TableStyleElement.new @first_column = TableStyleElement.new @last_row = TableStyleElement.new @first_row = TableStyleElement.new @southeast_cell = TableStyleElement.new @southwest_cell = TableStyleElement.new @northeast_cell = TableStyleElement.new @northwest_cell = TableStyleElement.new end |
Instance Attribute Details
#banding_1_horizontal ⇒ Object
Returns the value of attribute banding_1_horizontal.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def banding_1_horizontal @banding_1_horizontal end |
#banding_1_vertical ⇒ Object
Returns the value of attribute banding_1_vertical.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def banding_1_vertical @banding_1_vertical end |
#banding_2_horizontal ⇒ Object
Returns the value of attribute banding_2_horizontal.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def banding_2_horizontal @banding_2_horizontal end |
#banding_2_vertical ⇒ Object
Returns the value of attribute banding_2_vertical.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def banding_2_vertical @banding_2_vertical end |
#first_column ⇒ Object
Returns the value of attribute first_column.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def first_column @first_column end |
#first_row ⇒ Object
Returns the value of attribute first_row.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def first_row @first_row end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def id @id end |
#last_column ⇒ Object
Returns the value of attribute last_column.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def last_column @last_column end |
#last_row ⇒ Object
Returns the value of attribute last_row.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def last_row @last_row end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def name @name end |
#northeast_cell ⇒ Object
Returns the value of attribute northeast_cell.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def northeast_cell @northeast_cell end |
#northwest_cell ⇒ Object
Returns the value of attribute northwest_cell.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def northwest_cell @northwest_cell end |
#southeast_cell ⇒ Object
Returns the value of attribute southeast_cell.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def southeast_cell @southeast_cell end |
#southwest_cell ⇒ Object
Returns the value of attribute southwest_cell.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def southwest_cell @southwest_cell end |
#whole_table ⇒ Object
Returns the value of attribute whole_table.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 6 def whole_table @whole_table end |
Class Method Details
.get_style_node(style_id) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 74 def self.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, table_style_node: nil) ⇒ Object
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 |
# File 'lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb', line 26 def self.parse(style_id: nil, table_style_node: nil) table_style = TableStyle.new if !style_id.nil? nodes = get_style_node(style_id) return nil if nodes.nil? xpath = '*' attributes = 'style_node_child.name' elsif !table_style_node.nil? nodes = table_style_node xpath = 'w:tblStylePr' attributes = "style_node_child.attribute('type').value" end begin nodes.xpath(xpath).each do |style_node_child| case instance_eval(attributes) when 'wholeTbl' table_style.whole_table = TableElement.parse(style_node_child) when 'band1H' table_style.banding_1_horizontal = TableElement.parse(style_node_child) when 'band2H', 'band2Horz' table_style.banding_2_horizontal = TableElement.parse(style_node_child) when 'band1V' table_style.banding_1_vertical = TableElement.parse(style_node_child) when 'band2V' table_style.banding_2_vertical = TableElement.parse(style_node_child) when 'lastCol' table_style.last_column = TableElement.parse(style_node_child) when 'firstCol' table_style.first_column = TableElement.parse(style_node_child) when 'lastRow' table_style.last_row = TableElement.parse(style_node_child) when 'firstRow' table_style.first_row = TableElement.parse(style_node_child) when 'seCell' table_style.southeast_cell = TableElement.parse(style_node_child) when 'swCell' table_style.southwest_cell = TableElement.parse(style_node_child) when 'neCell' table_style.northeast_cell = TableElement.parse(style_node_child) when 'nwCell' table_style.northwest_cell = TableElement.parse(style_node_child) end end end table_style.id = style_id unless style_id.nil? table_style end |