xlsxrb 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +88 -0
- data/README.md +25 -3
- data/lib/xlsxrb/dsl_helpers.rb +65 -1
- data/lib/xlsxrb/elements/styles.rb +15 -6
- data/lib/xlsxrb/elements/worksheet.rb +2 -2
- data/lib/xlsxrb/number_formatter.rb +26 -8
- data/lib/xlsxrb/ooxml/cfb.rb +11 -3
- data/lib/xlsxrb/ooxml/crypto/agile.rb +48 -10
- data/lib/xlsxrb/ooxml/crypto/standard.rb +5 -1
- data/lib/xlsxrb/ooxml/crypto.rb +3 -0
- data/lib/xlsxrb/ooxml/shared_strings_parser.rb +26 -8
- data/lib/xlsxrb/ooxml/utils.rb +13 -0
- data/lib/xlsxrb/ooxml/workbook_writer.rb +43 -21
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +116 -12
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +338 -259
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +206 -201
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +109 -102
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +46 -46
- data/lib/xlsxrb/ooxml/writer.rb +167 -160
- data/lib/xlsxrb/ooxml/xml_builder.rb +35 -7
- data/lib/xlsxrb/ooxml/xml_parser.rb +34 -1
- data/lib/xlsxrb/ooxml/zip_reader.rb +95 -68
- data/lib/xlsxrb/ooxml/zip_writer.rb +16 -0
- data/lib/xlsxrb/stream_row.rb +2 -2
- data/lib/xlsxrb/stream_sheet.rb +26 -11
- data/lib/xlsxrb/stream_writer.rb +212 -86
- data/lib/xlsxrb/style_builder.rb +339 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +239 -88
- data/lib/xlsxrb/worksheet_builder.rb +847 -139
- data/lib/xlsxrb.rb +87 -21
- data/sig/generated/xlsxrb/dsl_helpers.rbs +37 -0
- data/sig/generated/xlsxrb/elements/styles.rbs +5 -0
- data/sig/generated/xlsxrb/number_formatter.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/cfb.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/crypto/agile.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/utils.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +13 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +40 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +53 -0
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +3 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +4 -0
- data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +19 -2
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +12 -1
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +8 -0
- data/sig/generated/xlsxrb/stream_row.rbs +2 -2
- data/sig/generated/xlsxrb/stream_sheet.rbs +9 -0
- data/sig/generated/xlsxrb/stream_writer.rbs +46 -6
- data/sig/generated/xlsxrb/style_builder.rbs +261 -0
- data/sig/generated/xlsxrb/workbook_builder.rbs +42 -9
- data/sig/generated/xlsxrb/worksheet_builder.rbs +618 -4
- data/sig/generated/xlsxrb.rbs +53 -8
- metadata +9 -3
|
@@ -33,22 +33,22 @@ module Xlsxrb
|
|
|
33
33
|
pic_lock_attrs << ' noChangeAspect="1"' if img[:no_change_aspect]
|
|
34
34
|
pic_lock_attrs << ' noCrop="1"' if img[:no_crop]
|
|
35
35
|
pic_locks = pic_lock_attrs.empty? ? "<a:picLocks/>" : "<a:picLocks#{pic_lock_attrs}/>"
|
|
36
|
-
parts << %(<xdr:nvPicPr><xdr:cNvPr id="#{dp[:rid_index] + 1}" name="#{xml_escape(img[:name])}"#{descr_attr}#{title_attr}#{hidden_attr}/><xdr:cNvPicPr>#{pic_locks}</xdr:cNvPicPr></xdr:nvPicPr>)
|
|
36
|
+
parts << %(<xdr:nvPicPr><xdr:cNvPr id="#{xml_escape(dp[:rid_index] + 1)}" name="#{xml_escape(img[:name])}"#{descr_attr}#{title_attr}#{hidden_attr}/><xdr:cNvPicPr>#{pic_locks}</xdr:cNvPicPr></xdr:nvPicPr>)
|
|
37
37
|
src_rect_xml = if img[:src_rect]
|
|
38
38
|
sr = img[:src_rect]
|
|
39
39
|
sr_attrs = +""
|
|
40
|
-
sr_attrs << %( t="#{sr[:top]}") if sr[:top]
|
|
41
|
-
sr_attrs << %( b="#{sr[:bottom]}") if sr[:bottom]
|
|
42
|
-
sr_attrs << %( l="#{sr[:left]}") if sr[:left]
|
|
43
|
-
sr_attrs << %( r="#{sr[:right]}") if sr[:right]
|
|
40
|
+
sr_attrs << %( t="#{xml_escape(sr[:top])}") if sr[:top]
|
|
41
|
+
sr_attrs << %( b="#{xml_escape(sr[:bottom])}") if sr[:bottom]
|
|
42
|
+
sr_attrs << %( l="#{xml_escape(sr[:left])}") if sr[:left]
|
|
43
|
+
sr_attrs << %( r="#{xml_escape(sr[:right])}") if sr[:right]
|
|
44
44
|
"<a:srcRect#{sr_attrs}/>"
|
|
45
45
|
else
|
|
46
46
|
""
|
|
47
47
|
end
|
|
48
48
|
blip_xml = if img[:alpha_mod_fix]
|
|
49
|
-
%(<a:blip r:embed="#{rid}"><a:alphaModFix amt="#{img[:alpha_mod_fix]}"/></a:blip>)
|
|
49
|
+
%(<a:blip r:embed="#{xml_escape(rid)}"><a:alphaModFix amt="#{xml_escape(img[:alpha_mod_fix])}"/></a:blip>)
|
|
50
50
|
else
|
|
51
|
-
%(<a:blip r:embed="#{rid}"/>)
|
|
51
|
+
%(<a:blip r:embed="#{xml_escape(rid)}"/>)
|
|
52
52
|
end
|
|
53
53
|
parts << %(<xdr:blipFill>#{blip_xml}#{src_rect_xml}<a:stretch><a:fillRect/></a:stretch></xdr:blipFill>)
|
|
54
54
|
img_line_xml = if img[:line_color]
|
|
@@ -71,7 +71,7 @@ module Xlsxrb
|
|
|
71
71
|
parts << anchor_xml("from", chart[:from_column] || chart[:from_col], chart[:from_row], col_off: chart[:from_col_off] || 0, row_off: chart[:from_row_off] || 0)
|
|
72
72
|
parts << anchor_xml("to", chart[:to_column] || chart[:to_col], chart[:to_row], col_off: chart[:to_col_off] || 0, row_off: chart[:to_row_off] || 0)
|
|
73
73
|
gf_macro = chart[:frame_macro] ? xml_escape(chart[:frame_macro]) : ""
|
|
74
|
-
parts << %(<xdr:graphicFrame macro="#{gf_macro}">)
|
|
74
|
+
parts << %(<xdr:graphicFrame macro="#{xml_escape(gf_macro)}">)
|
|
75
75
|
chart_frame_name = chart[:name] || chart[:title] || "Chart"
|
|
76
76
|
chart_descr_attr = chart[:description] ? %( descr="#{xml_escape(chart[:description])}") : ""
|
|
77
77
|
chart_title_attr = chart[:frame_title] ? %( title="#{xml_escape(chart[:frame_title])}") : ""
|
|
@@ -81,9 +81,9 @@ module Xlsxrb
|
|
|
81
81
|
else
|
|
82
82
|
"<xdr:cNvGraphicFramePr/>"
|
|
83
83
|
end
|
|
84
|
-
parts << %(<xdr:nvGraphicFramePr><xdr:cNvPr id="#{dp[:rid_index] + 1}" name="#{xml_escape(chart_frame_name)}"#{chart_descr_attr}#{chart_title_attr}#{chart_hidden_attr}/>#{cnv_gf_pr}</xdr:nvGraphicFramePr>)
|
|
84
|
+
parts << %(<xdr:nvGraphicFramePr><xdr:cNvPr id="#{xml_escape(dp[:rid_index] + 1)}" name="#{xml_escape(chart_frame_name)}"#{chart_descr_attr}#{chart_title_attr}#{chart_hidden_attr}/>#{cnv_gf_pr}</xdr:nvGraphicFramePr>)
|
|
85
85
|
parts << '<xdr:xfrm><a:off x="0" y="0"/><a:ext cx="5000000" cy="3000000"/></xdr:xfrm>'
|
|
86
|
-
parts << %(<a:graphic><a:graphicData uri="#{C_NS}"><c:chart xmlns:c="#{C_NS}" xmlns:r="#{DOC_REL_NS}" r:id="#{rid}"/></a:graphicData></a:graphic>)
|
|
86
|
+
parts << %(<a:graphic><a:graphicData uri="#{C_NS}"><c:chart xmlns:c="#{C_NS}" xmlns:r="#{DOC_REL_NS}" r:id="#{xml_escape(rid)}"/></a:graphicData></a:graphic>)
|
|
87
87
|
parts << "</xdr:graphicFrame>"
|
|
88
88
|
parts << client_data_xml(chart)
|
|
89
89
|
parts << "</xdr:twoCellAnchor>"
|
|
@@ -110,7 +110,7 @@ module Xlsxrb
|
|
|
110
110
|
else
|
|
111
111
|
"<xdr:cNvSpPr><a:spLocks#{sp_lock_attrs}/></xdr:cNvSpPr>"
|
|
112
112
|
end
|
|
113
|
-
parts << %(<xdr:nvSpPr><xdr:cNvPr id="#{dp[:id]}" name="#{xml_escape(shape[:name])}"#{shape_descr_attr}#{shape_title_attr}#{shape_hidden_attr}/>#{cnv_sp_pr}</xdr:nvSpPr>)
|
|
113
|
+
parts << %(<xdr:nvSpPr><xdr:cNvPr id="#{xml_escape(dp[:id])}" name="#{xml_escape(shape[:name])}"#{shape_descr_attr}#{shape_title_attr}#{shape_hidden_attr}/>#{cnv_sp_pr}</xdr:nvSpPr>)
|
|
114
114
|
shape_fill_xml = if shape[:no_fill]
|
|
115
115
|
"<a:noFill/>"
|
|
116
116
|
elsif shape[:fill_color]
|
|
@@ -120,16 +120,16 @@ module Xlsxrb
|
|
|
120
120
|
gf_attrs = +""
|
|
121
121
|
gf_attrs << %( rotWithShape="#{gf[:rot_with_shape] ? 1 : 0}") unless gf[:rot_with_shape].nil?
|
|
122
122
|
gf_attrs << %( flip="#{xml_escape(gf[:flip])}") if gf[:flip]
|
|
123
|
-
gs_xml = (gf[:stops] || []).map { |gs| %(<a:gs pos="#{gs[:pos]}">#{color_xml(gs[:color])}</a:gs>) }.join
|
|
123
|
+
gs_xml = (gf[:stops] || []).map { |gs| %(<a:gs pos="#{xml_escape(gs[:pos])}">#{color_xml(gs[:color])}</a:gs>) }.join
|
|
124
124
|
type_xml = if gf[:path]
|
|
125
125
|
%(<a:path path="#{xml_escape(gf[:path])}"/>)
|
|
126
126
|
elsif gf[:angle]
|
|
127
127
|
scaled_attr = gf[:scaled] ? %( scaled="1") : %( scaled="0")
|
|
128
|
-
%(<a:lin ang="#{gf[:angle]}"#{scaled_attr}/>)
|
|
128
|
+
%(<a:lin ang="#{xml_escape(gf[:angle])}"#{scaled_attr}/>)
|
|
129
129
|
else
|
|
130
130
|
""
|
|
131
131
|
end
|
|
132
|
-
tile_xml = gf[:tile_rect] ? %(<a:tileRect#{gf[:tile_rect].map { |k, v| %( #{k}="#{v}") }.join}/>) : ""
|
|
132
|
+
tile_xml = gf[:tile_rect] ? %(<a:tileRect#{gf[:tile_rect].map { |k, v| %( #{k}="#{xml_escape(v)}") }.join}/>) : ""
|
|
133
133
|
"<a:gradFill#{gf_attrs}><a:gsLst>#{gs_xml}</a:gsLst>#{type_xml}#{tile_xml}</a:gradFill>"
|
|
134
134
|
elsif shape[:pattern_fill]
|
|
135
135
|
pf = shape[:pattern_fill]
|
|
@@ -153,7 +153,7 @@ module Xlsxrb
|
|
|
153
153
|
""
|
|
154
154
|
end
|
|
155
155
|
dash_part = if shape[:line_custom_dash]
|
|
156
|
-
ds_xml = shape[:line_custom_dash].map { |ds| %(<a:ds d="#{ds[:d]}" sp="#{ds[:sp]}"/>) }.join
|
|
156
|
+
ds_xml = shape[:line_custom_dash].map { |ds| %(<a:ds d="#{xml_escape(ds[:d])}" sp="#{xml_escape(ds[:sp])}"/>) }.join
|
|
157
157
|
"<a:custDash>#{ds_xml}</a:custDash>"
|
|
158
158
|
elsif shape[:line_dash]
|
|
159
159
|
%(<a:prstDash val="#{xml_escape(shape[:line_dash])}"/>)
|
|
@@ -185,9 +185,9 @@ module Xlsxrb
|
|
|
185
185
|
if shape[:outer_shadow]
|
|
186
186
|
os = shape[:outer_shadow]
|
|
187
187
|
os_attrs = +""
|
|
188
|
-
os_attrs << %( blurRad="#{os[:blur_rad]}") if os[:blur_rad]
|
|
189
|
-
os_attrs << %( dist="#{os[:dist]}") if os[:dist]
|
|
190
|
-
os_attrs << %( dir="#{os[:dir]}") if os[:dir]
|
|
188
|
+
os_attrs << %( blurRad="#{xml_escape(os[:blur_rad])}") if os[:blur_rad]
|
|
189
|
+
os_attrs << %( dist="#{xml_escape(os[:dist])}") if os[:dist]
|
|
190
|
+
os_attrs << %( dir="#{xml_escape(os[:dir])}") if os[:dir]
|
|
191
191
|
os_attrs << %( algn="#{xml_escape(os[:algn])}") if os[:algn]
|
|
192
192
|
os_attrs << %( rotWithShape="#{os[:rot_with_shape] ? 1 : 0}") unless os[:rot_with_shape].nil?
|
|
193
193
|
os_color = os[:color] ? srgb_clr_xml(os[:color], alpha: os[:alpha]) : ""
|
|
@@ -196,44 +196,44 @@ module Xlsxrb
|
|
|
196
196
|
if shape[:glow]
|
|
197
197
|
gl = shape[:glow]
|
|
198
198
|
gl_attrs = +""
|
|
199
|
-
gl_attrs << %( rad="#{gl[:rad]}") if gl[:rad]
|
|
199
|
+
gl_attrs << %( rad="#{xml_escape(gl[:rad])}") if gl[:rad]
|
|
200
200
|
gl_color = gl[:color] ? srgb_clr_xml(gl[:color], alpha: gl[:alpha]) : ""
|
|
201
201
|
effect_children << "<a:glow#{gl_attrs}>#{gl_color}</a:glow>"
|
|
202
202
|
end
|
|
203
203
|
if shape[:inner_shadow]
|
|
204
204
|
is = shape[:inner_shadow]
|
|
205
205
|
is_attrs = +""
|
|
206
|
-
is_attrs << %( blurRad="#{is[:blur_rad]}") if is[:blur_rad]
|
|
207
|
-
is_attrs << %( dist="#{is[:dist]}") if is[:dist]
|
|
208
|
-
is_attrs << %( dir="#{is[:dir]}") if is[:dir]
|
|
206
|
+
is_attrs << %( blurRad="#{xml_escape(is[:blur_rad])}") if is[:blur_rad]
|
|
207
|
+
is_attrs << %( dist="#{xml_escape(is[:dist])}") if is[:dist]
|
|
208
|
+
is_attrs << %( dir="#{xml_escape(is[:dir])}") if is[:dir]
|
|
209
209
|
is_color = is[:color] ? srgb_clr_xml(is[:color], alpha: is[:alpha]) : ""
|
|
210
210
|
effect_children << "<a:innerShdw#{is_attrs}>#{is_color}</a:innerShdw>"
|
|
211
211
|
end
|
|
212
212
|
if shape[:reflection]
|
|
213
213
|
rf = shape[:reflection]
|
|
214
214
|
rf_attrs = +""
|
|
215
|
-
rf_attrs << %( blurRad="#{rf[:blur_rad]}") if rf[:blur_rad]
|
|
216
|
-
rf_attrs << %( stA="#{rf[:st_a]}") if rf[:st_a]
|
|
217
|
-
rf_attrs << %( endA="#{rf[:end_a]}") if rf[:end_a]
|
|
218
|
-
rf_attrs << %( dist="#{rf[:dist]}") unless rf[:dist].nil?
|
|
219
|
-
rf_attrs << %( dir="#{rf[:dir]}") if rf[:dir]
|
|
220
|
-
rf_attrs << %( fadeDir="#{rf[:fade_dir]}") if rf[:fade_dir]
|
|
221
|
-
rf_attrs << %( sx="#{rf[:sx]}") if rf[:sx]
|
|
222
|
-
rf_attrs << %( sy="#{rf[:sy]}") if rf[:sy]
|
|
223
|
-
rf_attrs << %( kx="#{rf[:kx]}") if rf[:kx]
|
|
224
|
-
rf_attrs << %( ky="#{rf[:ky]}") if rf[:ky]
|
|
215
|
+
rf_attrs << %( blurRad="#{xml_escape(rf[:blur_rad])}") if rf[:blur_rad]
|
|
216
|
+
rf_attrs << %( stA="#{xml_escape(rf[:st_a])}") if rf[:st_a]
|
|
217
|
+
rf_attrs << %( endA="#{xml_escape(rf[:end_a])}") if rf[:end_a]
|
|
218
|
+
rf_attrs << %( dist="#{xml_escape(rf[:dist])}") unless rf[:dist].nil?
|
|
219
|
+
rf_attrs << %( dir="#{xml_escape(rf[:dir])}") if rf[:dir]
|
|
220
|
+
rf_attrs << %( fadeDir="#{xml_escape(rf[:fade_dir])}") if rf[:fade_dir]
|
|
221
|
+
rf_attrs << %( sx="#{xml_escape(rf[:sx])}") if rf[:sx]
|
|
222
|
+
rf_attrs << %( sy="#{xml_escape(rf[:sy])}") if rf[:sy]
|
|
223
|
+
rf_attrs << %( kx="#{xml_escape(rf[:kx])}") if rf[:kx]
|
|
224
|
+
rf_attrs << %( ky="#{xml_escape(rf[:ky])}") if rf[:ky]
|
|
225
225
|
rf_attrs << %( algn="#{xml_escape(rf[:algn])}") if rf[:algn]
|
|
226
226
|
rf_attrs << %( rotWithShape="#{rf[:rot_with_shape] ? 1 : 0}") unless rf[:rot_with_shape].nil?
|
|
227
227
|
effect_children << "<a:reflection#{rf_attrs}/>"
|
|
228
228
|
end
|
|
229
229
|
if shape[:soft_edge]
|
|
230
230
|
se = shape[:soft_edge]
|
|
231
|
-
effect_children << %(<a:softEdge rad="#{se[:rad]}"/>)
|
|
231
|
+
effect_children << %(<a:softEdge rad="#{xml_escape(se[:rad])}"/>)
|
|
232
232
|
end
|
|
233
233
|
if shape[:blur]
|
|
234
234
|
bl = shape[:blur]
|
|
235
235
|
bl_attrs = +""
|
|
236
|
-
bl_attrs << %( rad="#{bl[:rad]}") if bl[:rad]
|
|
236
|
+
bl_attrs << %( rad="#{xml_escape(bl[:rad])}") if bl[:rad]
|
|
237
237
|
bl_attrs << %( grow="#{bl[:grow] ? 1 : 0}") unless bl[:grow].nil?
|
|
238
238
|
effect_children << "<a:blur#{bl_attrs}/>"
|
|
239
239
|
end
|
|
@@ -244,15 +244,15 @@ module Xlsxrb
|
|
|
244
244
|
parts << %(<xdr:spPr>#{shape_xfrm_xml}<a:prstGeom prst="#{xml_escape(shape[:preset])}">#{av_lst_xml}</a:prstGeom>#{shape_fill_xml}#{shape_line_xml}#{effect_lst_xml}</xdr:spPr>)
|
|
245
245
|
if shape[:text] || shape[:text_paragraphs]
|
|
246
246
|
body_pr_attrs = +""
|
|
247
|
-
body_pr_attrs << %( rot="#{shape[:text_rot]}") if shape[:text_rot]
|
|
247
|
+
body_pr_attrs << %( rot="#{xml_escape(shape[:text_rot])}") if shape[:text_rot]
|
|
248
248
|
body_pr_attrs << %( spcFirstLastPara="1") if shape[:text_spc_first_last_para]
|
|
249
249
|
body_pr_attrs << %( wrap="#{xml_escape(shape[:text_wrap])}") if shape[:text_wrap]
|
|
250
250
|
body_pr_attrs << %( anchor="#{xml_escape(shape[:text_anchor])}") if shape[:text_anchor]
|
|
251
251
|
body_pr_attrs << %( anchorCtr="1") if shape[:text_anchor_ctr]
|
|
252
252
|
body_pr_attrs << %( vertOverflow="#{xml_escape(shape[:text_vert_overflow])}") if shape[:text_vert_overflow]
|
|
253
253
|
body_pr_attrs << %( horzOverflow="#{xml_escape(shape[:text_horz_overflow])}") if shape[:text_horz_overflow]
|
|
254
|
-
body_pr_attrs << %( numCol="#{shape[:text_num_col]}") if shape[:text_num_col]
|
|
255
|
-
body_pr_attrs << %( spcCol="#{shape[:text_spc_col]}") if shape[:text_spc_col]
|
|
254
|
+
body_pr_attrs << %( numCol="#{xml_escape(shape[:text_num_col])}") if shape[:text_num_col]
|
|
255
|
+
body_pr_attrs << %( spcCol="#{xml_escape(shape[:text_spc_col])}") if shape[:text_spc_col]
|
|
256
256
|
body_pr_attrs << %( rtlCol="1") if shape[:text_rtl_col]
|
|
257
257
|
body_pr_attrs << %( fromWordArt="1") if shape[:text_from_word_art]
|
|
258
258
|
body_pr_attrs << %( upright="1") if shape[:text_upright]
|
|
@@ -261,10 +261,10 @@ module Xlsxrb
|
|
|
261
261
|
body_pr_attrs << %( vert="#{xml_escape(shape[:text_vertical])}") if shape[:text_vertical]
|
|
262
262
|
if shape[:text_insets]
|
|
263
263
|
ins = shape[:text_insets]
|
|
264
|
-
body_pr_attrs << %( lIns="#{ins[:left]}") if ins[:left]
|
|
265
|
-
body_pr_attrs << %( tIns="#{ins[:top]}") if ins[:top]
|
|
266
|
-
body_pr_attrs << %( rIns="#{ins[:right]}") if ins[:right]
|
|
267
|
-
body_pr_attrs << %( bIns="#{ins[:bottom]}") if ins[:bottom]
|
|
264
|
+
body_pr_attrs << %( lIns="#{xml_escape(ins[:left])}") if ins[:left]
|
|
265
|
+
body_pr_attrs << %( tIns="#{xml_escape(ins[:top])}") if ins[:top]
|
|
266
|
+
body_pr_attrs << %( rIns="#{xml_escape(ins[:right])}") if ins[:right]
|
|
267
|
+
body_pr_attrs << %( bIns="#{xml_escape(ins[:bottom])}") if ins[:bottom]
|
|
268
268
|
end
|
|
269
269
|
body_pr_children = +""
|
|
270
270
|
if shape[:text_warp]
|
|
@@ -280,8 +280,8 @@ module Xlsxrb
|
|
|
280
280
|
case af[:type]
|
|
281
281
|
when "normal"
|
|
282
282
|
na_attrs = +""
|
|
283
|
-
na_attrs << %( fontScale="#{af[:font_scale]}") if af[:font_scale]
|
|
284
|
-
na_attrs << %( lnSpcReduction="#{af[:ln_spc_reduction]}") if af[:ln_spc_reduction]
|
|
283
|
+
na_attrs << %( fontScale="#{xml_escape(af[:font_scale])}") if af[:font_scale]
|
|
284
|
+
na_attrs << %( lnSpcReduction="#{xml_escape(af[:ln_spc_reduction])}") if af[:ln_spc_reduction]
|
|
285
285
|
"<a:normAutofit#{na_attrs}/>"
|
|
286
286
|
when "none" then "<a:noAutofit/>"
|
|
287
287
|
when "shape" then "<a:spAutoFit/>"
|
|
@@ -327,40 +327,40 @@ module Xlsxrb
|
|
|
327
327
|
ppr_attrs = +""
|
|
328
328
|
ppr_attrs << %( algn="#{xml_escape(para[:align])}") if para[:align]
|
|
329
329
|
ppr_attrs << %( fontAlgn="#{xml_escape(para[:font_align])}") if para[:font_align]
|
|
330
|
-
ppr_attrs << %( defTabSz="#{para[:def_tab_sz]}") if para[:def_tab_sz]
|
|
330
|
+
ppr_attrs << %( defTabSz="#{xml_escape(para[:def_tab_sz])}") if para[:def_tab_sz]
|
|
331
331
|
ppr_attrs << %( rtl="1") if para[:rtl]
|
|
332
332
|
ppr_attrs << %( eaLnBrk="1") if para[:ea_ln_brk]
|
|
333
333
|
ppr_attrs << %( latinLnBrk="1") if para[:latin_ln_brk]
|
|
334
334
|
ppr_attrs << %( hangingPunct="1") if para[:hanging_punct]
|
|
335
|
-
ppr_attrs << %( lvl="#{para[:level]}") if para[:level]
|
|
335
|
+
ppr_attrs << %( lvl="#{xml_escape(para[:level])}") if para[:level]
|
|
336
336
|
if para[:indent]
|
|
337
337
|
ti = para[:indent]
|
|
338
|
-
ppr_attrs << %( marL="#{ti[:left]}") if ti[:left]
|
|
339
|
-
ppr_attrs << %( marR="#{ti[:right]}") if ti[:right]
|
|
340
|
-
ppr_attrs << %( indent="#{ti[:indent]}") if ti[:indent]
|
|
338
|
+
ppr_attrs << %( marL="#{xml_escape(ti[:left])}") if ti[:left]
|
|
339
|
+
ppr_attrs << %( marR="#{xml_escape(ti[:right])}") if ti[:right]
|
|
340
|
+
ppr_attrs << %( indent="#{xml_escape(ti[:indent])}") if ti[:indent]
|
|
341
341
|
end
|
|
342
342
|
ppr_children = +""
|
|
343
343
|
if para[:spacing]
|
|
344
344
|
ts = para[:spacing]
|
|
345
345
|
if ts[:line]
|
|
346
|
-
ppr_children << %(<a:lnSpc><a:spcPts val="#{ts[:line]}"/></a:lnSpc>)
|
|
346
|
+
ppr_children << %(<a:lnSpc><a:spcPts val="#{xml_escape(ts[:line])}"/></a:lnSpc>)
|
|
347
347
|
elsif ts[:line_pct]
|
|
348
|
-
ppr_children << %(<a:lnSpc><a:spcPct val="#{ts[:line_pct]}"/></a:lnSpc>)
|
|
348
|
+
ppr_children << %(<a:lnSpc><a:spcPct val="#{xml_escape(ts[:line_pct])}"/></a:lnSpc>)
|
|
349
349
|
end
|
|
350
350
|
if ts[:before]
|
|
351
|
-
ppr_children << %(<a:spcBef><a:spcPts val="#{ts[:before]}"/></a:spcBef>)
|
|
351
|
+
ppr_children << %(<a:spcBef><a:spcPts val="#{xml_escape(ts[:before])}"/></a:spcBef>)
|
|
352
352
|
elsif ts[:before_pct]
|
|
353
|
-
ppr_children << %(<a:spcBef><a:spcPct val="#{ts[:before_pct]}"/></a:spcBef>)
|
|
353
|
+
ppr_children << %(<a:spcBef><a:spcPct val="#{xml_escape(ts[:before_pct])}"/></a:spcBef>)
|
|
354
354
|
end
|
|
355
355
|
if ts[:after]
|
|
356
|
-
ppr_children << %(<a:spcAft><a:spcPts val="#{ts[:after]}"/></a:spcAft>)
|
|
356
|
+
ppr_children << %(<a:spcAft><a:spcPts val="#{xml_escape(ts[:after])}"/></a:spcAft>)
|
|
357
357
|
elsif ts[:after_pct]
|
|
358
|
-
ppr_children << %(<a:spcAft><a:spcPct val="#{ts[:after_pct]}"/></a:spcAft>)
|
|
358
|
+
ppr_children << %(<a:spcAft><a:spcPct val="#{xml_escape(ts[:after_pct])}"/></a:spcAft>)
|
|
359
359
|
end
|
|
360
360
|
end
|
|
361
361
|
if para[:tab_stops]&.any?
|
|
362
362
|
tabs = para[:tab_stops].map do |tab|
|
|
363
|
-
tab_attrs = %( pos="#{tab[:pos]}")
|
|
363
|
+
tab_attrs = %( pos="#{xml_escape(tab[:pos])}")
|
|
364
364
|
tab_attrs << %( algn="#{xml_escape(tab[:align])}") if tab[:align]
|
|
365
365
|
"<a:tab#{tab_attrs}/>"
|
|
366
366
|
end
|
|
@@ -369,8 +369,8 @@ module Xlsxrb
|
|
|
369
369
|
if para[:bullet]
|
|
370
370
|
bu = para[:bullet]
|
|
371
371
|
ppr_children << %(<a:buClr>#{color_xml(bu[:color])}</a:buClr>) if bu[:color]
|
|
372
|
-
ppr_children << %(<a:buSzPts val="#{bu[:size_pts]}"/>) if bu[:size_pts]
|
|
373
|
-
ppr_children << %(<a:buSzPct val="#{bu[:size_pct]}"/>) if bu[:size_pct]
|
|
372
|
+
ppr_children << %(<a:buSzPts val="#{xml_escape(bu[:size_pts])}"/>) if bu[:size_pts]
|
|
373
|
+
ppr_children << %(<a:buSzPct val="#{xml_escape(bu[:size_pct])}"/>) if bu[:size_pct]
|
|
374
374
|
ppr_children << %(<a:buFont typeface="#{xml_escape(bu[:font])}"/>) if bu[:font]
|
|
375
375
|
case bu[:type]
|
|
376
376
|
when "none"
|
|
@@ -379,7 +379,7 @@ module Xlsxrb
|
|
|
379
379
|
ppr_children << %(<a:buChar char="#{xml_escape(bu[:char])}"/>)
|
|
380
380
|
when "auto"
|
|
381
381
|
auto_attrs = %( type="#{xml_escape(bu[:auto_type])}")
|
|
382
|
-
auto_attrs << %( startAt="#{bu[:start_at]}") if bu[:start_at]
|
|
382
|
+
auto_attrs << %( startAt="#{xml_escape(bu[:start_at])}") if bu[:start_at]
|
|
383
383
|
ppr_children << "<a:buAutoNum#{auto_attrs}/>"
|
|
384
384
|
end
|
|
385
385
|
end
|
|
@@ -414,12 +414,12 @@ module Xlsxrb
|
|
|
414
414
|
attrs << %( noProof="1") if font[:no_proof]
|
|
415
415
|
attrs << %( normalizeH="1") if font[:normalize_h]
|
|
416
416
|
attrs << %( kumimoji="1") if font[:kumimoji]
|
|
417
|
-
attrs << %( sz="#{font[:size]}") if font[:size]
|
|
417
|
+
attrs << %( sz="#{xml_escape(font[:size])}") if font[:size]
|
|
418
418
|
attrs << %( strike="#{xml_escape(font[:strike])}") if font[:strike]
|
|
419
419
|
attrs << %( u="#{xml_escape(font[:underline])}") if font[:underline]
|
|
420
|
-
attrs << %( baseline="#{font[:baseline]}") if font[:baseline]
|
|
421
|
-
attrs << %( spc="#{font[:spacing]}") if font[:spacing]
|
|
422
|
-
attrs << %( kern="#{font[:kern]}") if font[:kern]
|
|
420
|
+
attrs << %( baseline="#{xml_escape(font[:baseline])}") if font[:baseline]
|
|
421
|
+
attrs << %( spc="#{xml_escape(font[:spacing])}") if font[:spacing]
|
|
422
|
+
attrs << %( kern="#{xml_escape(font[:kern])}") if font[:kern]
|
|
423
423
|
attrs << %( cap="#{xml_escape(font[:cap])}") if font[:cap]
|
|
424
424
|
attrs << %( lang="#{xml_escape(font[:lang])}") if font[:lang]
|
|
425
425
|
attrs << %( altLang="#{xml_escape(font[:alt_lang])}") if font[:alt_lang]
|
|
@@ -448,9 +448,9 @@ module Xlsxrb
|
|
|
448
448
|
if font[:outer_shadow]
|
|
449
449
|
os = font[:outer_shadow]
|
|
450
450
|
oa = +""
|
|
451
|
-
oa << %( blurRad="#{os[:blur_rad]}") if os[:blur_rad]
|
|
452
|
-
oa << %( dist="#{os[:dist]}") if os[:dist]
|
|
453
|
-
oa << %( dir="#{os[:dir]}") if os[:dir]
|
|
451
|
+
oa << %( blurRad="#{xml_escape(os[:blur_rad])}") if os[:blur_rad]
|
|
452
|
+
oa << %( dist="#{xml_escape(os[:dist])}") if os[:dist]
|
|
453
|
+
oa << %( dir="#{xml_escape(os[:dir])}") if os[:dir]
|
|
454
454
|
oa << %( algn="#{xml_escape(os[:algn])}") if os[:algn]
|
|
455
455
|
oa << %( rotWithShape="#{os[:rot_with_shape] ? 1 : 0}") unless os[:rot_with_shape].nil?
|
|
456
456
|
oc = os[:color] ? srgb_clr_xml(os[:color], alpha: os[:alpha]) : ""
|
|
@@ -458,43 +458,43 @@ module Xlsxrb
|
|
|
458
458
|
end
|
|
459
459
|
if font[:glow]
|
|
460
460
|
gl = font[:glow]
|
|
461
|
-
ga = +(gl[:rad] ? %( rad="#{gl[:rad]}") : "")
|
|
461
|
+
ga = +(gl[:rad] ? %( rad="#{xml_escape(gl[:rad])}") : "")
|
|
462
462
|
gc = gl[:color] ? srgb_clr_xml(gl[:color], alpha: gl[:alpha]) : ""
|
|
463
463
|
eff << "<a:glow#{ga}>#{gc}</a:glow>"
|
|
464
464
|
end
|
|
465
465
|
if font[:inner_shadow]
|
|
466
466
|
is = font[:inner_shadow]
|
|
467
467
|
ia = +""
|
|
468
|
-
ia << %( blurRad="#{is[:blur_rad]}") if is[:blur_rad]
|
|
469
|
-
ia << %( dist="#{is[:dist]}") if is[:dist]
|
|
470
|
-
ia << %( dir="#{is[:dir]}") if is[:dir]
|
|
468
|
+
ia << %( blurRad="#{xml_escape(is[:blur_rad])}") if is[:blur_rad]
|
|
469
|
+
ia << %( dist="#{xml_escape(is[:dist])}") if is[:dist]
|
|
470
|
+
ia << %( dir="#{xml_escape(is[:dir])}") if is[:dir]
|
|
471
471
|
ic = is[:color] ? srgb_clr_xml(is[:color], alpha: is[:alpha]) : ""
|
|
472
472
|
eff << "<a:innerShdw#{ia}>#{ic}</a:innerShdw>"
|
|
473
473
|
end
|
|
474
474
|
if font[:reflection]
|
|
475
475
|
rf = font[:reflection]
|
|
476
476
|
ra = +""
|
|
477
|
-
ra << %( blurRad="#{rf[:blur_rad]}") if rf[:blur_rad]
|
|
478
|
-
ra << %( stA="#{rf[:st_a]}") if rf[:st_a]
|
|
479
|
-
ra << %( endA="#{rf[:end_a]}") if rf[:end_a]
|
|
480
|
-
ra << %( dist="#{rf[:dist]}") unless rf[:dist].nil?
|
|
481
|
-
ra << %( dir="#{rf[:dir]}") if rf[:dir]
|
|
482
|
-
ra << %( fadeDir="#{rf[:fade_dir]}") if rf[:fade_dir]
|
|
483
|
-
ra << %( sx="#{rf[:sx]}") if rf[:sx]
|
|
484
|
-
ra << %( sy="#{rf[:sy]}") if rf[:sy]
|
|
485
|
-
ra << %( kx="#{rf[:kx]}") if rf[:kx]
|
|
486
|
-
ra << %( ky="#{rf[:ky]}") if rf[:ky]
|
|
477
|
+
ra << %( blurRad="#{xml_escape(rf[:blur_rad])}") if rf[:blur_rad]
|
|
478
|
+
ra << %( stA="#{xml_escape(rf[:st_a])}") if rf[:st_a]
|
|
479
|
+
ra << %( endA="#{xml_escape(rf[:end_a])}") if rf[:end_a]
|
|
480
|
+
ra << %( dist="#{xml_escape(rf[:dist])}") unless rf[:dist].nil?
|
|
481
|
+
ra << %( dir="#{xml_escape(rf[:dir])}") if rf[:dir]
|
|
482
|
+
ra << %( fadeDir="#{xml_escape(rf[:fade_dir])}") if rf[:fade_dir]
|
|
483
|
+
ra << %( sx="#{xml_escape(rf[:sx])}") if rf[:sx]
|
|
484
|
+
ra << %( sy="#{xml_escape(rf[:sy])}") if rf[:sy]
|
|
485
|
+
ra << %( kx="#{xml_escape(rf[:kx])}") if rf[:kx]
|
|
486
|
+
ra << %( ky="#{xml_escape(rf[:ky])}") if rf[:ky]
|
|
487
487
|
ra << %( algn="#{xml_escape(rf[:algn])}") if rf[:algn]
|
|
488
488
|
ra << %( rotWithShape="#{rf[:rot_with_shape] ? 1 : 0}") unless rf[:rot_with_shape].nil?
|
|
489
489
|
eff << "<a:reflection#{ra}/>"
|
|
490
490
|
end
|
|
491
491
|
if font[:soft_edge]
|
|
492
492
|
se = font[:soft_edge]
|
|
493
|
-
eff << %(<a:softEdge rad="#{se[:rad]}"/>)
|
|
493
|
+
eff << %(<a:softEdge rad="#{xml_escape(se[:rad])}"/>)
|
|
494
494
|
end
|
|
495
495
|
if font[:blur]
|
|
496
496
|
bl = font[:blur]
|
|
497
|
-
ba = +(bl[:rad] ? %( rad="#{bl[:rad]}") : "")
|
|
497
|
+
ba = +(bl[:rad] ? %( rad="#{xml_escape(bl[:rad])}") : "")
|
|
498
498
|
ba << %( grow="#{bl[:grow] ? 1 : 0}") unless bl[:grow].nil?
|
|
499
499
|
eff << "<a:blur#{ba}/>"
|
|
500
500
|
end
|
|
@@ -541,7 +541,7 @@ module Xlsxrb
|
|
|
541
541
|
when :image then "#{DOC_REL_NS}/image"
|
|
542
542
|
when :chart then "#{DOC_REL_NS}/chart"
|
|
543
543
|
end
|
|
544
|
-
parts << %(<Relationship Id="rId#{i + 1}" Type="#{rel_type}" Target="#{rel[:target]}"/>)
|
|
544
|
+
parts << %(<Relationship Id="rId#{i + 1}" Type="#{xml_escape(rel_type)}" Target="#{xml_escape(rel[:target])}"/>)
|
|
545
545
|
end
|
|
546
546
|
parts << "</Relationships>"
|
|
547
547
|
parts.join
|
|
@@ -553,12 +553,12 @@ module Xlsxrb
|
|
|
553
553
|
if title_spec.is_a?(Hash)
|
|
554
554
|
text = xml_escape(title_spec[:text].to_s)
|
|
555
555
|
rotation = title_spec[:rotation]
|
|
556
|
-
body_pr = rotation ? %(<a:bodyPr rot="#{rotation}"/>) : "<a:bodyPr/>"
|
|
556
|
+
body_pr = rotation ? %(<a:bodyPr rot="#{xml_escape(rotation)}"/>) : "<a:bodyPr/>"
|
|
557
557
|
font = title_spec[:font] || {}
|
|
558
558
|
rpr_attrs = +""
|
|
559
559
|
rpr_attrs << %( b="1") if font[:bold]
|
|
560
560
|
rpr_attrs << %( i="1") if font[:italic]
|
|
561
|
-
rpr_attrs << %( sz="#{font[:size]}") if font[:size]
|
|
561
|
+
rpr_attrs << %( sz="#{xml_escape(font[:size])}") if font[:size]
|
|
562
562
|
rpr_children = +""
|
|
563
563
|
rpr_children << %(<a:solidFill>#{color_xml(font[:color])}</a:solidFill>) if font[:color]
|
|
564
564
|
rpr_children << %(<a:latin typeface="#{xml_escape(font[:name])}"/>) if font[:name]
|
|
@@ -569,9 +569,9 @@ module Xlsxrb
|
|
|
569
569
|
end
|
|
570
570
|
layout_xml = build_title_layout_xml(title_spec[:layout])
|
|
571
571
|
sp_xml = build_title_sp_pr(title_spec)
|
|
572
|
-
"<c:title><c:tx><c:rich>#{body_pr}<a:lstStyle/><a:p><a:r>#{rpr_xml}<a:t>#{text}</a:t></a:r></a:p></c:rich></c:tx>#{layout_xml}<c:overlay val=\"#{overlay_val}\"/>#{sp_xml}</c:title>"
|
|
572
|
+
"<c:title><c:tx><c:rich>#{body_pr}<a:lstStyle/><a:p><a:r>#{rpr_xml}<a:t>#{text}</a:t></a:r></a:p></c:rich></c:tx>#{layout_xml}<c:overlay val=\"#{xml_escape(overlay_val)}\"/>#{sp_xml}</c:title>"
|
|
573
573
|
else
|
|
574
|
-
"<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>#{xml_escape(title_spec)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val=\"#{overlay_val}\"/></c:title>"
|
|
574
|
+
"<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>#{xml_escape(title_spec)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val=\"#{xml_escape(overlay_val)}\"/></c:title>"
|
|
575
575
|
end
|
|
576
576
|
end
|
|
577
577
|
|
|
@@ -617,10 +617,10 @@ module Xlsxrb
|
|
|
617
617
|
return "" unless layout.is_a?(Hash)
|
|
618
618
|
|
|
619
619
|
ml = +""
|
|
620
|
-
ml << %(<c:x val="#{layout[:x]}"/>) if layout[:x]
|
|
621
|
-
ml << %(<c:y val="#{layout[:y]}"/>) if layout[:y]
|
|
622
|
-
ml << %(<c:w val="#{layout[:w]}"/>) if layout[:w]
|
|
623
|
-
ml << %(<c:h val="#{layout[:h]}"/>) if layout[:h]
|
|
620
|
+
ml << %(<c:x val="#{xml_escape(layout[:x])}"/>) if layout[:x]
|
|
621
|
+
ml << %(<c:y val="#{xml_escape(layout[:y])}"/>) if layout[:y]
|
|
622
|
+
ml << %(<c:w val="#{xml_escape(layout[:w])}"/>) if layout[:w]
|
|
623
|
+
ml << %(<c:h val="#{xml_escape(layout[:h])}"/>) if layout[:h]
|
|
624
624
|
ml.empty? ? "" : "<c:layout><c:manualLayout>#{ml}</c:manualLayout></c:layout>"
|
|
625
625
|
end
|
|
626
626
|
|
|
@@ -726,14 +726,17 @@ module Xlsxrb
|
|
|
726
726
|
val = xml_escape(normalize_drawing_rgb(color))
|
|
727
727
|
end
|
|
728
728
|
children = +""
|
|
729
|
-
children << %(<a:alpha val="#{alpha}"/>) if alpha
|
|
729
|
+
children << %(<a:alpha val="#{xml_escape(alpha)}"/>) if alpha
|
|
730
730
|
(transforms || []).each do |t|
|
|
731
|
-
|
|
731
|
+
type = t[:type].to_s
|
|
732
|
+
raise ArgumentError, "Unknown color transform: #{type.inspect}. Use one of: #{COLOR_TRANSFORMS.join(", ")}." unless COLOR_TRANSFORMS.include?(type)
|
|
733
|
+
|
|
734
|
+
children << %(<a:#{type} val="#{xml_escape(t[:val])}"/>)
|
|
732
735
|
end
|
|
733
736
|
if children.empty?
|
|
734
|
-
%(<a:#{tag} val="#{val}"/>)
|
|
737
|
+
%(<a:#{tag} val="#{xml_escape(val)}"/>)
|
|
735
738
|
else
|
|
736
|
-
%(<a:#{tag} val="#{val}">#{children}</a:#{tag}>)
|
|
739
|
+
%(<a:#{tag} val="#{xml_escape(val)}">#{children}</a:#{tag}>)
|
|
737
740
|
end
|
|
738
741
|
end
|
|
739
742
|
|
|
@@ -759,7 +762,7 @@ module Xlsxrb
|
|
|
759
762
|
def build_axis_txpr(rotation, font)
|
|
760
763
|
return "" unless rotation || font
|
|
761
764
|
|
|
762
|
-
body_attrs = rotation ? %( rot="#{rotation}") : ""
|
|
765
|
+
body_attrs = rotation ? %( rot="#{xml_escape(rotation)}") : ""
|
|
763
766
|
rpr_attrs = +""
|
|
764
767
|
rpr_children = +""
|
|
765
768
|
if font
|
|
@@ -808,12 +811,12 @@ module Xlsxrb
|
|
|
808
811
|
parts = +""
|
|
809
812
|
val_del = chart[del_key] ? 1 : 0
|
|
810
813
|
val_orient = chart[orient_key] || "minMax"
|
|
811
|
-
parts << %(<c:valAx><c:axId val="#{ax_id}"/><c:scaling>)
|
|
812
|
-
parts << %(<c:logBase val="#{chart[log_key]}"/>) if chart[log_key]
|
|
813
|
-
parts << %(<c:orientation val="#{val_orient}"/>)
|
|
814
|
-
parts << %(<c:max val="#{chart[max_key]}"/>) if chart[max_key]
|
|
815
|
-
parts << %(<c:min val="#{chart[min_key]}"/>) if chart[min_key]
|
|
816
|
-
parts << %(</c:scaling><c:delete val="#{val_del}"/><c:axPos val="#{chart[pos_key] || default_pos}"/>)
|
|
814
|
+
parts << %(<c:valAx><c:axId val="#{xml_escape(ax_id)}"/><c:scaling>)
|
|
815
|
+
parts << %(<c:logBase val="#{xml_escape(chart[log_key])}"/>) if chart[log_key]
|
|
816
|
+
parts << %(<c:orientation val="#{xml_escape(val_orient)}"/>)
|
|
817
|
+
parts << %(<c:max val="#{xml_escape(chart[max_key])}"/>) if chart[max_key]
|
|
818
|
+
parts << %(<c:min val="#{xml_escape(chart[min_key])}"/>) if chart[min_key]
|
|
819
|
+
parts << %(</c:scaling><c:delete val="#{xml_escape(val_del)}"/><c:axPos val="#{xml_escape(chart[pos_key] || default_pos)}"/>)
|
|
817
820
|
parts << gridlines_xml("majorGridlines", chart[major_grid_key])
|
|
818
821
|
parts << gridlines_xml("minorGridlines", chart[minor_grid_key])
|
|
819
822
|
if chart[title_key]
|
|
@@ -823,17 +826,17 @@ module Xlsxrb
|
|
|
823
826
|
if (vnf = chart[num_fmt_key])
|
|
824
827
|
vnf_hash = vnf.is_a?(Hash) ? vnf : { format_code: vnf }
|
|
825
828
|
sl = vnf_hash[:source_linked] ? 1 : 0
|
|
826
|
-
parts << %(<c:numFmt formatCode="#{xml_escape(vnf_hash[:format_code])}" sourceLinked="#{sl}"/>)
|
|
829
|
+
parts << %(<c:numFmt formatCode="#{xml_escape(vnf_hash[:format_code])}" sourceLinked="#{xml_escape(sl)}"/>)
|
|
827
830
|
end
|
|
828
|
-
parts << %(<c:majorTickMark val="#{chart[major_tick_key]}"/>) if chart[major_tick_key]
|
|
829
|
-
parts << %(<c:minorTickMark val="#{chart[minor_tick_key]}"/>) if chart[minor_tick_key]
|
|
830
|
-
parts << %(<c:tickLblPos val="#{chart[tick_lbl_pos_key]}"/>) if chart[tick_lbl_pos_key]
|
|
831
|
+
parts << %(<c:majorTickMark val="#{xml_escape(chart[major_tick_key])}"/>) if chart[major_tick_key]
|
|
832
|
+
parts << %(<c:minorTickMark val="#{xml_escape(chart[minor_tick_key])}"/>) if chart[minor_tick_key]
|
|
833
|
+
parts << %(<c:tickLblPos val="#{xml_escape(chart[tick_lbl_pos_key])}"/>) if chart[tick_lbl_pos_key]
|
|
831
834
|
if chart[line_color_key] || chart[fill_key] || chart[no_fill_key] || chart[line_dash_key]
|
|
832
835
|
parts << "<c:spPr>"
|
|
833
836
|
parts << "<a:noFill/>" if chart[no_fill_key]
|
|
834
837
|
parts << %(<a:solidFill>#{color_xml(chart[fill_key])}</a:solidFill>) if chart[fill_key]
|
|
835
838
|
if chart[line_color_key] || chart[line_dash_key]
|
|
836
|
-
w_attr = chart[line_width_key] ? %( w="#{chart[line_width_key]}") : ""
|
|
839
|
+
w_attr = chart[line_width_key] ? %( w="#{xml_escape(chart[line_width_key])}") : ""
|
|
837
840
|
va_ln_f = chart[line_color_key] ? %(<a:solidFill>#{srgb_clr_xml(chart[line_color_key])}</a:solidFill>) : ""
|
|
838
841
|
va_ln_d = chart[line_dash_key] ? %(<a:prstDash val="#{xml_escape(chart[line_dash_key])}"/>) : ""
|
|
839
842
|
parts << "<a:ln#{w_attr}>#{va_ln_f}#{va_ln_d}</a:ln>"
|
|
@@ -843,17 +846,17 @@ module Xlsxrb
|
|
|
843
846
|
parts << build_axis_txpr(chart[rotation_key], chart[font_key])
|
|
844
847
|
parts << '<c:crossAx val="1"/>'
|
|
845
848
|
crosses_val = chart[crosses_key] || default_crosses
|
|
846
|
-
parts << %(<c:crosses val="#{crosses_val}"/>) if crosses_val
|
|
847
|
-
parts << %(<c:crossesAt val="#{chart[crosses_at_key]}"/>) if !crosses_val && chart[crosses_at_key]
|
|
848
|
-
parts << %(<c:crossBetween val="#{chart[cross_between_key]}"/>) if chart[cross_between_key]
|
|
849
|
-
parts << %(<c:majorUnit val="#{chart[major_unit_key]}"/>) if chart[major_unit_key]
|
|
850
|
-
parts << %(<c:minorUnit val="#{chart[minor_unit_key]}"/>) if chart[minor_unit_key]
|
|
849
|
+
parts << %(<c:crosses val="#{xml_escape(crosses_val)}"/>) if crosses_val
|
|
850
|
+
parts << %(<c:crossesAt val="#{xml_escape(chart[crosses_at_key])}"/>) if !crosses_val && chart[crosses_at_key]
|
|
851
|
+
parts << %(<c:crossBetween val="#{xml_escape(chart[cross_between_key])}"/>) if chart[cross_between_key]
|
|
852
|
+
parts << %(<c:majorUnit val="#{xml_escape(chart[major_unit_key])}"/>) if chart[major_unit_key]
|
|
853
|
+
parts << %(<c:minorUnit val="#{xml_escape(chart[minor_unit_key])}"/>) if chart[minor_unit_key]
|
|
851
854
|
if chart[disp_units_key]
|
|
852
855
|
du = chart[disp_units_key]
|
|
853
856
|
if du.is_a?(Hash)
|
|
854
857
|
parts << "<c:dispUnits>"
|
|
855
858
|
parts << %(<c:builtInUnit val="#{xml_escape(du[:built_in_unit])}"/>) if du[:built_in_unit]
|
|
856
|
-
parts << %(<c:custUnit val="#{du[:cust_unit]}"/>) if du[:cust_unit]
|
|
859
|
+
parts << %(<c:custUnit val="#{xml_escape(du[:cust_unit])}"/>) if du[:cust_unit]
|
|
857
860
|
if du[:label]
|
|
858
861
|
dul = du[:label]
|
|
859
862
|
parts << "<c:dispUnitsLbl>"
|
|
@@ -865,7 +868,7 @@ module Xlsxrb
|
|
|
865
868
|
else
|
|
866
869
|
0
|
|
867
870
|
end
|
|
868
|
-
parts << %(<c:numFmt formatCode="#{xml_escape(nf_src[:format_code])}" sourceLinked="#{nf_linked}"/>)
|
|
871
|
+
parts << %(<c:numFmt formatCode="#{xml_escape(nf_src[:format_code])}" sourceLinked="#{xml_escape(nf_linked)}"/>)
|
|
869
872
|
end
|
|
870
873
|
dul_sp = +""
|
|
871
874
|
dul_sp << %(<a:solidFill>#{color_xml(dul[:fill_color])}</a:solidFill>) if dul[:fill_color]
|
|
@@ -899,7 +902,7 @@ module Xlsxrb
|
|
|
899
902
|
]
|
|
900
903
|
rc = chart[:rounded_corners]
|
|
901
904
|
parts << %(<c:roundedCorners val="#{rc ? 1 : 0}"/>) unless rc.nil?
|
|
902
|
-
parts << %(<c:style val="#{chart[:style]}"/>) if chart[:style]
|
|
905
|
+
parts << %(<c:style val="#{xml_escape(chart[:style])}"/>) if chart[:style]
|
|
903
906
|
if (prot = chart[:protection])
|
|
904
907
|
parts << "<c:protection>"
|
|
905
908
|
parts << %(<c:chartObject val="#{prot[:chart_object] ? 1 : 0}"/>) unless prot[:chart_object].nil?
|
|
@@ -932,13 +935,13 @@ module Xlsxrb
|
|
|
932
935
|
|
|
933
936
|
if (v3d = chart[:view_3d])
|
|
934
937
|
parts << "<c:view3D>"
|
|
935
|
-
parts << %(<c:rotX val="#{v3d[:rot_x]}"/>) if v3d[:rot_x]
|
|
936
|
-
parts << %(<c:hPercent val="#{v3d[:h_percent]}"/>) if v3d[:h_percent]
|
|
937
|
-
parts << %(<c:rotY val="#{v3d[:rot_y]}"/>) if v3d[:rot_y]
|
|
938
|
-
parts << %(<c:depthPercent val="#{v3d[:depth_percent]}"/>) if v3d[:depth_percent]
|
|
938
|
+
parts << %(<c:rotX val="#{xml_escape(v3d[:rot_x])}"/>) if v3d[:rot_x]
|
|
939
|
+
parts << %(<c:hPercent val="#{xml_escape(v3d[:h_percent])}"/>) if v3d[:h_percent]
|
|
940
|
+
parts << %(<c:rotY val="#{xml_escape(v3d[:rot_y])}"/>) if v3d[:rot_y]
|
|
941
|
+
parts << %(<c:depthPercent val="#{xml_escape(v3d[:depth_percent])}"/>) if v3d[:depth_percent]
|
|
939
942
|
r_ang = v3d[:r_ang_ax]
|
|
940
943
|
parts << %(<c:rAngAx val="#{r_ang ? 1 : 0}"/>) unless r_ang.nil?
|
|
941
|
-
parts << %(<c:perspective val="#{v3d[:perspective]}"/>) if v3d[:perspective]
|
|
944
|
+
parts << %(<c:perspective val="#{xml_escape(v3d[:perspective])}"/>) if v3d[:perspective]
|
|
942
945
|
parts << "</c:view3D>"
|
|
943
946
|
end
|
|
944
947
|
|
|
@@ -950,7 +953,7 @@ module Xlsxrb
|
|
|
950
953
|
parts << "<a:solidFill>#{srgb_clr_xml(wall[:fill_color])}</a:solidFill>" if wall[:fill_color]
|
|
951
954
|
parts << "<a:noFill/>" if wall[:no_fill]
|
|
952
955
|
if wall[:line_color] || wall[:line_dash]
|
|
953
|
-
w_attr = wall[:line_width] ? %( w="#{wall[:line_width]}") : ""
|
|
956
|
+
w_attr = wall[:line_width] ? %( w="#{xml_escape(wall[:line_width])}") : ""
|
|
954
957
|
w_fill = wall[:line_color] ? %(<a:solidFill>#{srgb_clr_xml(wall[:line_color])}</a:solidFill>) : ""
|
|
955
958
|
w_dash = wall[:line_dash] ? %(<a:prstDash val="#{xml_escape(wall[:line_dash])}"/>) : ""
|
|
956
959
|
parts << "<a:ln#{w_attr}>#{w_fill}#{w_dash}</a:ln>"
|
|
@@ -967,10 +970,10 @@ module Xlsxrb
|
|
|
967
970
|
ml_parts << %(<c:yMode val="#{xml_escape(pa_layout[:y_mode])}"/>) if pa_layout[:y_mode]
|
|
968
971
|
ml_parts << %(<c:wMode val="#{xml_escape(pa_layout[:w_mode])}"/>) if pa_layout[:w_mode]
|
|
969
972
|
ml_parts << %(<c:hMode val="#{xml_escape(pa_layout[:h_mode])}"/>) if pa_layout[:h_mode]
|
|
970
|
-
ml_parts << %(<c:x val="#{pa_layout[:x]}"/>) if pa_layout[:x]
|
|
971
|
-
ml_parts << %(<c:y val="#{pa_layout[:y]}"/>) if pa_layout[:y]
|
|
972
|
-
ml_parts << %(<c:w val="#{pa_layout[:w]}"/>) if pa_layout[:w]
|
|
973
|
-
ml_parts << %(<c:h val="#{pa_layout[:h]}"/>) if pa_layout[:h]
|
|
973
|
+
ml_parts << %(<c:x val="#{xml_escape(pa_layout[:x])}"/>) if pa_layout[:x]
|
|
974
|
+
ml_parts << %(<c:y val="#{xml_escape(pa_layout[:y])}"/>) if pa_layout[:y]
|
|
975
|
+
ml_parts << %(<c:w val="#{xml_escape(pa_layout[:w])}"/>) if pa_layout[:w]
|
|
976
|
+
ml_parts << %(<c:h val="#{xml_escape(pa_layout[:h])}"/>) if pa_layout[:h]
|
|
974
977
|
parts << if ml_parts.empty?
|
|
975
978
|
"<c:layout/>"
|
|
976
979
|
else
|
|
@@ -992,7 +995,9 @@ module Xlsxrb
|
|
|
992
995
|
groups = []
|
|
993
996
|
all_series.each_with_index do |ser, idx|
|
|
994
997
|
s_type = if ser[:type]
|
|
995
|
-
|
|
998
|
+
# The type is written as an element name, so only known types are accepted.
|
|
999
|
+
CHART_TYPE_MAP[ser[:type]] || CHART_TYPE_MAP.values.find { |element| element == ser[:type].to_s } ||
|
|
1000
|
+
raise(ArgumentError, "Unknown chart series type: #{ser[:type].inspect}. Use one of: #{CHART_TYPE_MAP.keys.map(&:inspect).join(", ")}.")
|
|
996
1001
|
elsif chart_type == "comboChart"
|
|
997
1002
|
"barChart"
|
|
998
1003
|
else
|
|
@@ -1023,12 +1028,12 @@ module Xlsxrb
|
|
|
1023
1028
|
if %w[barChart bar3DChart].include?(g_type)
|
|
1024
1029
|
bd = chart[:bar_dir] || "col"
|
|
1025
1030
|
gr = chart[:grouping] || "clustered"
|
|
1026
|
-
parts << %(<c:barDir val="#{bd}"/><c:grouping val="#{gr}"/>)
|
|
1031
|
+
parts << %(<c:barDir val="#{xml_escape(bd)}"/><c:grouping val="#{xml_escape(gr)}"/>)
|
|
1027
1032
|
elsif GROUPING_CHARTS.include?(g_type)
|
|
1028
|
-
parts << %(<c:grouping val="#{chart[:grouping] || "standard"}"/>)
|
|
1033
|
+
parts << %(<c:grouping val="#{xml_escape(chart[:grouping] || "standard")}"/>)
|
|
1029
1034
|
end
|
|
1030
|
-
parts << %(<c:scatterStyle val="#{chart[:scatter_style] || "lineMarker"}"/>) if g_type == "scatterChart"
|
|
1031
|
-
parts << %(<c:radarStyle val="#{chart[:radar_style] || "standard"}"/>) if g_type == "radarChart"
|
|
1035
|
+
parts << %(<c:scatterStyle val="#{xml_escape(chart[:scatter_style] || "lineMarker")}"/>) if g_type == "scatterChart"
|
|
1036
|
+
parts << %(<c:radarStyle val="#{xml_escape(chart[:radar_style] || "standard")}"/>) if g_type == "radarChart"
|
|
1032
1037
|
vc = chart[:vary_colors]
|
|
1033
1038
|
parts << %(<c:varyColors val="#{vc ? 1 : 0}"/>) unless vc.nil?
|
|
1034
1039
|
wf = chart[:wireframe]
|
|
@@ -1036,21 +1041,21 @@ module Xlsxrb
|
|
|
1036
1041
|
|
|
1037
1042
|
grp[:series].each do |ser, idx|
|
|
1038
1043
|
ser_order = ser[:order] || idx
|
|
1039
|
-
parts << "<c:ser><c:idx val=\"#{idx}\"/><c:order val=\"#{ser_order}\"/>"
|
|
1044
|
+
parts << "<c:ser><c:idx val=\"#{xml_escape(idx)}\"/><c:order val=\"#{xml_escape(ser_order)}\"/>"
|
|
1040
1045
|
parts << "<c:tx><c:strRef><c:f>#{xml_escape(ser[:name])}</c:f>#{str_cache_xml(ser[:name])}</c:strRef></c:tx>" if ser[:name]
|
|
1041
1046
|
head_end = parts.size
|
|
1042
1047
|
iin = ser[:invert_if_negative]
|
|
1043
1048
|
parts << %(<c:invertIfNegative val="#{iin ? 1 : 0}"/>) unless iin.nil?
|
|
1044
|
-
parts << %(<c:explosion val="#{ser[:explosion]}"/>) if ser[:explosion]
|
|
1049
|
+
parts << %(<c:explosion val="#{xml_escape(ser[:explosion])}"/>) if ser[:explosion]
|
|
1045
1050
|
options_end = parts.size
|
|
1046
1051
|
ser[:data_points]&.each do |dp|
|
|
1047
|
-
parts << "<c:dPt><c:idx val=\"#{dp[:idx]}\"/>"
|
|
1052
|
+
parts << "<c:dPt><c:idx val=\"#{xml_escape(dp[:idx])}\"/>"
|
|
1048
1053
|
dp_iin = dp[:invert_if_negative]
|
|
1049
1054
|
parts << %(<c:invertIfNegative val="#{dp_iin ? 1 : 0}"/>) unless dp_iin.nil?
|
|
1050
1055
|
if dp[:marker_symbol] || dp[:marker_size] || dp[:marker_fill] || dp[:marker_no_fill] || dp[:marker_line_color] || dp[:marker_line_dash] || dp[:marker_no_line]
|
|
1051
1056
|
parts << "<c:marker>"
|
|
1052
1057
|
parts << %(<c:symbol val="#{xml_escape(dp[:marker_symbol])}"/>) if dp[:marker_symbol]
|
|
1053
|
-
parts << %(<c:size val="#{dp[:marker_size]}"/>) if dp[:marker_size]
|
|
1058
|
+
parts << %(<c:size val="#{xml_escape(dp[:marker_size])}"/>) if dp[:marker_size]
|
|
1054
1059
|
if dp[:marker_fill] || dp[:marker_no_fill] || dp[:marker_line_color] || dp[:marker_line_dash] || dp[:marker_no_line]
|
|
1055
1060
|
mk_sp = +""
|
|
1056
1061
|
mk_sp << "<a:noFill/>" if dp[:marker_no_fill]
|
|
@@ -1069,7 +1074,7 @@ module Xlsxrb
|
|
|
1069
1074
|
end
|
|
1070
1075
|
dp_b3d = dp[:bubble_3d]
|
|
1071
1076
|
parts << %(<c:bubble3D val="#{dp_b3d ? 1 : 0}"/>) unless dp_b3d.nil?
|
|
1072
|
-
parts << %(<c:explosion val="#{dp[:explosion]}"/>) if dp[:explosion]
|
|
1077
|
+
parts << %(<c:explosion val="#{xml_escape(dp[:explosion])}"/>) if dp[:explosion]
|
|
1073
1078
|
dp_sp_children = +""
|
|
1074
1079
|
dp_sp_children << %(<a:solidFill>#{color_xml(dp[:fill_color])}</a:solidFill>) if dp[:fill_color]
|
|
1075
1080
|
dp_sp_children << "<a:noFill/>" if dp[:no_fill]
|
|
@@ -1110,7 +1115,7 @@ module Xlsxrb
|
|
|
1110
1115
|
if ser[:marker_symbol] || ser[:marker_size] || ser[:marker_fill] || ser[:marker_no_fill] || ser[:marker_line_color] || ser[:marker_line_dash] || ser[:marker_no_line]
|
|
1111
1116
|
parts << "<c:marker>"
|
|
1112
1117
|
parts << %(<c:symbol val="#{xml_escape(ser[:marker_symbol])}"/>) if ser[:marker_symbol]
|
|
1113
|
-
parts << %(<c:size val="#{ser[:marker_size]}"/>) if ser[:marker_size]
|
|
1118
|
+
parts << %(<c:size val="#{xml_escape(ser[:marker_size])}"/>) if ser[:marker_size]
|
|
1114
1119
|
if ser[:marker_fill] || ser[:marker_no_fill] || ser[:marker_line_color] || ser[:marker_line_dash] || ser[:marker_no_line]
|
|
1115
1120
|
parts << "<c:spPr>"
|
|
1116
1121
|
parts << "<a:noFill/>" if ser[:marker_no_fill]
|
|
@@ -1138,14 +1143,14 @@ module Xlsxrb
|
|
|
1138
1143
|
parts << "<c:dLbls>"
|
|
1139
1144
|
dl[:labels]&.each do |lbl|
|
|
1140
1145
|
parts << "<c:dLbl>"
|
|
1141
|
-
parts << %(<c:idx val="#{lbl[:idx]}"/>)
|
|
1146
|
+
parts << %(<c:idx val="#{xml_escape(lbl[:idx])}"/>)
|
|
1142
1147
|
if lbl[:delete]
|
|
1143
1148
|
parts << '<c:delete val="1"/>'
|
|
1144
1149
|
else
|
|
1145
1150
|
if (lbl_layout = lbl[:layout])
|
|
1146
1151
|
ml = +""
|
|
1147
|
-
ml << %(<c:x val="#{lbl_layout[:x]}"/>) if lbl_layout[:x]
|
|
1148
|
-
ml << %(<c:y val="#{lbl_layout[:y]}"/>) if lbl_layout[:y]
|
|
1152
|
+
ml << %(<c:x val="#{xml_escape(lbl_layout[:x])}"/>) if lbl_layout[:x]
|
|
1153
|
+
ml << %(<c:y val="#{xml_escape(lbl_layout[:y])}"/>) if lbl_layout[:y]
|
|
1149
1154
|
parts << (ml.empty? ? "<c:layout/>" : "<c:layout><c:manualLayout>#{ml}</c:manualLayout></c:layout>")
|
|
1150
1155
|
end
|
|
1151
1156
|
parts << "<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>#{xml_escape(lbl[:text])}</a:t></a:r></a:p></c:rich></c:tx>" if lbl[:text]
|
|
@@ -1165,7 +1170,7 @@ module Xlsxrb
|
|
|
1165
1170
|
end
|
|
1166
1171
|
parts << "<c:spPr>#{lbl_sp}</c:spPr>" unless lbl_sp.empty?
|
|
1167
1172
|
parts << build_axis_txpr(nil, lbl[:font]) if lbl[:font]
|
|
1168
|
-
parts << %(<c:dLblPos val="#{lbl[:position]}"/>) if lbl[:position]
|
|
1173
|
+
parts << %(<c:dLblPos val="#{xml_escape(lbl[:position])}"/>) if lbl[:position]
|
|
1169
1174
|
parts << "<c:showLegendKey val=\"#{lbl[:show_legend_key] ? 1 : 0}\"/>" unless lbl[:show_legend_key].nil?
|
|
1170
1175
|
parts << "<c:showVal val=\"#{lbl[:show_val] ? 1 : 0}\"/>" unless lbl[:show_val].nil?
|
|
1171
1176
|
parts << "<c:showCatName val=\"#{lbl[:show_cat_name] ? 1 : 0}\"/>" unless lbl[:show_cat_name].nil?
|
|
@@ -1192,7 +1197,7 @@ module Xlsxrb
|
|
|
1192
1197
|
end
|
|
1193
1198
|
parts << "<c:spPr>#{dl_sp_children}</c:spPr>" unless dl_sp_children.empty?
|
|
1194
1199
|
parts << build_axis_txpr(nil, dl[:font]) if dl[:font]
|
|
1195
|
-
parts << %(<c:dLblPos val="#{dl[:position]}"/>) if dl[:position]
|
|
1200
|
+
parts << %(<c:dLblPos val="#{xml_escape(dl[:position])}"/>) if dl[:position]
|
|
1196
1201
|
parts << "<c:showLegendKey val=\"#{dl[:show_legend_key] ? 1 : 0}\"/>" unless dl[:show_legend_key].nil?
|
|
1197
1202
|
parts << "<c:showVal val=\"#{dl[:show_val] ? 1 : 0}\"/>" unless dl[:show_val].nil?
|
|
1198
1203
|
parts << "<c:showCatName val=\"#{dl[:show_cat_name] ? 1 : 0}\"/>" unless dl[:show_cat_name].nil?
|
|
@@ -1232,11 +1237,11 @@ module Xlsxrb
|
|
|
1232
1237
|
end
|
|
1233
1238
|
parts << "<c:spPr>#{tl_sp_children}</c:spPr>" unless tl_sp_children.empty?
|
|
1234
1239
|
parts << %(<c:trendlineType val="#{xml_escape(tl[:type] || "linear")}"/>)
|
|
1235
|
-
parts << %(<c:order val="#{tl[:order]}"/>) if tl[:order]
|
|
1236
|
-
parts << %(<c:period val="#{tl[:period]}"/>) if tl[:period]
|
|
1237
|
-
parts << %(<c:forward val="#{tl[:forward]}"/>) if tl[:forward]
|
|
1238
|
-
parts << %(<c:backward val="#{tl[:backward]}"/>) if tl[:backward]
|
|
1239
|
-
parts << %(<c:intercept val="#{tl[:intercept]}"/>) if tl[:intercept]
|
|
1240
|
+
parts << %(<c:order val="#{xml_escape(tl[:order])}"/>) if tl[:order]
|
|
1241
|
+
parts << %(<c:period val="#{xml_escape(tl[:period])}"/>) if tl[:period]
|
|
1242
|
+
parts << %(<c:forward val="#{xml_escape(tl[:forward])}"/>) if tl[:forward]
|
|
1243
|
+
parts << %(<c:backward val="#{xml_escape(tl[:backward])}"/>) if tl[:backward]
|
|
1244
|
+
parts << %(<c:intercept val="#{xml_escape(tl[:intercept])}"/>) if tl[:intercept]
|
|
1240
1245
|
parts << %(<c:dispRSqr val="#{tl[:disp_r_sqr] ? 1 : 0}"/>) unless tl[:disp_r_sqr].nil?
|
|
1241
1246
|
parts << %(<c:dispEq val="#{tl[:disp_eq] ? 1 : 0}"/>) unless tl[:disp_eq].nil?
|
|
1242
1247
|
if tl[:label]
|
|
@@ -1252,7 +1257,7 @@ module Xlsxrb
|
|
|
1252
1257
|
else
|
|
1253
1258
|
0
|
|
1254
1259
|
end
|
|
1255
|
-
parts << %(<c:numFmt formatCode="#{xml_escape(nf_src[:format_code])}" sourceLinked="#{nf_linked}"/>)
|
|
1260
|
+
parts << %(<c:numFmt formatCode="#{xml_escape(nf_src[:format_code])}" sourceLinked="#{xml_escape(nf_linked)}"/>)
|
|
1256
1261
|
end
|
|
1257
1262
|
tll_sp = +""
|
|
1258
1263
|
tll_sp << %(<a:solidFill>#{color_xml(lbl[:fill_color])}</a:solidFill>) if lbl[:fill_color]
|
|
@@ -1278,7 +1283,7 @@ module Xlsxrb
|
|
|
1278
1283
|
parts << %(<c:noEndCap val="#{eb[:no_end_cap] ? 1 : 0}"/>) unless eb[:no_end_cap].nil?
|
|
1279
1284
|
parts << "<c:plus><c:numRef><c:f>#{xml_escape(eb[:plus])}</c:f></c:numRef></c:plus>" if eb[:plus]
|
|
1280
1285
|
parts << "<c:minus><c:numRef><c:f>#{xml_escape(eb[:minus])}</c:f></c:numRef></c:minus>" if eb[:minus]
|
|
1281
|
-
parts << %(<c:val val="#{eb[:val]}"/>) if eb[:val]
|
|
1286
|
+
parts << %(<c:val val="#{xml_escape(eb[:val])}"/>) if eb[:val]
|
|
1282
1287
|
eb_sp_children = +""
|
|
1283
1288
|
eb_sp_children << %(<a:solidFill>#{color_xml(eb[:fill_color])}</a:solidFill>) if eb[:fill_color]
|
|
1284
1289
|
eb_sp_children << "<a:noFill/>" if eb[:no_fill]
|
|
@@ -1311,7 +1316,7 @@ module Xlsxrb
|
|
|
1311
1316
|
if chart[:band_fmts]
|
|
1312
1317
|
parts << "<c:bandFmts>"
|
|
1313
1318
|
chart[:band_fmts].each do |bf|
|
|
1314
|
-
parts << "<c:bandFmt><c:idx val=\"#{bf[:idx]}\"/>"
|
|
1319
|
+
parts << "<c:bandFmt><c:idx val=\"#{xml_escape(bf[:idx])}\"/>"
|
|
1315
1320
|
bf_sp = +""
|
|
1316
1321
|
bf_sp << %(<a:solidFill>#{color_xml(bf[:fill_color])}</a:solidFill>) if bf[:fill_color]
|
|
1317
1322
|
bf_sp << "<a:noFill/>" if bf[:no_fill]
|
|
@@ -1327,29 +1332,29 @@ module Xlsxrb
|
|
|
1327
1332
|
parts << "</c:bandFmts>"
|
|
1328
1333
|
end
|
|
1329
1334
|
|
|
1330
|
-
parts << %(<c:gapWidth val="#{chart[:gap_width]}"/>) if chart[:gap_width]
|
|
1335
|
+
parts << %(<c:gapWidth val="#{xml_escape(chart[:gap_width])}"/>) if chart[:gap_width]
|
|
1331
1336
|
parts << %(<c:splitType val="#{xml_escape(chart[:split_type])}"/>) if chart[:split_type]
|
|
1332
|
-
parts << %(<c:splitPos val="#{chart[:split_pos]}"/>) if chart[:split_pos]
|
|
1337
|
+
parts << %(<c:splitPos val="#{xml_escape(chart[:split_pos])}"/>) if chart[:split_pos]
|
|
1333
1338
|
if chart[:cust_split]&.any?
|
|
1334
1339
|
parts << "<c:custSplit>"
|
|
1335
|
-
chart[:cust_split].each { |idx| parts << %(<c:secondPiePt val="#{idx}"/>) }
|
|
1340
|
+
chart[:cust_split].each { |idx| parts << %(<c:secondPiePt val="#{xml_escape(idx)}"/>) }
|
|
1336
1341
|
parts << "</c:custSplit>"
|
|
1337
1342
|
end
|
|
1338
|
-
parts << %(<c:secondPieSize val="#{chart[:second_pie_size]}"/>) if chart[:second_pie_size]
|
|
1339
|
-
parts << %(<c:gapDepth val="#{chart[:gap_depth]}"/>) if chart[:gap_depth]
|
|
1340
|
-
parts << %(<c:overlap val="#{chart[:overlap]}"/>) if chart[:overlap]
|
|
1341
|
-
parts << %(<c:shape val="#{chart[:bar_shape]}"/>) if chart[:bar_shape]
|
|
1343
|
+
parts << %(<c:secondPieSize val="#{xml_escape(chart[:second_pie_size])}"/>) if chart[:second_pie_size]
|
|
1344
|
+
parts << %(<c:gapDepth val="#{xml_escape(chart[:gap_depth])}"/>) if chart[:gap_depth]
|
|
1345
|
+
parts << %(<c:overlap val="#{xml_escape(chart[:overlap])}"/>) if chart[:overlap]
|
|
1346
|
+
parts << %(<c:shape val="#{xml_escape(chart[:bar_shape])}"/>) if chart[:bar_shape]
|
|
1342
1347
|
b3d = chart[:bubble_3d]
|
|
1343
1348
|
parts << %(<c:bubble3D val="#{b3d ? 1 : 0}"/>) unless b3d.nil?
|
|
1344
|
-
parts << %(<c:bubbleScale val="#{chart[:bubble_scale]}"/>) if chart[:bubble_scale]
|
|
1349
|
+
parts << %(<c:bubbleScale val="#{xml_escape(chart[:bubble_scale])}"/>) if chart[:bubble_scale]
|
|
1345
1350
|
snb = chart[:show_neg_bubbles]
|
|
1346
1351
|
parts << %(<c:showNegBubbles val="#{snb ? 1 : 0}"/>) unless snb.nil?
|
|
1347
|
-
parts << %(<c:sizeRepresents val="#{chart[:size_represents]}"/>) if chart[:size_represents]
|
|
1352
|
+
parts << %(<c:sizeRepresents val="#{xml_escape(chart[:size_represents])}"/>) if chart[:size_represents]
|
|
1348
1353
|
# Doughnut charts carry both; Excel's defaults are 0 and 50.
|
|
1349
1354
|
first_slice_ang = chart[:first_slice_ang] || (0 if g_type == "doughnutChart")
|
|
1350
1355
|
hole_size = chart[:hole_size] || (50 if g_type == "doughnutChart")
|
|
1351
|
-
parts << %(<c:firstSliceAng val="#{first_slice_ang}"/>) if first_slice_ang
|
|
1352
|
-
parts << %(<c:holeSize val="#{hole_size}"/>) if hole_size
|
|
1356
|
+
parts << %(<c:firstSliceAng val="#{xml_escape(first_slice_ang)}"/>) if first_slice_ang
|
|
1357
|
+
parts << %(<c:holeSize val="#{xml_escape(hole_size)}"/>) if hole_size
|
|
1353
1358
|
if chart[:ser_lines]
|
|
1354
1359
|
sl_spec = chart[:ser_lines]
|
|
1355
1360
|
if sl_spec.is_a?(Hash)
|
|
@@ -1398,7 +1403,7 @@ module Xlsxrb
|
|
|
1398
1403
|
if chart[:up_down_bars]
|
|
1399
1404
|
udb = chart[:up_down_bars]
|
|
1400
1405
|
parts << "<c:upDownBars>"
|
|
1401
|
-
parts << %(<c:gapWidth val="#{udb[:gap_width]}"/>) if udb.is_a?(Hash) && udb[:gap_width]
|
|
1406
|
+
parts << %(<c:gapWidth val="#{xml_escape(udb[:gap_width])}"/>) if udb.is_a?(Hash) && udb[:gap_width]
|
|
1402
1407
|
%i[up_bars down_bars].each do |bar_key|
|
|
1403
1408
|
tag = bar_key == :up_bars ? "upBars" : "downBars"
|
|
1404
1409
|
bar = udb.is_a?(Hash) ? udb[bar_key] : nil
|
|
@@ -1425,7 +1430,7 @@ module Xlsxrb
|
|
|
1425
1430
|
parts << %(<c:smooth val="#{sm ? 1 : 0}"/>) unless sm.nil?
|
|
1426
1431
|
three_axes = THREE_AXIS_CHARTS.include?(g_type)
|
|
1427
1432
|
unless g_no_axes
|
|
1428
|
-
parts << %(<c:axId val="1"/><c:axId val="#{g_val_ax}"/>)
|
|
1433
|
+
parts << %(<c:axId val="1"/><c:axId val="#{xml_escape(g_val_ax)}"/>)
|
|
1429
1434
|
parts << '<c:axId val="3"/>' if three_axes
|
|
1430
1435
|
end
|
|
1431
1436
|
parts << "</c:#{g_type}>"
|
|
@@ -1437,11 +1442,11 @@ module Xlsxrb
|
|
|
1437
1442
|
cat_orient = chart[:cat_axis_orientation] || "minMax"
|
|
1438
1443
|
cat_ax_tag = chart[:cat_axis_type] == :date ? "dateAx" : "catAx"
|
|
1439
1444
|
parts << %(<c:#{cat_ax_tag}><c:axId val="1"/><c:scaling>)
|
|
1440
|
-
parts << %(<c:logBase val="#{chart[:cat_axis_log_base]}"/>) if chart[:cat_axis_log_base]
|
|
1441
|
-
parts << %(<c:orientation val="#{cat_orient}"/>)
|
|
1442
|
-
parts << %(<c:max val="#{chart[:cat_axis_scaling_max]}"/>) if chart[:cat_axis_scaling_max]
|
|
1443
|
-
parts << %(<c:min val="#{chart[:cat_axis_scaling_min]}"/>) if chart[:cat_axis_scaling_min]
|
|
1444
|
-
parts << %(</c:scaling><c:delete val="#{cat_del}"/><c:axPos val="#{chart[:cat_axis_pos] || "b"}"/>)
|
|
1445
|
+
parts << %(<c:logBase val="#{xml_escape(chart[:cat_axis_log_base])}"/>) if chart[:cat_axis_log_base]
|
|
1446
|
+
parts << %(<c:orientation val="#{xml_escape(cat_orient)}"/>)
|
|
1447
|
+
parts << %(<c:max val="#{xml_escape(chart[:cat_axis_scaling_max])}"/>) if chart[:cat_axis_scaling_max]
|
|
1448
|
+
parts << %(<c:min val="#{xml_escape(chart[:cat_axis_scaling_min])}"/>) if chart[:cat_axis_scaling_min]
|
|
1449
|
+
parts << %(</c:scaling><c:delete val="#{xml_escape(cat_del)}"/><c:axPos val="#{xml_escape(chart[:cat_axis_pos] || "b")}"/>)
|
|
1445
1450
|
parts << gridlines_xml("majorGridlines", chart[:cat_axis_major_gridlines])
|
|
1446
1451
|
parts << gridlines_xml("minorGridlines", chart[:cat_axis_minor_gridlines])
|
|
1447
1452
|
if chart[:cat_axis_title]
|
|
@@ -1450,17 +1455,17 @@ module Xlsxrb
|
|
|
1450
1455
|
end
|
|
1451
1456
|
if (cnf = chart[:cat_axis_num_fmt])
|
|
1452
1457
|
sl = cnf[:source_linked] ? 1 : 0
|
|
1453
|
-
parts << %(<c:numFmt formatCode="#{xml_escape(cnf[:format_code])}" sourceLinked="#{sl}"/>)
|
|
1458
|
+
parts << %(<c:numFmt formatCode="#{xml_escape(cnf[:format_code])}" sourceLinked="#{xml_escape(sl)}"/>)
|
|
1454
1459
|
end
|
|
1455
|
-
parts << %(<c:majorTickMark val="#{chart[:cat_axis_major_tick_mark]}"/>) if chart[:cat_axis_major_tick_mark]
|
|
1456
|
-
parts << %(<c:minorTickMark val="#{chart[:cat_axis_minor_tick_mark]}"/>) if chart[:cat_axis_minor_tick_mark]
|
|
1457
|
-
parts << %(<c:tickLblPos val="#{chart[:cat_axis_tick_lbl_pos]}"/>) if chart[:cat_axis_tick_lbl_pos]
|
|
1460
|
+
parts << %(<c:majorTickMark val="#{xml_escape(chart[:cat_axis_major_tick_mark])}"/>) if chart[:cat_axis_major_tick_mark]
|
|
1461
|
+
parts << %(<c:minorTickMark val="#{xml_escape(chart[:cat_axis_minor_tick_mark])}"/>) if chart[:cat_axis_minor_tick_mark]
|
|
1462
|
+
parts << %(<c:tickLblPos val="#{xml_escape(chart[:cat_axis_tick_lbl_pos])}"/>) if chart[:cat_axis_tick_lbl_pos]
|
|
1458
1463
|
if chart[:cat_axis_line_color] || chart[:cat_axis_fill] || chart[:cat_axis_no_fill] || chart[:cat_axis_line_dash]
|
|
1459
1464
|
parts << "<c:spPr>"
|
|
1460
1465
|
parts << "<a:noFill/>" if chart[:cat_axis_no_fill]
|
|
1461
1466
|
parts << %(<a:solidFill>#{color_xml(chart[:cat_axis_fill])}</a:solidFill>) if chart[:cat_axis_fill]
|
|
1462
1467
|
if chart[:cat_axis_line_color] || chart[:cat_axis_line_dash]
|
|
1463
|
-
w_attr = chart[:cat_axis_line_width] ? %( w="#{chart[:cat_axis_line_width]}") : ""
|
|
1468
|
+
w_attr = chart[:cat_axis_line_width] ? %( w="#{xml_escape(chart[:cat_axis_line_width])}") : ""
|
|
1464
1469
|
ca_ln_f = chart[:cat_axis_line_color] ? %(<a:solidFill>#{srgb_clr_xml(chart[:cat_axis_line_color])}</a:solidFill>) : ""
|
|
1465
1470
|
ca_ln_d = chart[:cat_axis_line_dash] ? %(<a:prstDash val="#{xml_escape(chart[:cat_axis_line_dash])}"/>) : ""
|
|
1466
1471
|
parts << "<a:ln#{w_attr}>#{ca_ln_f}#{ca_ln_d}</a:ln>"
|
|
@@ -1469,22 +1474,22 @@ module Xlsxrb
|
|
|
1469
1474
|
end
|
|
1470
1475
|
parts << build_axis_txpr(chart[:cat_axis_label_rotation], chart[:cat_axis_font])
|
|
1471
1476
|
parts << '<c:crossAx val="2"/>'
|
|
1472
|
-
parts << %(<c:crosses val="#{chart[:cat_axis_crosses]}"/>) if chart[:cat_axis_crosses]
|
|
1473
|
-
parts << %(<c:crossesAt val="#{chart[:cat_axis_crosses_at]}"/>) if !chart[:cat_axis_crosses] && chart[:cat_axis_crosses_at]
|
|
1477
|
+
parts << %(<c:crosses val="#{xml_escape(chart[:cat_axis_crosses])}"/>) if chart[:cat_axis_crosses]
|
|
1478
|
+
parts << %(<c:crossesAt val="#{xml_escape(chart[:cat_axis_crosses_at])}"/>) if !chart[:cat_axis_crosses] && chart[:cat_axis_crosses_at]
|
|
1474
1479
|
ca_auto = chart[:cat_axis_auto]
|
|
1475
1480
|
parts << %(<c:auto val="#{ca_auto ? 1 : 0}"/>) unless ca_auto.nil?
|
|
1476
1481
|
parts << %(<c:lblAlgn val="#{xml_escape(chart[:cat_axis_lbl_algn])}"/>) if chart[:cat_axis_lbl_algn]
|
|
1477
|
-
parts << %(<c:lblOffset val="#{chart[:cat_axis_lbl_offset]}"/>) if chart[:cat_axis_lbl_offset]
|
|
1478
|
-
parts << %(<c:tickLblSkip val="#{chart[:cat_axis_tick_lbl_skip]}"/>) if chart[:cat_axis_tick_lbl_skip]
|
|
1479
|
-
parts << %(<c:tickMarkSkip val="#{chart[:cat_axis_tick_mark_skip]}"/>) if chart[:cat_axis_tick_mark_skip]
|
|
1482
|
+
parts << %(<c:lblOffset val="#{xml_escape(chart[:cat_axis_lbl_offset])}"/>) if chart[:cat_axis_lbl_offset]
|
|
1483
|
+
parts << %(<c:tickLblSkip val="#{xml_escape(chart[:cat_axis_tick_lbl_skip])}"/>) if chart[:cat_axis_tick_lbl_skip]
|
|
1484
|
+
parts << %(<c:tickMarkSkip val="#{xml_escape(chart[:cat_axis_tick_mark_skip])}"/>) if chart[:cat_axis_tick_mark_skip]
|
|
1480
1485
|
nml = chart[:cat_axis_no_multi_lvl_lbl]
|
|
1481
1486
|
parts << %(<c:noMultiLvlLbl val="#{nml ? 1 : 0}"/>) unless nml.nil?
|
|
1482
1487
|
if cat_ax_tag == "dateAx"
|
|
1483
|
-
parts << %(<c:baseTimeUnit val="#{chart[:cat_axis_base_time_unit]}"/>) if chart[:cat_axis_base_time_unit]
|
|
1484
|
-
parts << %(<c:majorUnit val="#{chart[:cat_axis_major_unit]}"/>) if chart[:cat_axis_major_unit]
|
|
1485
|
-
parts << %(<c:majorTimeUnit val="#{chart[:cat_axis_major_time_unit]}"/>) if chart[:cat_axis_major_time_unit]
|
|
1486
|
-
parts << %(<c:minorUnit val="#{chart[:cat_axis_minor_unit]}"/>) if chart[:cat_axis_minor_unit]
|
|
1487
|
-
parts << %(<c:minorTimeUnit val="#{chart[:cat_axis_minor_time_unit]}"/>) if chart[:cat_axis_minor_time_unit]
|
|
1488
|
+
parts << %(<c:baseTimeUnit val="#{xml_escape(chart[:cat_axis_base_time_unit])}"/>) if chart[:cat_axis_base_time_unit]
|
|
1489
|
+
parts << %(<c:majorUnit val="#{xml_escape(chart[:cat_axis_major_unit])}"/>) if chart[:cat_axis_major_unit]
|
|
1490
|
+
parts << %(<c:majorTimeUnit val="#{xml_escape(chart[:cat_axis_major_time_unit])}"/>) if chart[:cat_axis_major_time_unit]
|
|
1491
|
+
parts << %(<c:minorUnit val="#{xml_escape(chart[:cat_axis_minor_unit])}"/>) if chart[:cat_axis_minor_unit]
|
|
1492
|
+
parts << %(<c:minorTimeUnit val="#{xml_escape(chart[:cat_axis_minor_time_unit])}"/>) if chart[:cat_axis_minor_time_unit]
|
|
1488
1493
|
end
|
|
1489
1494
|
parts << "</c:#{cat_ax_tag}>"
|
|
1490
1495
|
|
|
@@ -1534,10 +1539,10 @@ module Xlsxrb
|
|
|
1534
1539
|
parts << "</c:plotArea>"
|
|
1535
1540
|
legend_pos = chart.dig(:legend, :position) || "r"
|
|
1536
1541
|
legend_overlay = chart.dig(:legend, :overlay)
|
|
1537
|
-
parts << %(<c:legend><c:legendPos val="#{legend_pos}"/>)
|
|
1542
|
+
parts << %(<c:legend><c:legendPos val="#{xml_escape(legend_pos)}"/>)
|
|
1538
1543
|
legend_entries = chart.dig(:legend, :entries)
|
|
1539
1544
|
legend_entries&.each do |entry|
|
|
1540
|
-
parts << %(<c:legendEntry><c:idx val="#{entry[:idx]}"/>)
|
|
1545
|
+
parts << %(<c:legendEntry><c:idx val="#{xml_escape(entry[:idx])}"/>)
|
|
1541
1546
|
if !entry[:delete].nil?
|
|
1542
1547
|
parts << %(<c:delete val="#{entry[:delete] ? 1 : 0}"/>)
|
|
1543
1548
|
elsif entry[:font]
|
|
@@ -1553,10 +1558,10 @@ module Xlsxrb
|
|
|
1553
1558
|
ml_parts << %(<c:yMode val="#{xml_escape(legend_layout[:y_mode])}"/>) if legend_layout[:y_mode]
|
|
1554
1559
|
ml_parts << %(<c:wMode val="#{xml_escape(legend_layout[:w_mode])}"/>) if legend_layout[:w_mode]
|
|
1555
1560
|
ml_parts << %(<c:hMode val="#{xml_escape(legend_layout[:h_mode])}"/>) if legend_layout[:h_mode]
|
|
1556
|
-
ml_parts << %(<c:x val="#{legend_layout[:x]}"/>) if legend_layout[:x]
|
|
1557
|
-
ml_parts << %(<c:y val="#{legend_layout[:y]}"/>) if legend_layout[:y]
|
|
1558
|
-
ml_parts << %(<c:w val="#{legend_layout[:w]}"/>) if legend_layout[:w]
|
|
1559
|
-
ml_parts << %(<c:h val="#{legend_layout[:h]}"/>) if legend_layout[:h]
|
|
1561
|
+
ml_parts << %(<c:x val="#{xml_escape(legend_layout[:x])}"/>) if legend_layout[:x]
|
|
1562
|
+
ml_parts << %(<c:y val="#{xml_escape(legend_layout[:y])}"/>) if legend_layout[:y]
|
|
1563
|
+
ml_parts << %(<c:w val="#{xml_escape(legend_layout[:w])}"/>) if legend_layout[:w]
|
|
1564
|
+
ml_parts << %(<c:h val="#{xml_escape(legend_layout[:h])}"/>) if legend_layout[:h]
|
|
1560
1565
|
parts << "<c:layout><c:manualLayout>#{ml_parts}</c:manualLayout></c:layout>" unless ml_parts.empty?
|
|
1561
1566
|
end
|
|
1562
1567
|
parts << %(<c:overlay val="#{legend_overlay ? 1 : 0}"/>) unless legend_overlay.nil?
|
|
@@ -1581,7 +1586,7 @@ module Xlsxrb
|
|
|
1581
1586
|
parts << %(</c:legend>)
|
|
1582
1587
|
pvo = chart[:plot_vis_only]
|
|
1583
1588
|
parts << %(<c:plotVisOnly val="#{pvo ? 1 : 0}"/>) unless pvo.nil?
|
|
1584
|
-
parts << %(<c:dispBlanksAs val="#{chart[:disp_blanks_as]}"/>) if chart[:disp_blanks_as]
|
|
1589
|
+
parts << %(<c:dispBlanksAs val="#{xml_escape(chart[:disp_blanks_as])}"/>) if chart[:disp_blanks_as]
|
|
1585
1590
|
sdom = chart[:show_d_lbls_over_max]
|
|
1586
1591
|
parts << %(<c:showDLblsOverMax val="#{sdom ? 1 : 0}"/>) unless sdom.nil?
|
|
1587
1592
|
parts << "</c:chart>"
|
|
@@ -1611,17 +1616,17 @@ module Xlsxrb
|
|
|
1611
1616
|
parts << "</c:headerFooter>"
|
|
1612
1617
|
end
|
|
1613
1618
|
if (pm = ps[:page_margins])
|
|
1614
|
-
pm_attrs = %w[b l r t header footer].filter_map { |a| pm[a.to_sym] ? %( #{a}="#{pm[a.to_sym]}") : nil }.join
|
|
1619
|
+
pm_attrs = %w[b l r t header footer].filter_map { |a| pm[a.to_sym] ? %( #{a}="#{xml_escape(pm[a.to_sym])}") : nil }.join
|
|
1615
1620
|
parts << "<c:pageMargins#{pm_attrs}/>"
|
|
1616
1621
|
end
|
|
1617
1622
|
if (psu = ps[:page_setup])
|
|
1618
1623
|
psu_parts = +""
|
|
1619
|
-
psu_parts << %( paperSize="#{psu[:paper_size]}") if psu[:paper_size]
|
|
1620
|
-
psu_parts << %( firstPageNumber="#{psu[:first_page_number]}") if psu[:first_page_number]
|
|
1624
|
+
psu_parts << %( paperSize="#{xml_escape(psu[:paper_size])}") if psu[:paper_size]
|
|
1625
|
+
psu_parts << %( firstPageNumber="#{xml_escape(psu[:first_page_number])}") if psu[:first_page_number]
|
|
1621
1626
|
psu_parts << %( orientation="#{xml_escape(psu[:orientation])}") if psu[:orientation]
|
|
1622
|
-
psu_parts << %( horizontalDpi="#{psu[:horizontal_dpi]}") if psu[:horizontal_dpi]
|
|
1623
|
-
psu_parts << %( verticalDpi="#{psu[:vertical_dpi]}") if psu[:vertical_dpi]
|
|
1624
|
-
psu_parts << %( copies="#{psu[:copies]}") if psu[:copies]
|
|
1627
|
+
psu_parts << %( horizontalDpi="#{xml_escape(psu[:horizontal_dpi])}") if psu[:horizontal_dpi]
|
|
1628
|
+
psu_parts << %( verticalDpi="#{xml_escape(psu[:vertical_dpi])}") if psu[:vertical_dpi]
|
|
1629
|
+
psu_parts << %( copies="#{xml_escape(psu[:copies])}") if psu[:copies]
|
|
1625
1630
|
parts << "<c:pageSetup#{psu_parts}/>"
|
|
1626
1631
|
end
|
|
1627
1632
|
parts << "</c:printSettings>"
|
|
@@ -1647,9 +1652,9 @@ module Xlsxrb
|
|
|
1647
1652
|
else
|
|
1648
1653
|
"<r><t>#{xml_escape(c[:text])}</t></r>"
|
|
1649
1654
|
end
|
|
1650
|
-
comment_attrs = %(ref="#{c[:ref]}" authorId="#{aid}")
|
|
1651
|
-
comment_attrs << %( guid="#{c[:guid]}") if c[:guid]
|
|
1652
|
-
comment_attrs << %( shapeId="#{c[:shape_id]}") if c[:shape_id]
|
|
1655
|
+
comment_attrs = %(ref="#{xml_escape(c[:ref])}" authorId="#{xml_escape(aid)}")
|
|
1656
|
+
comment_attrs << %( guid="#{xml_escape(c[:guid])}") if c[:guid]
|
|
1657
|
+
comment_attrs << %( shapeId="#{xml_escape(c[:shape_id])}") if c[:shape_id]
|
|
1653
1658
|
parts << "<comment #{comment_attrs}><text>#{text_xml}</text></comment>"
|
|
1654
1659
|
end
|
|
1655
1660
|
parts << "</commentList></comments>"
|
|
@@ -1668,7 +1673,7 @@ module Xlsxrb
|
|
|
1668
1673
|
sheet_comments.each_with_index do |c, idx|
|
|
1669
1674
|
col, row = cell_to_col_row(c[:ref])
|
|
1670
1675
|
shape_id = 1025 + idx
|
|
1671
|
-
parts << %(<v:shape id="_x0000_s#{shape_id}" type="#_x0000_t202" style="position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:#{idx + 1};visibility:#{c[:visible] ? "visible" : "hidden"}" fillcolor="#ffffe1" o:insetmode="auto">)
|
|
1676
|
+
parts << %(<v:shape id="_x0000_s#{xml_escape(shape_id)}" type="#_x0000_t202" style="position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:#{xml_escape(idx + 1)};visibility:#{c[:visible] ? "visible" : "hidden"}" fillcolor="#ffffe1" o:insetmode="auto">)
|
|
1672
1677
|
parts << '<v:fill color2="#ffffe1"/>'
|
|
1673
1678
|
parts << '<v:shadow on="t" color="black" obscured="t"/>'
|
|
1674
1679
|
parts << '<v:path o:connecttype="none"/>'
|
|
@@ -1730,8 +1735,8 @@ module Xlsxrb
|
|
|
1730
1735
|
person_id = c[:person_id] || c[:author_id] || "{00000000-0000-0000-0000-000000000000}"
|
|
1731
1736
|
comment_id = c[:id] || format_guid(nil)
|
|
1732
1737
|
|
|
1733
|
-
attrs = %(ref="#{ref}" dT="#{dt_str}" personId="#{person_id}" id="#{comment_id}")
|
|
1734
|
-
attrs << %( parentId="#{c[:parent_id]}") if c[:parent_id]
|
|
1738
|
+
attrs = %(ref="#{xml_escape(ref)}" dT="#{xml_escape(dt_str)}" personId="#{xml_escape(person_id)}" id="#{xml_escape(comment_id)}")
|
|
1739
|
+
attrs << %( parentId="#{xml_escape(c[:parent_id])}") if c[:parent_id]
|
|
1735
1740
|
attrs << %( done="true") if [true, "true", "1"].include?(c[:done])
|
|
1736
1741
|
|
|
1737
1742
|
text_val = c[:text].to_s
|
|
@@ -1753,7 +1758,7 @@ module Xlsxrb
|
|
|
1753
1758
|
name = xml_escape(p[:display_name] || p[:name] || "Author")
|
|
1754
1759
|
user_id = xml_escape(p[:user_id] || "AD:#{p[:display_name] || p[:name] || "Author"}")
|
|
1755
1760
|
provider_id = xml_escape(p[:provider_id] || "AD")
|
|
1756
|
-
parts << %(<person displayName="#{name}" id="#{p_id}" userId="#{user_id}" providerId="#{provider_id}"/>)
|
|
1761
|
+
parts << %(<person displayName="#{xml_escape(name)}" id="#{xml_escape(p_id)}" userId="#{xml_escape(user_id)}" providerId="#{xml_escape(provider_id)}"/>)
|
|
1757
1762
|
end
|
|
1758
1763
|
parts << "</personList>"
|
|
1759
1764
|
parts.join
|