summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/series_title.rb
blob: 08e5e90941d07bedd8d224f17ea54698cd2e1a85 (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
# frozen_string_literal: true

module Axlsx
  # A series title is a Title with a slightly different serialization than chart titles.
  class SeriesTitle < Title
    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s))

      str << '<c:tx>'
      str << '<c:strRef>'
      str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
      str << '<c:strCache>'
      str << '<c:ptCount val="1"/>'
      str << '<c:pt idx="0">'
      str << '<c:v>' << clean_value << '</c:v>'
      str << '</c:pt>'
      str << '</c:strCache>'
      str << '</c:strRef>'
      str << '</c:tx>'
    end
  end
end