Class: Rspreadsheet::WorksheetImages
- Inherits:
-
Object
- Object
- Rspreadsheet::WorksheetImages
- Defined in:
- lib/rspreadsheet/image.rb
Overview
Represents images embeded in a Worksheet
XMLTiedArray_WithRepeatableItems related methods collapse
- #prepare_empty_subnode ⇒ Object
- #prepare_empty_xmlnode ⇒ Object
- #prepare_subitem(index) ⇒ Object
- #subnode_options ⇒ Object
- #xmlnode ⇒ Object
Instance Method Summary collapse
-
#initialize(parent_worksheet) ⇒ WorksheetImages
constructor
A new instance of WorksheetImages.
- #insert_image(filename, mime = 'image/png') ⇒ Object
Constructor Details
#initialize(parent_worksheet) ⇒ WorksheetImages
Returns a new instance of WorksheetImages.
6 7 8 9 |
# File 'lib/rspreadsheet/image.rb', line 6 def initialize(parent_worksheet) initialize_xml_tied_array @worksheet = parent_worksheet end |
Instance Method Details
#insert_image(filename, mime = 'image/png') ⇒ Object
11 12 13 14 15 16 17 |
# 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 ⇒ Object
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 |
# 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 ⇒ Object
23 24 25 26 27 28 |
# 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) ⇒ Object
21 |
# File 'lib/rspreadsheet/image.rb', line 21 def prepare_subitem(index); Image.new(self,index) end |
#subnode_options ⇒ Object
20 |
# File 'lib/rspreadsheet/image.rb', line 20 def ; {:node_name => 'frame', :node_namespace => 'draw'} end |
#xmlnode ⇒ Object
22 |
# File 'lib/rspreadsheet/image.rb', line 22 def xmlnode; @worksheet.xmlnode.find('./table:shapes').first end |