summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing
diff options
context:
space:
mode:
authorSebastiano <[email protected]>2023-02-19 13:43:18 +0100
committerKoza <[email protected]>2023-04-12 17:29:29 +0200
commitc068cd0f3734b8fd34d99a129afa9ce180092d61 (patch)
tree780ea15ef5ba12b335a9d8376782fd3805ac8810 /lib/axlsx/drawing
parent892b06a1ab832133ac933e58d09acfc24ad24d22 (diff)
downloadcaxlsx-c068cd0f3734b8fd34d99a129afa9ce180092d61.tar.gz
caxlsx-c068cd0f3734b8fd34d99a129afa9ce180092d61.zip
refactored code on Pic class
Diffstat (limited to 'lib/axlsx/drawing')
-rw-r--r--lib/axlsx/drawing/pic.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb
index 4e269721..dda1763c 100644
--- a/lib/axlsx/drawing/pic.rb
+++ b/lib/axlsx/drawing/pic.rb
@@ -95,10 +95,14 @@ module Axlsx
def descr=(v) Axlsx::validate_string(v); @descr = v; end
# @see remote
- def remote=(v) @remote = v; end
+ def remote=(v) Axlsx::validate_boolean(v); @remote = v; end
def remote?
- remote == true;
+ if remote == 1 || remote.to_s == 'true'
+ true
+ else
+ false
+ end
end
# The file name of image_src without any path information
@@ -196,11 +200,7 @@ module Axlsx
picture_locking.to_xml_string(str)
str << '</xdr:cNvPicPr></xdr:nvPicPr>'
str << '<xdr:blipFill>'
- if remote?
- str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
- else
- str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
- end
+ str << relationship_xml_portion
if opacity
str << "<a:alphaModFix amt=\"#{opacity}\"/>"
end
@@ -212,6 +212,15 @@ module Axlsx
private
+ # Return correct xml relationship string portion
+ def relationship_xml_portion
+ if remote?
+ ('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
+ else
+ ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
+ end
+ end
+
# Changes the anchor to a one cell anchor.
def use_one_cell_anchor
return if @anchor.is_a?(OneCellAnchor)