blob: 364ce19a20e3ce1d1c9cc135bacfcc615fff7f15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# frozen_string_literal: true
module Axlsx
# a vml drawing used for comments in Excel.
class VmlDrawing
# creates a new Vml Drawing object.
# @param [Comments] comments the comments object this drawing is associated with
def initialize(comments)
raise ArgumentError, "you must provide a comments object" unless comments.is_a?(Comments)
@comments = comments
end
# The part name for this vml drawing
# @return [String]
def pn
"#{VML_DRAWING_PN}" % (@comments.worksheet.index + 1)
end
# serialize the vml_drawing to xml.
# @param [String] str
# @return [String]
def to_xml_string(str = +'')
str << <<~XML
<xml xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="#{@comments.worksheet.index + 1}"/>
</o:shapelayout>
<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
path="m0,0l0,21600,21600,21600,21600,0xe">
<v:stroke joinstyle="miter"/>
<v:path gradientshapeok="t" o:connecttype="rect"/>
</v:shapetype>
XML
@comments.each { |comment| comment.vml_shape.to_xml_string str }
str << "</xml>"
end
end
end
|