From c8c63518b4d58ca8875f81602792050cbec318f2 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 23 Nov 2011 21:45:54 +0900 Subject: Adding image support and some document clean up for .8 release --- doc/Axlsx/Drawing.html | 308 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 243 insertions(+), 65 deletions(-) (limited to 'doc/Axlsx/Drawing.html') diff --git a/doc/Axlsx/Drawing.html b/doc/Axlsx/Drawing.html index 26f3f3fa..8f899d2a 100644 --- a/doc/Axlsx/Drawing.html +++ b/doc/Axlsx/Drawing.html @@ -183,6 +183,34 @@ An array of charts that are associated with this drawing’s anchors.

+ + + +
  • + + + - (Array) images + + + + + + + readonly + + + + + + + + +

    +An array of image objects that are associated with this drawing’s +anchors. +

    +
    +
  • @@ -383,6 +411,30 @@ Adds a chart to the drawing.

    + + + +
  • + + + - (Object) add_image(options = {}) + + + + + + + + + + + + +

    +Adds an image to the chart. +

    +
    +
  • @@ -488,21 +540,21 @@ The worksheet that owns this drawing
     
     
    -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
     
    @@ -557,12 +609,12 @@ in this version
     
     
    -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 +

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array) + + + +
    • + +
    + +
    + + + @@ -672,12 +786,12 @@ collection.
     
     
    -51
    -52
    -53
    +60 +61 +62 + +
    +
    +
    +
    +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
     
    -
    # 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, options={})
    -  TwoCellAnchor.new(self, chart_type, options)
    -  @anchors.last.graphic_frame.chart
    +  TwoCellAnchor.new(self, options)
    +  @anchors.last.add_chart(chart_type, options)
    +end
    +
    +
    +
    + +
    +

    + + - (Object) add_image(options = {}) + + + +

    +
    + +
    + Note: +

    +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 +

    + + +
    +
    +
    + + +

    See Also:

    + + +
    + + + @@ -1088,17 +1266,17 @@ Serializes the drawing
     
     
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    +142 +143 +144 +145 +146 +147 +148 +149
    +
    +
    +
    +90
    +91
    +92
    +93
    +
    +
    # File 'lib/axlsx/drawing/drawing.rb', line 90
    +
    +def add_image(options={})
    +  OneCellAnchor.new(self, options)
    +  @anchors.last.object
     end
     
    -
    # 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