def insert_shape(*args)
      # Check for a cell reference in A1 notation and substitute row and column.
      row_start, column_start, shape, x_offset, y_offset, x_scale, y_scale =
        row_col_notation(args)
      if [row_start, column_start, shape].include?(nil)
        raise "Insufficient arguments in insert_shape()"
      end

      shape.set_position(
                           row_start, column_start, x_offset, y_offset,
                           x_scale, y_scale
                           )
      # Assign a shape ID.
      while true
        id = shape.id || 0
        used = @shape_hash[id]

        # Test if shape ID is already used. Otherwise assign a new one.
        if !used && id != 0
          break
        else
          @last_shape_id += 1
          shape.id = @last_shape_id
        end
      end

      # Allow lookup of entry into shape array by shape ID.
      @shape_hash[shape.id] = shape.element = @shapes.size

      if ptrue?(shape.stencil)
        # Insert a copy of the shape, not a reference so that the shape is
        # used as a stencil. Previously stamped copies don't get modified
        # if the stencil is modified.
        insert = shape.dup
      else
        insert = shape
      end

      # For connectors change x/y coords based on location of connected shapes.
      insert.auto_locate_connectors(@shapes, @shape_hash)

      # Insert a link to the shape on the list of shapes. Connection to
      # the parent shape is maintained.
      @shapes << insert
      insert
    end
def insert_shape(*args)
      # Check for a cell reference in A1 notation and substitute row and column.
      row_start, column_start, shape, x_offset, y_offset, x_scale, y_scale =
        row_col_notation(args)
      if [row_start, column_start, shape].include?(nil)
        raise "Insufficient arguments in insert_shape()"
      end

      shape.set_position(
                           row_start, column_start, x_offset, y_offset,
                           x_scale, y_scale
                           )
      # Assign a shape ID.
      while true
        id = shape.id || 0
        used = @shape_hash[id]

        # Test if shape ID is already used. Otherwise assign a new one.
        if !used && id != 0
          break
        else
          @last_shape_id += 1
          shape.id = @last_shape_id
        end
      end

      # Allow lookup of entry into shape array by shape ID.
      @shape_hash[shape.id] = shape.element = @shapes.size

      if ptrue?(shape.stencil)
        # Insert a copy of the shape, not a reference so that the shape is
        # used as a stencil. Previously stamped copies don't get modified
        # if the stencil is modified.
        insert = shape.dup
      else
        insert = shape
      end

      # For connectors change x/y coords based on location of connected shapes.
      insert.auto_locate_connectors(@shapes, @shape_hash)

      # Insert a link to the shape on the list of shapes. Connection to
      # the parent shape is maintained.
      @shapes << insert
      insert
    end
:call-seq:
   insert_shape(row, col, shape [ , x, y, x_scale, y_scale ] )

 Insert a shape into the worksheet.

 This method can be used to insert a Shape object into a worksheet.
 The Shape must be created by the add_shape() Workbook method.

   shape = workbook.add_shape(:name => 'My Shape', :type => 'plus')

   # Configure the shape.
   shape.set_text('foo')
   ...

   # Insert the shape into the a worksheet.
   worksheet.insert_shape('E2', shape)

 See add_shape() for details on how to create the Shape object
 and Writexlsx::Shape for details on how to configure it.

 The +x+, +y+, +x_scale+ and +y_scale+ parameters are optional.

 The parameters +x+ and +y+ can be used to specify an offset
 from the top left hand corner of the cell specified by +row+ and +col+.
 The offset values are in pixels.

   worksheet1.insert_shape('E2', chart, 3, 3)

 The parameters +x_scale+ and +y_scale+ can be used to scale the
 inserted shape horizontally and vertically:

   # Scale the width by 120% and the height by 150%
   worksheet.insert_shape('E2', shape, 0, 0, 1.2, 1.5)

 See also the shape*.rb programs in the examples directory of the distro.