class Rspreadsheet::WorksheetImages
Represents images embeded in a Worksheet
Public Class Methods
new(parent_worksheet)
click to toggle source
# File lib/rspreadsheet/image.rb, line 6 def initialize(parent_worksheet) initialize_xml_tied_array @worksheet = parent_worksheet end
Public Instance Methods
insert_image(filename,mime='image/png')
click to toggle source
# File lib/rspreadsheet/image.rb, line 11 def insert_image(filename,mime='image/png') if xmlnode.nil? #TODO: this needs to be solved more generally maybe on XMLTiedArray level @worksheet.xmlnode end push_new last.initialize_from_file(filename,mime) end
prepare_empty_subnode()
click to toggle source
Calls superclass method
Rspreadsheet::XMLTiedArray#prepare_empty_subnode
# File lib/rspreadsheet/image.rb, line 29 def prepare_empty_subnode main_node = super # prepares <draw:frame/> node but it is entirely empty [ ['draw', 'z-index', '1'], ['draw', 'name', 'test'], ['draw', 'style-name', 'gr1'], ['draw', 'text-style-name', 'P1'], ['svg', 'width', '11.63mm'], ['svg', 'height', '10.83mm'] ].each do |line| Tools.set_ns_attribute(main_node,line[0],line[1],line[2]) end sub_node = Tools.prepare_ns_node('draw', 'image') [ ['xlink', 'type', 'simple'], ['xlink', 'show', 'embed'], ['xlink', 'actuate', 'onLoad'] ].each do |line| Tools.set_ns_attribute(sub_node,line[0],line[1],line[2]) end sub_node << Tools.prepare_ns_node('text','p') main_node << sub_node main_node end
prepare_empty_xmlnode()
click to toggle source
# File lib/rspreadsheet/image.rb, line 23 def prepare_empty_xmlnode Tools.insert_as_first_node_child( @worksheet.xmlnode, Tools.prepare_ns_node('table', 'shapes') ) end
prepare_subitem(index)
click to toggle source
# File lib/rspreadsheet/image.rb, line 21 def prepare_subitem(index); Image.new(self,index) end
subnode_options()
click to toggle source
@!group XMLTiedArray_WithRepeatableItems
related methods
# File lib/rspreadsheet/image.rb, line 20 def subnode_options; {:node_name => 'frame', :node_namespace => 'draw'} end
xmlnode()
click to toggle source
# File lib/rspreadsheet/image.rb, line 22 def xmlnode; @worksheet.xmlnode.find('./table:shapes').first end