axlsx 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +23 -0
- data/README.md +50 -53
- data/examples/example.rb +14 -2
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +1 -1
- data/lib/axlsx/drawing/chart.rb +1 -1
- data/lib/axlsx/drawing/drawing.rb +12 -1
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb +95 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +64 -0
- data/lib/axlsx/drawing/pic.rb +29 -3
- data/lib/axlsx/package.rb +4 -4
- data/lib/axlsx/rels/relationship.rb +16 -1
- data/lib/axlsx/rels/relationships.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/util/cbf.rb +68 -33
- data/lib/axlsx/util/constants.rb +12 -6
- data/lib/axlsx/util/ms_off_crypto.rb +9 -9
- data/lib/axlsx/util/storage.rb +0 -1
- data/lib/axlsx/util/validators.rb +1 -1
- data/lib/axlsx/version.rb +4 -2
- data/lib/axlsx/workbook/workbook.rb +14 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +2 -1
- data/test/drawing/tc_hyperlink.rb +70 -0
- data/test/drawing/tc_hyperlink.rb~ +71 -0
- data/test/drawing/tc_pic.rb +6 -0
- data/test/rels/tc_relationship.rb +5 -0
- data/test/workbook/worksheet/tc_worksheet.rb +7 -0
- metadata +27 -24
- data/test/drawing/tc_line_series.tc~ +0 -34
- data/test/drawing/tc_picture_locking.rb~ +0 -77
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **December.14.11**: 1.0.14 release
|
4
|
+
- Added support for merging cells
|
5
|
+
- Added support for auto filters
|
6
|
+
- Improved auto width calculations
|
7
|
+
- Improved charts
|
8
|
+
- Updated examples to output to a single workbook with multiple sheets
|
9
|
+
- Added access to app and core package objects so you can set the creator and other properties of the package
|
10
|
+
- The beginning of password protected xlsx files - roadmapped for January release.
|
11
|
+
|
12
|
+
- **December.8.11**: 1.0.13 release
|
13
|
+
- Fixing .gemspec errors that caused gem to miss the lib directory. Sorry about that.
|
14
|
+
|
15
|
+
- **December.7.11**: 1.0.12 release
|
16
|
+
DO NOT USE THIS VERSION = THE GEM IS BROKEN
|
17
|
+
- changed dependency from 'zip' gem to 'rubyzip' and added conditional code to force binary encoding to resolve issue with excel 2011
|
18
|
+
- Patched bug in app.xml that would ignore user specified properties.
|
19
|
+
- **December.5.11**: 1.0.11 release
|
20
|
+
- Added [] methods to worksheet and workbook to provide name based access to cells.
|
21
|
+
- Added support for functions as cell values
|
22
|
+
- Updated color creation so that two character shorthand values can be used like 'FF' for 'FFFFFFFF' or 'D8' for 'FFD8D8D8'
|
23
|
+
- Examples for all this fun stuff added to the readme
|
24
|
+
- Clean up and support for 1.9.2 and travis integration
|
25
|
+
- Added support for string based cell referencing to chart start_at and end_at. That means you can now use :start_at=>"A1" when using worksheet.add_chart, or chart.start_at ="A1" in addition to passing a cell or the x, y coordinates.
|
3
26
|
|
4
27
|
- **October.30.11**: 1.0.10 release
|
5
28
|
- Updating gemspec to lower gem version requirements.
|
data/README.md
CHANGED
@@ -7,10 +7,10 @@ Axlsx: Office Open XML Spreadsheet Generation
|
|
7
7
|
**Author**: Randy Morgan
|
8
8
|
**Copyright**: 2011
|
9
9
|
**License**: MIT License
|
10
|
-
**Latest Version**: 1.0.
|
10
|
+
**Latest Version**: 1.0.16
|
11
11
|
**Ruby Version**: 1.8.7, 1.9.2, 1.9.3
|
12
12
|
|
13
|
-
**Release Date**:
|
13
|
+
**Release Date**: February 2nd 2012
|
14
14
|
|
15
15
|
Synopsis
|
16
16
|
--------
|
@@ -44,7 +44,7 @@ Feature List
|
|
44
44
|
|
45
45
|
**6. Support for automatically formatted 1904 and 1900 epocs configurable in the workbook.
|
46
46
|
|
47
|
-
**7. Add jpg, gif and png images to worksheets
|
47
|
+
**7. Add jpg, gif and png images to worksheets with hyperlinks
|
48
48
|
|
49
49
|
**8. Refernce cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheett1!A3:B4" style references
|
50
50
|
|
@@ -89,18 +89,50 @@ To install Axlsx, use the following command:
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
##Using Custom Formatting
|
93
|
-
|
92
|
+
##Using Custom Formatting and date1904
|
93
|
+
require 'date'
|
94
94
|
wb.styles do |s|
|
95
95
|
date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
|
96
96
|
padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
|
97
97
|
percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
|
98
|
+
wb.date1904 = true # required for generation on mac
|
98
99
|
wb.add_worksheet(:name => "Formatting Data") do |sheet|
|
99
100
|
sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
|
100
|
-
sheet.add_row [
|
101
|
+
sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
105
|
+
##Add an Image
|
106
|
+
|
107
|
+
wb.add_worksheet(:name => "Images") do |sheet|
|
108
|
+
img = File.expand_path('examples/image1.jpeg')
|
109
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
110
|
+
image.width=720
|
111
|
+
image.height=666
|
112
|
+
image.start_at 2, 2
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
##Add an Image with a hyperlink
|
117
|
+
|
118
|
+
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
119
|
+
img = File.expand_path('examples/image1.jpeg')
|
120
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
121
|
+
image.width=720
|
122
|
+
image.height=666
|
123
|
+
image.hyperlink.tooltip = "Labeled Link"
|
124
|
+
image.start_at 2, 2
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
##Asian Language Support
|
129
|
+
|
130
|
+
wb.add_worksheet(:name => "Unicode Support") do |sheet|
|
131
|
+
sheet.add_row ["日本語"]
|
132
|
+
sheet.add_row ["华语/華語"]
|
133
|
+
sheet.add_row ["한국어/조선말"]
|
134
|
+
end
|
135
|
+
|
104
136
|
##Styling Columns
|
105
137
|
|
106
138
|
wb.styles do |s|
|
@@ -140,26 +172,6 @@ To install Axlsx, use the following command:
|
|
140
172
|
sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
141
173
|
end
|
142
174
|
|
143
|
-
##Add an Image
|
144
|
-
|
145
|
-
wb.add_worksheet(:name => "Images") do |sheet|
|
146
|
-
img = File.expand_path('examples/image1.jpeg')
|
147
|
-
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
148
|
-
image.width=720
|
149
|
-
image.height=666
|
150
|
-
image.start_at 2, 2
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
##Asian Language Support
|
155
|
-
|
156
|
-
wb.add_worksheet(:name => "Unicode Support") do |sheet|
|
157
|
-
sheet.add_row ["日本語"]
|
158
|
-
sheet.add_row ["华语/華語"]
|
159
|
-
sheet.add_row ["한국어/조선말"]
|
160
|
-
end
|
161
|
-
|
162
|
-
|
163
175
|
##Using formula
|
164
176
|
|
165
177
|
wb.add_worksheet(:name => "Using Formulas") do |sheet|
|
@@ -167,8 +179,7 @@ To install Axlsx, use the following command:
|
|
167
179
|
sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
|
168
180
|
end
|
169
181
|
|
170
|
-
|
171
|
-
##Merging Cells
|
182
|
+
##Merging Cells.
|
172
183
|
|
173
184
|
wb.add_worksheet(:name => 'Merging Cells') do |sheet|
|
174
185
|
# cell level style overides when adding cells
|
@@ -255,48 +266,34 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
255
266
|
gem install yard
|
256
267
|
yard server -g
|
257
268
|
|
258
|
-
|
259
269
|
#Specs
|
260
270
|
------
|
261
271
|
This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
|
262
272
|
|
263
273
|
#Changelog
|
264
274
|
---------
|
275
|
+
- ** February.2.12**: 1.0.16 release
|
276
|
+
- Bug fix for schema file locations when validating in rails
|
277
|
+
- Added hyperlink to images
|
278
|
+
- date1904 now automatically set in bsd and mac environments
|
279
|
+
- removed whitespace/indentation from xml outputs
|
280
|
+
- col_style now skips rows that do not contain cells at the column index
|
281
|
+
|
265
282
|
- **January.6.12**: 1.0.15 release
|
266
283
|
- Bug fix add_style specified number formats must be explicity applied for libraOffice
|
267
284
|
- performance improvements from ochko when creating cells with options.
|
268
285
|
- Bug fix setting types=>[:n] when adding a row incorrectly determines the cell type to be string as the value is null during creation.
|
269
286
|
- Release in preparation for password protection merge
|
270
287
|
|
271
|
-
- **December.14.11**: 1.0.14 release
|
272
|
-
- Added support for merging cells
|
273
|
-
- Added support for auto filters
|
274
|
-
- Improved auto width calculations
|
275
|
-
- Improved charts
|
276
|
-
- Updated examples to output to a single workbook with multiple sheets
|
277
|
-
- Added access to app and core package objects so you can set the creator and other properties of the package
|
278
|
-
- The beginning of password protected xlsx files - roadmapped for January release.
|
279
|
-
|
280
|
-
- **December.8.11**: 1.0.13 release
|
281
|
-
- Fixing .gemspec errors that caused gem to miss the lib directory. Sorry about that.
|
282
|
-
|
283
|
-
- **December.7.11**: 1.0.12 release
|
284
|
-
DO NOT USE THIS VERSION = THE GEM IS BROKEN
|
285
|
-
- changed dependency from 'zip' gem to 'rubyzip' and added conditional code to force binary encoding to resolve issue with excel 2011
|
286
|
-
- Patched bug in app.xml that would ignore user specified properties.
|
287
|
-
- **December.5.11**: 1.0.11 release
|
288
|
-
- Added [] methods to worksheet and workbook to provide name based access to cells.
|
289
|
-
- Added support for functions as cell values
|
290
|
-
- Updated color creation so that two character shorthand values can be used like 'FF' for 'FFFFFFFF' or 'D8' for 'FFD8D8D8'
|
291
|
-
- Examples for all this fun stuff added to the readme
|
292
|
-
- Clean up and support for 1.9.2 and travis integration
|
293
|
-
- Added support for string based cell referencing to chart start_at and end_at. That means you can now use :start_at=>"A1" when using worksheet.add_chart, or chart.start_at ="A1" in addition to passing a cell or the x, y coordinates.
|
294
288
|
|
295
289
|
Please see the {file:CHANGELOG.md} document for past release information.
|
296
290
|
|
297
291
|
#Thanks!
|
298
292
|
--------
|
299
|
-
ochko
|
293
|
+
[ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
|
294
|
+
|
295
|
+
[kleine2](https://github.com/kleine2) - for generously donating in return for the image hyperlink feature.
|
296
|
+
|
300
297
|
#Copyright and License
|
301
298
|
----------
|
302
299
|
|
data/examples/example.rb
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
end
|
25
25
|
|
26
26
|
##Using Custom Formatting and date1904
|
27
|
-
|
27
|
+
require 'date'
|
28
28
|
wb.styles do |s|
|
29
29
|
date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
|
30
30
|
padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
|
@@ -32,7 +32,7 @@
|
|
32
32
|
wb.date1904 = true # required for generation on mac
|
33
33
|
wb.add_worksheet(:name => "Formatting Data") do |sheet|
|
34
34
|
sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
|
35
|
-
sheet.add_row [
|
35
|
+
sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -47,6 +47,18 @@
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
##Add an Image with a hyperlink
|
51
|
+
|
52
|
+
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
53
|
+
img = File.expand_path('examples/image1.jpeg')
|
54
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
55
|
+
image.width=720
|
56
|
+
image.height=666
|
57
|
+
image.hyperlink.tooltip = "Labeled Link"
|
58
|
+
image.start_at 2, 2
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
50
62
|
##Asian Language Support
|
51
63
|
|
52
64
|
wb.add_worksheet(:name => "Unicode Support") do |sheet|
|
data/lib/axlsx/doc_props/app.rb
CHANGED
data/lib/axlsx/doc_props/core.rb
CHANGED
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -29,6 +29,7 @@ module Axlsx
|
|
29
29
|
|
30
30
|
require 'axlsx/drawing/picture_locking.rb'
|
31
31
|
require 'axlsx/drawing/pic.rb'
|
32
|
+
require 'axlsx/drawing/hyperlink.rb'
|
32
33
|
|
33
34
|
# A Drawing is a canvas for charts. Each worksheet has a single drawing that manages anchors.
|
34
35
|
# The anchors reference the charts via graphical frames. This is not a trivial relationship so please do follow the advice in the note.
|
@@ -79,6 +80,13 @@ module Axlsx
|
|
79
80
|
charts.map { |a| a.object.chart }
|
80
81
|
end
|
81
82
|
|
83
|
+
# An array of hyperlink objects associated with this drawings images
|
84
|
+
# @return [Array]
|
85
|
+
def hyperlinks
|
86
|
+
links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }
|
87
|
+
links.map { |a| a.hyperlink }
|
88
|
+
end
|
89
|
+
|
82
90
|
# An array of image objects that are associated with this drawing's anchors
|
83
91
|
# @return [Array]
|
84
92
|
def images
|
@@ -120,6 +128,9 @@ module Axlsx
|
|
120
128
|
images.each do |image|
|
121
129
|
r << Relationship.new(IMAGE_R, "../#{image.pn}")
|
122
130
|
end
|
131
|
+
hyperlinks.each do |hyperlink|
|
132
|
+
r << Relationship.new(HYPERLINK_R, hyperlink.href, :target_mode => :External)
|
133
|
+
end
|
123
134
|
r
|
124
135
|
end
|
125
136
|
|
@@ -131,7 +142,7 @@ module Axlsx
|
|
131
142
|
anchors.each {|anchor| anchor.to_xml(xml) }
|
132
143
|
}
|
133
144
|
end
|
134
|
-
builder.to_xml
|
145
|
+
builder.to_xml(:save_with => 0)
|
135
146
|
end
|
136
147
|
end
|
137
148
|
end
|
File without changes
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
# a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
|
4
|
+
# @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
|
5
|
+
# @see {file:README} README
|
6
|
+
class Hyperlink
|
7
|
+
|
8
|
+
# The destination of the hyperlink stored in the drawing's relationships document.
|
9
|
+
# @return [String]
|
10
|
+
attr_accessor :href
|
11
|
+
|
12
|
+
# The spec says: Specifies the URL when it has been determined by the generating application that the URL is invalid. That is the generating application can still store the URL but it is known that this URL is not correct.
|
13
|
+
#
|
14
|
+
# What exactly that means is beyond me so if you ever use this, let me know!
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :invalidUrl
|
17
|
+
|
18
|
+
#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
|
+
# @return [String]
|
20
|
+
attr_accessor :action
|
21
|
+
|
22
|
+
# Specifies if all sound events should be terminated when this link is clicked.
|
23
|
+
# @return [Boolean]
|
24
|
+
attr_reader :endSnd
|
25
|
+
|
26
|
+
# @see endSnd
|
27
|
+
# @param [Boolean] v The boolean value indicating the termination of playing sounds on click
|
28
|
+
# @return [Boolean]
|
29
|
+
def endSnd=(v) Axlsx::validate_boolean(v); @endSnd = v end
|
30
|
+
|
31
|
+
# indicates that the link has already been clicked.
|
32
|
+
# @return [Boolean]
|
33
|
+
attr_reader :highlightClick
|
34
|
+
|
35
|
+
# @see highlightClick
|
36
|
+
# @param [Boolean] v The value to assign
|
37
|
+
def highlightClick=(v) Axlsx::validate_boolean(v); @highlightClick = v end
|
38
|
+
|
39
|
+
# 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
|
+
# @return [Boolean]
|
41
|
+
attr_reader :history
|
42
|
+
|
43
|
+
# @see history
|
44
|
+
# param [Boolean] v The value to assing
|
45
|
+
def history=(v) Axlsx::validate_boolean(v); @history = v end
|
46
|
+
|
47
|
+
# 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
|
+
# @return [String]
|
49
|
+
attr_accessor :tgtFrame
|
50
|
+
|
51
|
+
# Text to show when you mouse over the hyperlink. If you do not set this, the href property will be shown.
|
52
|
+
# @return [String]
|
53
|
+
attr_accessor :tooltip
|
54
|
+
|
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
|
+
|
77
|
+
# Serializes the hyperlink
|
78
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
79
|
+
# @return [String]
|
80
|
+
def to_xml(xml)
|
81
|
+
h = self.instance_values.merge({:'r:id' => "rId#{id}", :'xmlns:r' => XML_NS_R })
|
82
|
+
h.delete('href')
|
83
|
+
h.delete('parent')
|
84
|
+
xml[:a].hlinkClick h
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
# The relational ID for this hyperlink
|
89
|
+
# @return [Integer]
|
90
|
+
def id
|
91
|
+
@parent.anchor.drawing.charts.size + @parent.anchor.drawing.images.size + @parent.anchor.drawing.hyperlinks.index(self) + 1
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
# a hlinkClick object adds a click behaviour to a drawing object.
|
4
|
+
# using the hlink_click method on a drawing object is the recommended way to manage hlinks
|
5
|
+
# @see Pic#link_to
|
6
|
+
class Hyperlink
|
7
|
+
|
8
|
+
# the type of hyper link defines the onclick or mouseover trigger.
|
9
|
+
# type must be one of :hlinkClick or :hlinkMouse
|
10
|
+
def type
|
11
|
+
@type ||= :hlinkClick
|
12
|
+
end
|
13
|
+
|
14
|
+
# sets the type of the object.
|
15
|
+
# @param [Symbol] type one of :hlinkClick or hlinkMouse
|
16
|
+
def type(v) RestrictionValidator.validate "Hyperlink.type", [:hlinkClick, :hlinkMouse], v; @type = v end
|
17
|
+
|
18
|
+
# The destination of the hyperlink
|
19
|
+
# This value is actually stored in the drawings .rels. doc as a relationship.
|
20
|
+
attr_accessor :href
|
21
|
+
|
22
|
+
# The docs say:
|
23
|
+
# Specifies the URL when it has been determined by the generating application that the URL is invalid. That is the generating application can still store the URL but it is known that this URL is not correct.
|
24
|
+
attr_accessor :invalidUrl
|
25
|
+
|
26
|
+
# 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.
|
27
|
+
attr_accessor :tgtFrame
|
28
|
+
|
29
|
+
# Specifies the tooltip that should be displayed when the hyperlink text is hovered over with the mouse. If this attribute is omitted, than the hyperlink text itself can be displayed.
|
30
|
+
attr_accessor :tooltip
|
31
|
+
|
32
|
+
#Creates a hyperlink object
|
33
|
+
# parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent
|
34
|
+
# @param [Pic] parent
|
35
|
+
# @option [String] tooltip message shown when hyperlinked object is hovered over with mouse.
|
36
|
+
# @option [String] tgtFrame Target frame for opening hyperlink
|
37
|
+
# @option [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
|
38
|
+
# @option [String] href the target resource this hyperlink links to.
|
39
|
+
def initialize(parent, options=>{})
|
40
|
+
DataTypeValidator.validate "Hyperlink.parent", [Pic], parent
|
41
|
+
@parent = parent
|
42
|
+
options.each do |o|
|
43
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# The index of this hyperlink in the owning document's hyperlinks collection
|
48
|
+
# @returns [Integer]
|
49
|
+
def index
|
50
|
+
self.parent.anchor.drawing.hyperlinks.index(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
# The relational ID for this hyperlink
|
54
|
+
# @returns [String]
|
55
|
+
def r:id
|
56
|
+
reference_count = self.parent.anchor.drawing.charts.size + self.parent.anchor.drawing.images.size + index
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_xml(xml)
|
61
|
+
xml.send(type,
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|