From c8c63518b4d58ca8875f81602792050cbec318f2 Mon Sep 17 00:00:00 2001
From: Randy Morgan
+An array of image objects that are associated with this drawing’s +anchors. +
++Adds an image to the chart. +
+-71 -72 -73 -74 -75 -76+80 +81 +82 +83 +84 +85
# File 'lib/axlsx/drawing/drawing.rb', line 71 +# File 'lib/axlsx/drawing/drawing.rb', line 80 def initialize(worksheet) DataTypeValidator.validate "Drawing.worksheet", Worksheet, worksheet @worksheet = worksheet @worksheet.workbook.drawings << self - @anchors = SimpleTypedList.new TwoCellAnchor + @anchors = SimpleTypedList.new [TwoCellAnchor, OneCellAnchor] end
-43 -44 -45+48 +49 +50
# File 'lib/axlsx/drawing/drawing.rb', line 43 +# File 'lib/axlsx/drawing/drawing.rb', line 48 def anchors @anchors @@ -614,15 +666,77 @@ An array of charts that are associated with this drawing’s anchors-47 -48 -49+52 +53 +54 +55
# File 'lib/axlsx/drawing/drawing.rb', line 47 +# File 'lib/axlsx/drawing/drawing.rb', line 52 def charts - @anchors.map { |a| a.graphic_frame.chart } + charts = @anchors.select { |a| a.object.is_a?(GraphicFrame) } + charts.map { |a| a.object.chart } +end ++
+ + - (Array) images (readonly) + + + +
+An array of image objects that are associated with this drawing’s +anchors +
+ + +
+ + + +56 +57 +58 +59+ |
+
+ # File 'lib/axlsx/drawing/drawing.rb', line 56 + +def images + images = @anchors.select { |a| a.object.is_a?(Pic) } + images.map { |a| a.object } end |
@@ -672,12 +786,12 @@ collection.
- # File 'lib/axlsx/drawing/drawing.rb', line 51 +# File 'lib/axlsx/drawing/drawing.rb', line 60 def index @worksheet.workbook.drawings.index(self) @@ -729,12 +843,12 @@ The part name for this drawing-59 -60 -61+68 +69 +70 |
- # File 'lib/axlsx/drawing/drawing.rb', line 59 +# File 'lib/axlsx/drawing/drawing.rb', line 68 def pn "#{DRAWING_PN % (index+1)}" @@ -786,24 +900,28 @@ The drawing’s relationships.-67 -68 -69 -70 -71 -72 -73 -74+76 +77 +78 +79 +80 +81 +82 +83 +84 +85 |
- # File 'lib/axlsx/drawing/drawing.rb', line 67 +# File 'lib/axlsx/drawing/drawing.rb', line 76 def relationships r = Relationships.new - @anchors.each do |anchor| - chart = anchor.graphic_frame.chart + charts.each do |chart| r << Relationship.new(CHART_R, "../#{chart.pn}") end + images.each do |image| + r << Relationship.new(IMAGE_R, "../#{image.pn}") + end r end@@ -853,12 +971,12 @@ The relational part name for this drawing-63 -64 -65+72 +73 +74 |
- # File 'lib/axlsx/drawing/drawing.rb', line 63 +# File 'lib/axlsx/drawing/drawing.rb', line 72 def rels_pn "#{DRAWING_RELS_PN % (index+1)}" @@ -910,12 +1028,12 @@ The relation reference id for this drawing-55 -56 -57+64 +65 +66 |
- # File 'lib/axlsx/drawing/drawing.rb', line 55 +# File 'lib/axlsx/drawing/drawing.rb', line 64 def rId "rId#{index+1}" @@ -967,12 +1085,12 @@ The worksheet that owns the drawing-38 -39 -40+43 +44 +45 |
- # File 'lib/axlsx/drawing/drawing.rb', line 38 +# File 'lib/axlsx/drawing/drawing.rb', line 43 def worksheet @worksheet @@ -1032,17 +1150,77 @@ Adds a chart to the drawing.-82 -83 -84 -85+98 +99 +100 +101 |
- # File 'lib/axlsx/drawing/drawing.rb', line 82 +# File 'lib/axlsx/drawing/drawing.rb', line 98 def add_chart(chart_type, ={}) - TwoCellAnchor.new(self, chart_type, ) - @anchors.last.graphic_frame.chart + TwoCellAnchor.new(self, ) + @anchors.last.add_chart(chart_type, ) +end ++ |
+
+ + - (Object) add_image(options = {}) + + + +
+The recommended way to manage images is to use Worksheet.add_image. Please +refer to that method for documentation. +
++Adds an image to the chart +
+ + +
+ + + +90 +91 +92 +93+ |
+
+ # File 'lib/axlsx/drawing/drawing.rb', line 90 + +def add_image(={}) + OneCellAnchor.new(self, ) + @anchors.last.object end |
@@ -1088,17 +1266,17 @@ Serializes the drawing
- # File 'lib/axlsx/drawing/drawing.rb', line 118 +# File 'lib/axlsx/drawing/drawing.rb', line 142 def to_xml builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml| @@ -1119,7 +1297,7 @@ Serializes the drawing -- cgit v1.2.3 |