summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/hyperlink.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 09:09:00 +0900
committerRandy Morgan <[email protected]>2012-10-14 09:09:00 +0900
commitef1dee87627fbb2a7ef8d9f2da530d500311ddf7 (patch)
treec8c290ef868eef6f37a6a200ccaef37f460b33eb /lib/axlsx/drawing/hyperlink.rb
parent8a75ef7e94d6f56d5ba1bff6f1e9cd1fa00819c2 (diff)
downloadcaxlsx-ef1dee87627fbb2a7ef8d9f2da530d500311ddf7.tar.gz
caxlsx-ef1dee87627fbb2a7ef8d9f2da530d500311ddf7.zip
Refactor in aliases for snake cased methods and integrate serialized attributes for drawing/hyperlink
Diffstat (limited to 'lib/axlsx/drawing/hyperlink.rb')
-rw-r--r--lib/axlsx/drawing/hyperlink.rb30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/axlsx/drawing/hyperlink.rb b/lib/axlsx/drawing/hyperlink.rb
index 6caebb6e..3b3f8c37 100644
--- a/lib/axlsx/drawing/hyperlink.rb
+++ b/lib/axlsx/drawing/hyperlink.rb
@@ -5,6 +5,9 @@ module Axlsx
# @see {file:README} README
class Hyperlink
+ include Axlsx::SerializedAttributes
+
+ serializable_attributes :invalid_url, :action, :end_snd, :highlight_click, :history, :tgt_frame, :tooltip
# The destination of the hyperlink stored in the drawing's relationships document.
# @return [String]
attr_accessor :href
@@ -13,7 +16,9 @@ module Axlsx
#
# What exactly that means is beyond me so if you ever use this, let me know!
# @return [String]
- attr_accessor :invalidUrl
+ attr_accessor :invalid_url
+ alias :invalidUrl :invalid_url
+ alias :invalidUrl= :invalid_url=
#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
# @return [String]
@@ -21,20 +26,24 @@ module Axlsx
# Specifies if all sound events should be terminated when this link is clicked.
# @return [Boolean]
- attr_reader :endSnd
+ attr_reader :end_snd
+ alias :endSnd :end_snd
# @see endSnd
# @param [Boolean] v The boolean value indicating the termination of playing sounds on click
# @return [Boolean]
- def endSnd=(v) Axlsx::validate_boolean(v); @endSnd = v end
+ def end_snd=(v) Axlsx::validate_boolean(v); @end_snd = v end
+ alias :endSnd= :end_snd=
# indicates that the link has already been clicked.
# @return [Boolean]
- attr_reader :highlightClick
+ attr_reader :highlight_click
+ alias :highlightClick :highlight_click
# @see highlightClick
# @param [Boolean] v The value to assign
- def highlightClick=(v) Axlsx::validate_boolean(v); @highlightClick = v end
+ def highlight_click=(v) Axlsx::validate_boolean(v); @highlight_click = v end
+ alias :highlightClick= :highlight_click=
# 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.
# @return [Boolean]
@@ -46,7 +55,9 @@ module Axlsx
# 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.
# @return [String]
- attr_accessor :tgtFrame
+ attr_accessor :tgt_frame
+ alias :tgtFrame :tgt_frame
+ alias :tgtFrame= :tgt_frame=
# Text to show when you mouse over the hyperlink. If you do not set this, the href property will be shown.
# @return [String]
@@ -58,7 +69,7 @@ module Axlsx
# @option options [String] tooltip message shown when hyperlinked object is hovered over with mouse.
# @option options [String] tgtFrame Target frame for opening hyperlink
# @option options [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
- # @option options [String] href the target resource this hyperlink links to.
+ # @option options [String] href the target resource this hyperlink links to. This is actually stored on the relationship.
# @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
# @option options [Boolean] endSnd terminate any sound events when processing this link
# @option options [Boolean] history include this link in the list of visited links for the applications history.
@@ -77,11 +88,8 @@ module Axlsx
# @param [String] str
# @return [String]
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(' ')
+ serialized_attributes str, {:'r:id' => "rId#{id}", :'xmlns:r' => XML_NS_R }
str << '/>'
end