axlsx 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -5
- data/examples/colored_links.rb +59 -0
- data/examples/example.rb +421 -266
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/finance.rb +82 -0
- data/examples/finance.xlsx +0 -0
- data/examples/financial.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/where_is_my_color.xlsx +0 -0
- data/lib/axlsx.rb +11 -4
- data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/content_type/default.rb +6 -37
- data/lib/axlsx/content_type/override.rb +6 -38
- data/lib/axlsx/doc_props/app.rb +7 -4
- data/lib/axlsx/drawing/axis.rb +3 -3
- data/lib/axlsx/drawing/chart.rb +2 -3
- data/lib/axlsx/drawing/d_lbls.rb +21 -31
- data/lib/axlsx/drawing/drawing.rb +6 -0
- data/lib/axlsx/drawing/hyperlink.rb +40 -32
- data/lib/axlsx/drawing/marker.rb +13 -13
- data/lib/axlsx/drawing/num_data.rb +6 -6
- data/lib/axlsx/drawing/num_data_source.rb +17 -16
- data/lib/axlsx/drawing/one_cell_anchor.rb +20 -22
- data/lib/axlsx/drawing/pic.rb +25 -27
- data/lib/axlsx/drawing/picture_locking.rb +12 -44
- data/lib/axlsx/drawing/scaling.rb +13 -13
- data/lib/axlsx/drawing/scatter_chart.rb +3 -3
- data/lib/axlsx/drawing/series.rb +3 -6
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +7 -8
- data/lib/axlsx/drawing/view_3D.rb +51 -37
- data/lib/axlsx/drawing/vml_shape.rb +23 -23
- data/lib/axlsx/package.rb +14 -16
- data/lib/axlsx/stylesheet/border.rb +29 -20
- data/lib/axlsx/stylesheet/border_pr.rb +5 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +55 -29
- data/lib/axlsx/stylesheet/cell_protection.rb +7 -4
- data/lib/axlsx/stylesheet/cell_style.rb +19 -14
- data/lib/axlsx/stylesheet/color.rb +19 -16
- data/lib/axlsx/stylesheet/dxf.rb +4 -4
- data/lib/axlsx/stylesheet/font.rb +22 -22
- data/lib/axlsx/stylesheet/gradient_fill.rb +45 -21
- data/lib/axlsx/stylesheet/num_fmt.rb +22 -13
- data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/stylesheet/table_style.rb +17 -16
- data/lib/axlsx/stylesheet/table_style_element.rb +15 -11
- data/lib/axlsx/stylesheet/table_styles.rb +14 -11
- data/lib/axlsx/stylesheet/xf.rb +28 -26
- data/lib/axlsx/util/accessors.rb +49 -0
- data/lib/axlsx/util/options_parser.rb +15 -0
- data/lib/axlsx/util/serialized_attributes.rb +46 -0
- data/lib/axlsx/util/simple_typed_list.rb +16 -4
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +13 -58
- data/lib/axlsx/workbook/workbook.rb +27 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -19
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +20 -27
- data/lib/axlsx/workbook/worksheet/cell.rb +38 -39
- data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
- data/lib/axlsx/workbook/worksheet/cfvos.rb +18 -0
- data/lib/axlsx/workbook/worksheet/col.rb +34 -27
- data/lib/axlsx/workbook/worksheet/color_scale.rb +7 -13
- data/lib/axlsx/workbook/worksheet/comment.rb +14 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +27 -25
- data/lib/axlsx/workbook/worksheet/data_bar.rb +44 -34
- data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
- data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +20 -20
- data/lib/axlsx/workbook/worksheet/page_margins.rb +21 -19
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -9
- data/lib/axlsx/workbook/worksheet/page_setup.rb +20 -19
- data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
- data/lib/axlsx/workbook/worksheet/print_options.rb +8 -30
- data/lib/axlsx/workbook/worksheet/protected_range.rb +16 -13
- data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -26
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +19 -57
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +51 -155
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +68 -234
- data/lib/axlsx/workbook/worksheet/table.rb +16 -18
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +10 -27
- data/lib/axlsx/workbook/worksheet/worksheet.rb +6 -7
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +11 -33
- data/test/content_type/tc_default.rb +0 -11
- data/test/content_type/tc_override.rb +0 -13
- data/test/drawing/tc_d_lbls.rb +14 -4
- data/test/tc_axlsx.rb +20 -2
- data/test/workbook/tc_defined_name.rb +2 -2
- data/test/workbook/tc_workbook.rb +15 -0
- data/test/workbook/worksheet/tc_col.rb +11 -1
- data/test/workbook/worksheet/tc_pane.rb +5 -45
- data/test/workbook/worksheet/tc_selection.rb +9 -48
- metadata +13 -3
@@ -137,6 +137,12 @@ module Axlsx
|
|
137
137
|
"#{DRAWING_RELS_PN % (index+1)}"
|
138
138
|
end
|
139
139
|
|
140
|
+
# The index of a chart, image or hyperlink object this drawing contains
|
141
|
+
def index_of(object)
|
142
|
+
objects = charts + images + hyperlinks
|
143
|
+
objects.index(object)
|
144
|
+
end
|
145
|
+
|
140
146
|
# The drawing's relationships.
|
141
147
|
# @return [Relationships]
|
142
148
|
def relationships
|
@@ -5,6 +5,29 @@ module Axlsx
|
|
5
5
|
# @see {file:README} README
|
6
6
|
class Hyperlink
|
7
7
|
|
8
|
+
include Axlsx::SerializedAttributes
|
9
|
+
include Axlsx::OptionsParser
|
10
|
+
|
11
|
+
#Creates a hyperlink object
|
12
|
+
# parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent
|
13
|
+
# @param [Pic] parent
|
14
|
+
# @option options [String] tooltip message shown when hyperlinked object is hovered over with mouse.
|
15
|
+
# @option options [String] tgtFrame Target frame for opening hyperlink
|
16
|
+
# @option options [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
|
17
|
+
# @option options [String] href the target resource this hyperlink links to. This is actually stored on the relationship.
|
18
|
+
# @option options [String] action A string that can be used to perform specific actions. For excel please see this reference: http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
19
|
+
# @option options [Boolean] endSnd terminate any sound events when processing this link
|
20
|
+
# @option options [Boolean] history include this link in the list of visited links for the applications history.
|
21
|
+
# @option options [Boolean] highlightClick indicate that the link has already been visited.
|
22
|
+
def initialize(parent, options={})
|
23
|
+
DataTypeValidator.validate "Hyperlink.parent", [Pic], parent
|
24
|
+
@parent = parent
|
25
|
+
parse_options options
|
26
|
+
yield self if block_given?
|
27
|
+
end
|
28
|
+
|
29
|
+
serializable_attributes :invalid_url, :action, :end_snd, :highlight_click, :history, :tgt_frame, :tooltip
|
30
|
+
|
8
31
|
# The destination of the hyperlink stored in the drawing's relationships document.
|
9
32
|
# @return [String]
|
10
33
|
attr_accessor :href
|
@@ -13,7 +36,9 @@ module Axlsx
|
|
13
36
|
#
|
14
37
|
# What exactly that means is beyond me so if you ever use this, let me know!
|
15
38
|
# @return [String]
|
16
|
-
attr_accessor :
|
39
|
+
attr_accessor :invalid_url
|
40
|
+
alias :invalidUrl :invalid_url
|
41
|
+
alias :invalidUrl= :invalid_url=
|
17
42
|
|
18
43
|
#An action to take when the link is clicked. The specification says "This can be used to specify a slide to be navigated to or a script of code to be run." but in most cases you will not need to do anything with this. MS does reserve a few interesting strings. @see http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
19
44
|
# @return [String]
|
@@ -21,20 +46,24 @@ module Axlsx
|
|
21
46
|
|
22
47
|
# Specifies if all sound events should be terminated when this link is clicked.
|
23
48
|
# @return [Boolean]
|
24
|
-
attr_reader :
|
49
|
+
attr_reader :end_snd
|
50
|
+
alias :endSnd :end_snd
|
25
51
|
|
26
52
|
# @see endSnd
|
27
53
|
# @param [Boolean] v The boolean value indicating the termination of playing sounds on click
|
28
54
|
# @return [Boolean]
|
29
|
-
def
|
55
|
+
def end_snd=(v) Axlsx::validate_boolean(v); @end_snd = v end
|
56
|
+
alias :endSnd= :end_snd=
|
30
57
|
|
31
58
|
# indicates that the link has already been clicked.
|
32
59
|
# @return [Boolean]
|
33
|
-
attr_reader :
|
60
|
+
attr_reader :highlight_click
|
61
|
+
alias :highlightClick :highlight_click
|
34
62
|
|
35
63
|
# @see highlightClick
|
36
64
|
# @param [Boolean] v The value to assign
|
37
|
-
def
|
65
|
+
def highlight_click=(v) Axlsx::validate_boolean(v); @highlight_click = v end
|
66
|
+
alias :highlightClick= :highlight_click=
|
38
67
|
|
39
68
|
# From the specs: Specifies whether to add this URI to the history when navigating to it. This allows for the viewing of this presentation without the storing of history information on the viewing machine. If this attribute is omitted, then a value of 1 or true is assumed.
|
40
69
|
# @return [Boolean]
|
@@ -46,50 +75,29 @@ module Axlsx
|
|
46
75
|
|
47
76
|
# From the specs: Specifies the target frame that is to be used when opening this hyperlink. When the hyperlink is activated this attribute is used to determine if a new window is launched for viewing or if an existing one can be used. If this attribute is omitted, than a new window is opened.
|
48
77
|
# @return [String]
|
49
|
-
attr_accessor :
|
78
|
+
attr_accessor :tgt_frame
|
79
|
+
alias :tgtFrame :tgt_frame
|
80
|
+
alias :tgtFrame= :tgt_frame=
|
50
81
|
|
51
82
|
# Text to show when you mouse over the hyperlink. If you do not set this, the href property will be shown.
|
52
83
|
# @return [String]
|
53
84
|
attr_accessor :tooltip
|
54
85
|
|
55
|
-
#Creates a hyperlink object
|
56
|
-
# parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent
|
57
|
-
# @param [Pic] parent
|
58
|
-
# @option options [String] tooltip message shown when hyperlinked object is hovered over with mouse.
|
59
|
-
# @option options [String] tgtFrame Target frame for opening hyperlink
|
60
|
-
# @option options [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
|
61
|
-
# @option options [String] href the target resource this hyperlink links to.
|
62
|
-
# @option options [String] action A string that can be used to perform specific actions. For excel please see this reference: http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
63
|
-
# @option options [Boolean] endSnd terminate any sound events when processing this link
|
64
|
-
# @option options [Boolean] history include this link in the list of visited links for the applications history.
|
65
|
-
# @option options [Boolean] highlightClick indicate that the link has already been visited.
|
66
|
-
def initialize(parent, options={})
|
67
|
-
DataTypeValidator.validate "Hyperlink.parent", [Pic], parent
|
68
|
-
@parent = parent
|
69
|
-
options.each do |o|
|
70
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
71
|
-
end
|
72
|
-
yield self if block_given?
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
86
|
# Serializes the object
|
77
87
|
# @param [String] str
|
78
88
|
# @return [String]
|
79
89
|
def to_xml_string(str = '')
|
80
|
-
h = self.instance_values.merge({:'r:id' => "rId#{id}", :'xmlns:r' => XML_NS_R })
|
81
|
-
h.delete('href')
|
82
|
-
h.delete('parent')
|
83
90
|
str << '<a:hlinkClick '
|
84
|
-
str
|
91
|
+
serialized_attributes str, {:'r:id' => "rId#{id}", :'xmlns:r' => XML_NS_R }
|
85
92
|
str << '/>'
|
86
93
|
end
|
87
94
|
|
88
95
|
private
|
96
|
+
|
89
97
|
# The relational ID for this hyperlink
|
90
98
|
# @return [Integer]
|
91
99
|
def id
|
92
|
-
@parent.anchor.drawing.
|
100
|
+
@parent.anchor.drawing.index_of(self)+1
|
93
101
|
end
|
94
102
|
|
95
103
|
end
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -5,6 +5,18 @@ module Axlsx
|
|
5
5
|
# @see Worksheet#add_chart
|
6
6
|
class Marker
|
7
7
|
|
8
|
+
include Axlsx::OptionsParser
|
9
|
+
|
10
|
+
# Creates a new Marker object
|
11
|
+
# @option options [Integer] col
|
12
|
+
# @option options [Integer] colOff
|
13
|
+
# @option options [Integer] row
|
14
|
+
# @option options [Integer] rowOff
|
15
|
+
def initialize(options={})
|
16
|
+
@col, @colOff, @row, @rowOff = 0, 0, 0, 0
|
17
|
+
parse_options options
|
18
|
+
end
|
19
|
+
|
8
20
|
# The column this marker anchors to
|
9
21
|
# @return [Integer]
|
10
22
|
attr_reader :col
|
@@ -21,19 +33,7 @@ module Axlsx
|
|
21
33
|
# @return [Integer]
|
22
34
|
attr_reader :rowOff
|
23
35
|
|
24
|
-
|
25
|
-
# @option options [Integer] col
|
26
|
-
# @option options [Integer] colOff
|
27
|
-
# @option options [Integer] row
|
28
|
-
# @option options [Integer] rowOff
|
29
|
-
def initialize(options={})
|
30
|
-
@col, @colOff, @row, @rowOff = 0, 0, 0, 0
|
31
|
-
options.each do |o|
|
32
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @see col
|
36
|
+
# @see col
|
37
37
|
def col=(v) Axlsx::validate_unsigned_int v; @col = v end
|
38
38
|
# @see colOff
|
39
39
|
def colOff=(v) Axlsx::validate_int v; @colOff = v end
|
@@ -4,9 +4,7 @@ module Axlsx
|
|
4
4
|
#This class specifies data for a particular data point. It is used for both numCache and numLit object
|
5
5
|
class NumData
|
6
6
|
|
7
|
-
|
8
|
-
# @return [String]
|
9
|
-
attr_reader :format_code
|
7
|
+
include Axlsx::OptionsParser
|
10
8
|
|
11
9
|
# creates a new NumVal object
|
12
10
|
# @option options [String] formatCode
|
@@ -15,11 +13,13 @@ module Axlsx
|
|
15
13
|
def initialize(options={})
|
16
14
|
@format_code = "General"
|
17
15
|
@pt = SimpleTypedList.new NumVal
|
18
|
-
options
|
19
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
20
|
-
end
|
16
|
+
parse_options options
|
21
17
|
end
|
22
18
|
|
19
|
+
# A string representing the format code to apply. For more information see see the SpreadsheetML numFmt element's (§18.8.30) formatCode attribute.
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :format_code
|
22
|
+
|
23
23
|
# Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
|
24
24
|
# @param [Array] values An array of cells or values.
|
25
25
|
def data=(values=[])
|
@@ -3,18 +3,7 @@ module Axlsx
|
|
3
3
|
# A numeric data source for use by charts.
|
4
4
|
class NumDataSource
|
5
5
|
|
6
|
-
|
7
|
-
# Only items defined in allowed_tag_names are allowed
|
8
|
-
# @return [Symbol]
|
9
|
-
attr_reader :tag_name
|
10
|
-
|
11
|
-
attr_reader :data
|
12
|
-
|
13
|
-
# allowed element tag names
|
14
|
-
# @return [Array]
|
15
|
-
def self.allowed_tag_names
|
16
|
-
[:yVal, :val]
|
17
|
-
end
|
6
|
+
include Axlsx::OptionsParser
|
18
7
|
|
19
8
|
# creates a new NumDataSource object
|
20
9
|
# @option options [Array] data An array of Cells or Numeric objects
|
@@ -30,12 +19,24 @@ module Axlsx
|
|
30
19
|
if options[:data] && options[:data].first.is_a?(Cell)
|
31
20
|
@f = Axlsx::cell_range(options[:data])
|
32
21
|
end
|
33
|
-
options
|
34
|
-
|
35
|
-
|
22
|
+
parse_options options
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# The tag name to use when serializing this data source.
|
27
|
+
# Only items defined in allowed_tag_names are allowed
|
28
|
+
# @return [Symbol]
|
29
|
+
attr_reader :tag_name
|
30
|
+
|
31
|
+
attr_reader :data
|
32
|
+
|
33
|
+
# allowed element tag names
|
34
|
+
# @return [Array]
|
35
|
+
def self.allowed_tag_names
|
36
|
+
[:yVal, :val]
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
# sets the tag name for this data source
|
39
40
|
# @param [Symbol] v One of the allowed_tag_names
|
40
41
|
def tag_name=(v)
|
41
42
|
Axlsx::RestrictionValidator.validate "#{self.class.name}.tag_name", self.class.allowed_tag_names, v
|
@@ -6,6 +6,26 @@ module Axlsx
|
|
6
6
|
# @see Worksheet#add_image
|
7
7
|
class OneCellAnchor
|
8
8
|
|
9
|
+
include Axlsx::OptionsParser
|
10
|
+
|
11
|
+
# Creates a new OneCellAnchor object and an Pic associated with it.
|
12
|
+
# @param [Drawing] drawing
|
13
|
+
# @option options [Array] start_at the col, row to start at
|
14
|
+
# @option options [Integer] width
|
15
|
+
# @option options [Integer] height
|
16
|
+
# @option options [String] image_src the file location of the image you will render
|
17
|
+
# @option options [String] name the name attribute for the rendered image
|
18
|
+
# @option options [String] descr the description of the image rendered
|
19
|
+
def initialize(drawing, options={})
|
20
|
+
@drawing = drawing
|
21
|
+
@width = 0
|
22
|
+
@height = 0
|
23
|
+
drawing.anchors << self
|
24
|
+
@from = Marker.new
|
25
|
+
parse_options options
|
26
|
+
@object = Pic.new(self, options)
|
27
|
+
end
|
28
|
+
|
9
29
|
# A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
|
10
30
|
# @return [Marker]
|
11
31
|
attr_reader :from
|
@@ -28,27 +48,6 @@ module Axlsx
|
|
28
48
|
# @return [Integer]
|
29
49
|
attr_reader :height
|
30
50
|
|
31
|
-
|
32
|
-
# Creates a new OneCellAnchor object and an Pic associated with it.
|
33
|
-
# @param [Drawing] drawing
|
34
|
-
# @option options [Array] start_at the col, row to start at
|
35
|
-
# @option options [Integer] width
|
36
|
-
# @option options [Integer] height
|
37
|
-
# @option options [String] image_src the file location of the image you will render
|
38
|
-
# @option options [String] name the name attribute for the rendered image
|
39
|
-
# @option options [String] descr the description of the image rendered
|
40
|
-
def initialize(drawing, options={})
|
41
|
-
@drawing = drawing
|
42
|
-
@width = 0
|
43
|
-
@height = 0
|
44
|
-
drawing.anchors << self
|
45
|
-
@from = Marker.new
|
46
|
-
options.each do |o|
|
47
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
48
|
-
end
|
49
|
-
@object = Pic.new(self, options)
|
50
|
-
end
|
51
|
-
|
52
51
|
# @see height
|
53
52
|
def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end
|
54
53
|
|
@@ -61,7 +60,6 @@ module Axlsx
|
|
61
60
|
@drawing.anchors.index(self)
|
62
61
|
end
|
63
62
|
|
64
|
-
|
65
63
|
# Serializes the object
|
66
64
|
# @param [String] str
|
67
65
|
# @return [String]
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -5,6 +5,26 @@ module Axlsx
|
|
5
5
|
# @see Worksheet#add_image
|
6
6
|
class Pic
|
7
7
|
|
8
|
+
include Axlsx::OptionsParser
|
9
|
+
|
10
|
+
# Creates a new Pic(ture) object
|
11
|
+
# @param [Anchor] anchor the anchor that holds this image
|
12
|
+
# @option options [String] name
|
13
|
+
# @option options [String] descr
|
14
|
+
# @option options [String] image_src
|
15
|
+
# @option options [Array] start_at
|
16
|
+
# @option options [Intger] width
|
17
|
+
# @option options [Intger] height
|
18
|
+
def initialize(anchor, options={})
|
19
|
+
@anchor = anchor
|
20
|
+
@hyperlink = nil
|
21
|
+
@anchor.drawing.worksheet.workbook.images << self
|
22
|
+
parse_options options
|
23
|
+
start_at(*options[:start_at]) if options[:start_at]
|
24
|
+
yield self if block_given?
|
25
|
+
@picture_locking = PictureLocking.new(options)
|
26
|
+
end
|
27
|
+
|
8
28
|
# allowed file extenstions
|
9
29
|
ALLOWED_EXTENSIONS = ['gif', 'jpeg', 'png', 'jpg']
|
10
30
|
|
@@ -12,7 +32,6 @@ module Axlsx
|
|
12
32
|
# @return [String]
|
13
33
|
attr_reader :name
|
14
34
|
|
15
|
-
|
16
35
|
# A description of the picture
|
17
36
|
# @return [String]
|
18
37
|
attr_reader :descr
|
@@ -29,26 +48,6 @@ module Axlsx
|
|
29
48
|
# The picture locking attributes for this picture
|
30
49
|
attr_reader :picture_locking
|
31
50
|
|
32
|
-
# Creates a new Pic(ture) object
|
33
|
-
# @param [Anchor] anchor the anchor that holds this image
|
34
|
-
# @option options [String] name
|
35
|
-
# @option options [String] descr
|
36
|
-
# @option options [String] image_src
|
37
|
-
# @option options [Array] start_at
|
38
|
-
# @option options [Intger] width
|
39
|
-
# @option options [Intger] height
|
40
|
-
def initialize(anchor, options={})
|
41
|
-
@anchor = anchor
|
42
|
-
@hyperlink = nil
|
43
|
-
@anchor.drawing.worksheet.workbook.images << self
|
44
|
-
options.each do |o|
|
45
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
46
|
-
end
|
47
|
-
start_at(*options[:start_at]) if options[:start_at]
|
48
|
-
yield self if block_given?
|
49
|
-
@picture_locking = PictureLocking.new(options)
|
50
|
-
end
|
51
|
-
|
52
51
|
attr_reader :hyperlink
|
53
52
|
|
54
53
|
# sets or updates a hyperlink for this image.
|
@@ -136,8 +135,8 @@ module Axlsx
|
|
136
135
|
use_one_cell_anchor unless @anchor.is_a?(OneCellAnchor)
|
137
136
|
@anchor.height = v
|
138
137
|
end
|
139
|
-
|
140
|
-
|
138
|
+
|
139
|
+
# This is a short cut method to set the start anchor position
|
141
140
|
# If you need finer granularity in positioning use
|
142
141
|
# graphic_frame.anchor.from.colOff / rowOff
|
143
142
|
# @param [Integer] x The column
|
@@ -148,7 +147,7 @@ module Axlsx
|
|
148
147
|
@anchor.from.row = y
|
149
148
|
@anchor.from
|
150
149
|
end
|
151
|
-
|
150
|
+
|
152
151
|
# noop if not using a two cell anchor
|
153
152
|
# @param [Integer] x The column
|
154
153
|
# @param [Integer] y The row
|
@@ -178,7 +177,7 @@ module Axlsx
|
|
178
177
|
str << '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>'
|
179
178
|
|
180
179
|
end
|
181
|
-
|
180
|
+
|
182
181
|
private
|
183
182
|
|
184
183
|
# Changes the anchor to a one cell anchor.
|
@@ -186,7 +185,7 @@ module Axlsx
|
|
186
185
|
return if @anchor.is_a?(OneCellAnchor)
|
187
186
|
swap_anchor(OneCellAnchor.new(@anchor.drawing, :from => @anchor.from))
|
188
187
|
end
|
189
|
-
|
188
|
+
|
190
189
|
#changes the anchor type to a two cell anchor
|
191
190
|
def use_two_cell_anchor
|
192
191
|
return if @anchor.is_a?(TwoCellAnchor)
|
@@ -202,6 +201,5 @@ module Axlsx
|
|
202
201
|
@anchor.drawing.anchors[@anchor.drawing.anchors.index(@anchor)] = new_anchor
|
203
202
|
@anchor = new_anchor
|
204
203
|
end
|
205
|
-
|
206
204
|
end
|
207
205
|
end
|
@@ -3,17 +3,17 @@ module Axlsx
|
|
3
3
|
# The picture locking class defines the locking properties for pictures in your workbook.
|
4
4
|
class PictureLocking
|
5
5
|
|
6
|
+
include Axlsx::OptionsParser
|
7
|
+
include Axlsx::SerializedAttributes
|
8
|
+
include Axlsx::Accessors
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :noAdjustHandles
|
15
|
-
attr_reader :noChangeArrowheads
|
16
|
-
attr_reader :noChangeShapeType
|
10
|
+
boolean_attr_accessor :noGrp, :noSelect, :noRot, :noChangeAspect,
|
11
|
+
:noMove, :noResize, :noEditPoints, :noAdjustHandles,
|
12
|
+
:noChangeArrowheads, :noChangeShapeType
|
13
|
+
|
14
|
+
serializable_attributes :noGrp, :noSelect, :noRot, :noChangeAspect,
|
15
|
+
:noMove, :noResize, :noEditPoints, :noAdjustHandles,
|
16
|
+
:noChangeArrowheads, :noChangeShapeType
|
17
17
|
|
18
18
|
# Creates a new PictureLocking object
|
19
19
|
# @option options [Boolean] noGrp
|
@@ -28,47 +28,15 @@ module Axlsx
|
|
28
28
|
# @option options [Boolean] noChangeShapeType
|
29
29
|
def initialize(options={})
|
30
30
|
@noChangeAspect = true
|
31
|
-
options
|
32
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
33
|
-
end
|
31
|
+
parse_options options
|
34
32
|
end
|
35
33
|
|
36
|
-
# @see noGrp
|
37
|
-
def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
|
38
|
-
|
39
|
-
# @see noSelect
|
40
|
-
def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
|
41
|
-
|
42
|
-
# @see noRot
|
43
|
-
def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
|
44
|
-
|
45
|
-
# @see noChangeAspect
|
46
|
-
def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
|
47
|
-
|
48
|
-
# @see noMove
|
49
|
-
def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
|
50
|
-
|
51
|
-
# @see noResize
|
52
|
-
def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
|
53
|
-
|
54
|
-
# @see noEditPoints
|
55
|
-
def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
|
56
|
-
|
57
|
-
# @see noAdjustHandles
|
58
|
-
def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
|
59
|
-
|
60
|
-
# @see noChangeArrowheads
|
61
|
-
def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
|
62
|
-
|
63
|
-
# @see noChangeShapeType
|
64
|
-
def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
|
65
|
-
|
66
34
|
# Serializes the object
|
67
35
|
# @param [String] str
|
68
36
|
# @return [String]
|
69
37
|
def to_xml_string(str = '')
|
70
38
|
str << '<a:picLocks '
|
71
|
-
str
|
39
|
+
serialized_attributes str
|
72
40
|
str << '/>'
|
73
41
|
end
|
74
42
|
|