Class: Axlsx::Hyperlink
- Inherits:
-
Object
- Object
- Axlsx::Hyperlink
- Includes:
- OptionsParser, SerializedAttributes
- 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.
-
#end_snd ⇒ Boolean
(also: #endSnd)
Specifies if all sound events should be terminated when this link is clicked.
-
#highlight_click ⇒ Boolean
(also: #highlightClick)
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.
-
#invalid_url ⇒ String
(also: #invalidUrl)
The spec says: Specifies the URL when it has been determined by the generating application that the URL is invalid.
-
#tgt_frame ⇒ String
(also: #tgtFrame)
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.
-
#relationship ⇒ Relationship
The relationship object for this hyperlink.
-
#to_xml_string(str = +'')) ⇒ String
Serializes the object.
Methods included from OptionsParser
Methods included from SerializedAttributes
included, #serialized_attributes, #serialized_element_attributes, #serialized_tag
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
22 23 24 25 26 27 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 22 def initialize(parent, = {}) DataTypeValidator.validate "Hyperlink.parent", [Pic], parent @parent = parent 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 https://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
45 46 47 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 45 def action @action end |
#end_snd ⇒ Boolean Also known as: endSnd
Specifies if all sound events should be terminated when this link is clicked.
49 50 51 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 49 def end_snd @end_snd end |
#highlight_click ⇒ Boolean Also known as: highlightClick
indicates that the link has already been clicked.
63 64 65 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 63 def highlight_click @highlight_click 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.
76 77 78 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 76 def history @history end |
#href ⇒ String
The destination of the hyperlink stored in the drawing's relationships document.
33 34 35 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 33 def href @href end |
#invalid_url ⇒ String Also known as: invalidUrl
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!
39 40 41 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 39 def invalid_url @invalid_url end |
#tgt_frame ⇒ String Also known as: tgtFrame
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.
87 88 89 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 87 def tgt_frame @tgt_frame end |
#tooltip ⇒ String
Text to show when you mouse over the hyperlink. If you do not set this, the href property will be shown.
93 94 95 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 93 def tooltip @tooltip end |
Instance Method Details
#relationship ⇒ Relationship
The relationship object for this hyperlink.
97 98 99 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 97 def relationship Relationship.new(self, HYPERLINK_R, href, target_mode: :External) end |
#to_xml_string(str = +'')) ⇒ String
Serializes the object
104 105 106 |
# File 'lib/axlsx/drawing/hyperlink.rb', line 104 def to_xml_string(str = +'') serialized_tag 'a:hlinkClick', str, { 'r:id': relationship.Id, 'xmlns:r': XML_NS_R } end |