Class: Axlsx::VmlShape

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

Overview

A VmlShape is used to position and render a comment.

Instance Attribute Summary collapse

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):

  • left_column (Integer|String)
  • left_offset (Integer|String)
  • top_row (Integer|String)
  • top_offset (Integer|String)
  • right_column (Integer|String)
  • right_offset (Integer|String)
  • bottom_row (Integer|String)
  • bottom_offset (Integer|String)

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
26
# File 'lib/axlsx/drawing/vml_shape.rb', line 17

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
  @id = (0...8).map{65.+(rand(25)).chr}.join
  parse_options options
  yield self if block_given?
end

Instance Attribute Details

#bottom_offsetInteger

The bottom offset for this shape

Returns:

  • (Integer)


66
67
68
# File 'lib/axlsx/drawing/vml_shape.rb', line 66

def bottom_offset
  @bottom_offset
end

#bottom_rowInteger

The botttom row for this shape

Returns:

  • (Integer)


62
63
64
# File 'lib/axlsx/drawing/vml_shape.rb', line 62

def bottom_row
  @bottom_row
end

#columnInteger

The column anchor position for this shape determined by the comment's ref value

Returns:

  • (Integer)


34
35
36
# File 'lib/axlsx/drawing/vml_shape.rb', line 34

def column
  @column
end

#left_columnInteger

The left column for this shape

Returns:

  • (Integer)


38
39
40
# File 'lib/axlsx/drawing/vml_shape.rb', line 38

def left_column
  @left_column
end

#left_offsetInteger

The left offset for this shape

Returns:

  • (Integer)


42
43
44
# File 'lib/axlsx/drawing/vml_shape.rb', line 42

def left_offset
  @left_offset
end

#right_columnInteger

The right column for this shape

Returns:

  • (Integer)


54
55
56
# File 'lib/axlsx/drawing/vml_shape.rb', line 54

def right_column
  @right_column
end

#right_offsetInteger

The right offset for this shape

Returns:

  • (Integer)


58
59
60
# File 'lib/axlsx/drawing/vml_shape.rb', line 58

def right_offset
  @right_offset
end

#rowInteger

The row anchor position for this shape determined by the comment's ref value

Returns:

  • (Integer)


30
31
32
# File 'lib/axlsx/drawing/vml_shape.rb', line 30

def row
  @row
end

#top_offsetInteger

The top offset for this shape

Returns:

  • (Integer)


50
51
52
# File 'lib/axlsx/drawing/vml_shape.rb', line 50

def top_offset
  @top_offset
end

#top_rowInteger

The top row for this shape

Returns:

  • (Integer)


46
47
48
# File 'lib/axlsx/drawing/vml_shape.rb', line 46

def top_row
  @top_row
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

serialize the shape to a string

Parameters:

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

Returns:

  • (String)


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/axlsx/drawing/vml_shape.rb', line 100

def to_xml_string(str ='')
str << <<SHAME_ON_YOU

<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto">
  <v:fill color2="#ffffa1 [80]"/>
  <v:shadow on="t" obscured="t"/>
  <v:path o:connecttype="none"/>
  <v:textbox style='mso-fit-text-with-word-wrap:t'>
   <div style='text-align:left'></div>
  </v:textbox>

  <x:ClientData ObjectType="Note">
   <x:MoveWithCells/>
   <x:SizeWithCells/>
   <x:Anchor>#{left_column}, #{left_offset}, #{top_row}, #{top_offset}, #{right_column}, #{right_offset}, #{bottom_row}, #{bottom_offset}</x:Anchor>
   <x:AutoFill>False</x:AutoFill>
   <x:Row>#{row}</x:Row>
   <x:Column>#{column}</x:Column>
   <x:Visible/>
  </x:ClientData>
 </v:shape>
SHAME_ON_YOU

end