Class: Axlsx::VmlShape

Inherits:
Object
  • Object
show all
Includes:
Accessors, OptionsParser
Defined in:
lib/axlsx/drawing/vml_shape.rb

Overview

A VmlShape is used to position and render a comment.

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ VmlShape

Creates a new VmlShape

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • row (Integer)
  • column (Integer)
  • left_column (Integer)
  • left_offset (Integer)
  • top_row (Integer)
  • top_offset (Integer)
  • right_column (Integer)
  • right_offset (Integer)
  • bottom_row (Integer)
  • bottom_offset (Integer)

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/axlsx/drawing/vml_shape.rb', line 20

def initialize(options = {})
  @row = @column = @left_column = @top_row = @right_column = @bottom_row = 0
  @left_offset = 15
  @top_offset = 2
  @right_offset = 50
  @bottom_offset = 5
  @visible = true
  @id = Array.new(8) { rand(65..89).chr }.join
  parse_options options
  yield self if block_given?
end

Instance Method Details

#to_xml_string(str = +'')) ⇒ String

serialize the shape to a string

Parameters:

  • str (String) (defaults to: +''))

Returns:

  • (String)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/axlsx/drawing/vml_shape.rb', line 40

def to_xml_string(str = +'')
  str << "\n    <v:shape id=\"\#{@id}\" type=\"#_x0000_t202\" fillcolor=\"#ffffa1 [80]\" o:insetmode=\"auto\"\n      style=\"visibility:\#{@visible ? 'visible' : 'hidden'}\">\n      <v:fill color2=\"#ffffa1 [80]\"/>\n      <v:shadow on=\"t\" obscured=\"t\"/>\n      <v:path o:connecttype=\"none\"/>\n      <v:textbox style='mso-fit-text-with-word-wrap:t'>\n       <div style='text-align:left'></div>\n      </v:textbox>\n\n      <x:ClientData ObjectType=\"Note\">\n       <x:MoveWithCells/>\n       <x:SizeWithCells/>\n       <x:Anchor>\#{left_column}, \#{left_offset}, \#{top_row}, \#{top_offset}, \#{right_column}, \#{right_offset}, \#{bottom_row}, \#{bottom_offset}</x:Anchor>\n       <x:AutoFill>False</x:AutoFill>\n       <x:Row>\#{row}</x:Row>\n       <x:Column>\#{column}</x:Column>\n       \#{'<x:Visible/>' if @visible}\n      </x:ClientData>\n     </v:shape>\n  XML\nend\n"