summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/vml_shape.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-03-16 11:40:54 +0900
committerRandy Morgan <[email protected]>2013-03-16 11:40:54 +0900
commit38e1638fa715398429797276058f2c18e9e21e9b (patch)
tree30fd423d54033d2a525ebd6092f6da7a1342efbd /lib/axlsx/drawing/vml_shape.rb
parent0cb6eec06b6e13df28a6ce9e0b90e4e1ed8d5b28 (diff)
downloadcaxlsx-38e1638fa715398429797276058f2c18e9e21e9b.tar.gz
caxlsx-38e1638fa715398429797276058f2c18e9e21e9b.zip
First run at 'hidden' comments WIP
The xml is genrated correcty, but the comment still shows until it is selected once in the excel ui - so I must be missing something.
Diffstat (limited to 'lib/axlsx/drawing/vml_shape.rb')
-rw-r--r--lib/axlsx/drawing/vml_shape.rb95
1 files changed, 18 insertions, 77 deletions
diff --git a/lib/axlsx/drawing/vml_shape.rb b/lib/axlsx/drawing/vml_shape.rb
index 701456f3..8dc83c3b 100644
--- a/lib/axlsx/drawing/vml_shape.rb
+++ b/lib/axlsx/drawing/vml_shape.rb
@@ -4,95 +4,35 @@ module Axlsx
class VmlShape
include Axlsx::OptionsParser
+ include Axlsx::Accessors
# Creates a new VmlShape
- # @option options [Integer|String] left_column
- # @option options [Integer|String] left_offset
- # @option options [Integer|String] top_row
- # @option options [Integer|String] top_offset
- # @option options [Integer|String] right_column
- # @option options [Integer|String] right_offset
- # @option options [Integer|String] bottom_row
- # @option options [Integer|String] bottom_offset
+ # @option options [Integer] row
+ # @option options [Integer] column
+ # @option options [Integer] left_column
+ # @option options [Integer] left_offset
+ # @option options [Integer] top_row
+ # @option options [Integer] top_offset
+ # @option options [Integer] right_column
+ # @option options [Integer] right_offset
+ # @option options [Integer] bottom_row
+ # @option options [Integer] bottom_offset
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 = (0...8).map{65.+(rand(25)).chr}.join
parse_options options
yield self if block_given?
end
- # The row anchor position for this shape determined by the comment's ref value
- # @return [Integer]
- attr_reader :row
+ unsigned_int_attr_accessor :row, :column, :left_column, :left_offset, :top_row, :top_offset,
+ :right_column, :right_offset, :bottom_row, :bottom_offset
- # The column anchor position for this shape determined by the comment's ref value
- # @return [Integer]
- attr_reader :column
-
- # The left column for this shape
- # @return [Integer]
- attr_reader :left_column
-
- # The left offset for this shape
- # @return [Integer]
- attr_reader :left_offset
-
- # The top row for this shape
- # @return [Integer]
- attr_reader :top_row
-
- # The top offset for this shape
- # @return [Integer]
- attr_reader :top_offset
-
- # The right column for this shape
- # @return [Integer]
- attr_reader :right_column
-
- # The right offset for this shape
- # @return [Integer]
- attr_reader :right_offset
-
- # The botttom row for this shape
- # @return [Integer]
- attr_reader :bottom_row
-
- # The bottom offset for this shape
- # @return [Integer]
- attr_reader :bottom_offset
-
- # @see column
- def column=(v); Axlsx::validate_integerish(v); @column = v.to_i end
-
- # @see row
- def row=(v); Axlsx::validate_integerish(v); @row = v.to_i end
- # @see left_column
- def left_column=(v); Axlsx::validate_integerish(v); @left_column = v.to_i end
-
- # @see left_offset
- def left_offset=(v); Axlsx::validate_integerish(v); @left_offset = v.to_i end
-
- # @see top_row
- def top_row=(v); Axlsx::validate_integerish(v); @top_row = v.to_i end
-
- # @see top_offset
- def top_offset=(v); Axlsx::validate_integerish(v); @top_offset = v.to_i end
-
- # @see right_column
- def right_column=(v); Axlsx::validate_integerish(v); @right_column = v.to_i end
-
- # @see right_offset
- def right_offset=(v); Axlsx::validate_integerish(v); @right_offset = v.to_i end
-
- # @see bottom_row
- def bottom_row=(v); Axlsx::validate_integerish(v); @bottom_row = v.to_i end
-
- # @see bottom_offset
- def bottom_offset=(v); Axlsx::validate_integerish(v); @bottom_offset = v.to_i end
+ boolean_attr_accessor :visible
# serialize the shape to a string
# @param [String] str
@@ -100,7 +40,8 @@ module Axlsx
def to_xml_string(str ='')
str << <<SHAME_ON_YOU
-<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto">
+<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto"
+ style="visiblity:#{@visible ? 'visible' : 'hidden'}">
<v:fill color2="#ffffa1 [80]"/>
<v:shadow on="t" obscured="t"/>
<v:path o:connecttype="none"/>
@@ -115,7 +56,7 @@ str << <<SHAME_ON_YOU
<x:AutoFill>False</x:AutoFill>
<x:Row>#{row}</x:Row>
<x:Column>#{column}</x:Column>
- <x:Visible/>
+ #{@visible ? '<x:Visible/>' : ''}
</x:ClientData>
</v:shape>
SHAME_ON_YOU