Class: Axlsx::Hyperlink
- Inherits:
-
Object
- Object
- Axlsx::Hyperlink
- Defined in:
- lib/axlsx/drawing/hyperlink.rb
Overview
using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
Instance Attribute Summary collapse
-
#action ⇒ String
An action to take when the link is clicked.
-
#endSnd ⇒ Boolean
Specifies if all sound events should be terminated when this link is clicked.
-
#highlightClick ⇒ Boolean
indicates that the link has already been clicked.
-
#history ⇒ Boolean
From the specs: Specifies whether to add this URI to the history when navigating to it.
-
#href ⇒ String
The destination of the hyperlink stored in the drawing’s relationships document.
-
#invalidUrl ⇒ String
The spec says: Specifies the URL when it has been determined by the generating application that the URL is invalid.
-
#tgtFrame ⇒ String
From the specs: Specifies the target frame that is to be used when opening this hyperlink.
-
#tooltip ⇒ String
Text to show when you mouse over the hyperlink.
Instance Method Summary collapse
-
#initialize(parent, options = {}) {|_self| ... } ⇒ Hyperlink
constructor
Creates a hyperlink object parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(parent, options = {}) {|_self| ... } ⇒ Hyperlink
Creates a hyperlink object parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent
66 67 68 69 70 71 72 73 74 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 66 def initialize(parent, ={}) DataTypeValidator.validate "Hyperlink.parent", [Pic], parent @parent = parent .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end yield self if block_given? end |
Instance Attribute Details
#action ⇒ String
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 msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
20 21 22 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 20 def action @action end |
#endSnd ⇒ Boolean
Specifies if all sound events should be terminated when this link is clicked.
24 25 26 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 24 def endSnd @endSnd end |
#highlightClick ⇒ Boolean
indicates that the link has already been clicked.
33 34 35 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 33 def highlightClick @highlightClick end |
#history ⇒ Boolean
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.
41 42 43 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 41 def history @history end |
#href ⇒ String
The destination of the hyperlink stored in the drawing’s relationships document.
10 11 12 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 10 def href @href end |
#invalidUrl ⇒ String
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.
What exactly that means is beyond me so if you ever use this, let me know!
16 17 18 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 16 def invalidUrl @invalidUrl end |
#tgtFrame ⇒ String
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.
49 50 51 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 49 def tgtFrame @tgtFrame end |
#tooltip ⇒ String
Text to show when you mouse over the hyperlink. If you do not set this, the href property will be shown.
53 54 55 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 53 def tooltip @tooltip end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
79 80 81 82 83 84 85 86 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 79 def to_xml_string(str = '') h = self.instance_values.merge({:'r:id' => "rId#{id}", :'xmlns:r' => XML_NS_R }) h.delete('href') h.delete('parent') str << '<a:hlinkClick ' str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') str << '/>' end |