write_xlsx 0.72.2 → 0.72.3.beta1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/{README.rdoc → Changes} +3 -94
  3. data/README.md +96 -0
  4. data/lib/write_xlsx/chart.rb +115 -259
  5. data/lib/write_xlsx/chart/axis.rb +4 -4
  6. data/lib/write_xlsx/chart/bar.rb +1 -1
  7. data/lib/write_xlsx/chart/column.rb +1 -1
  8. data/lib/write_xlsx/chart/pie.rb +3 -3
  9. data/lib/write_xlsx/chart/radar.rb +1 -1
  10. data/lib/write_xlsx/chart/scatter.rb +1 -1
  11. data/lib/write_xlsx/chart/series.rb +0 -37
  12. data/lib/write_xlsx/chartsheet.rb +25 -37
  13. data/lib/write_xlsx/col_name.rb +40 -0
  14. data/lib/write_xlsx/drawing.rb +95 -85
  15. data/lib/write_xlsx/format.rb +32 -32
  16. data/lib/write_xlsx/package/app.rb +18 -23
  17. data/lib/write_xlsx/package/button.rb +15 -12
  18. data/lib/write_xlsx/package/comments.rb +33 -30
  19. data/lib/write_xlsx/package/conditional_format.rb +18 -14
  20. data/lib/write_xlsx/package/content_types.rb +22 -17
  21. data/lib/write_xlsx/package/core.rb +19 -24
  22. data/lib/write_xlsx/package/relationships.rb +10 -13
  23. data/lib/write_xlsx/package/shared_strings.rb +8 -16
  24. data/lib/write_xlsx/package/styles.rb +59 -64
  25. data/lib/write_xlsx/package/table.rb +27 -37
  26. data/lib/write_xlsx/package/vml.rb +23 -21
  27. data/lib/write_xlsx/package/xml_writer_simple.rb +3 -6
  28. data/lib/write_xlsx/sheets.rb +4 -4
  29. data/lib/write_xlsx/sparkline.rb +22 -22
  30. data/lib/write_xlsx/utility.rb +61 -33
  31. data/lib/write_xlsx/version.rb +1 -1
  32. data/lib/write_xlsx/workbook.rb +46 -50
  33. data/lib/write_xlsx/worksheet.rb +149 -133
  34. data/lib/write_xlsx/worksheet/cell_data.rb +8 -6
  35. data/lib/write_xlsx/worksheet/data_validation.rb +14 -14
  36. data/lib/write_xlsx/worksheet/hyperlink.rb +97 -65
  37. data/lib/write_xlsx/worksheet/page_setup.rb +23 -22
  38. data/test/chart/test_write_a_latin.rb +3 -3
  39. data/test/regression/test_chart_font01.rb +1 -1
  40. data/test/regression/test_chart_font02.rb +1 -1
  41. data/test/regression/test_chart_font03.rb +1 -1
  42. data/test/regression/test_chart_font04.rb +1 -1
  43. data/test/regression/test_chart_font05.rb +1 -1
  44. data/test/regression/test_chart_font06.rb +1 -1
  45. data/test/test_xml_writer_simple.rb +3 -3
  46. data/test/worksheet/test_write_hyperlink.rb +4 -4
  47. data/test/worksheet/test_write_worksheet_attributes.rb +3 -3
  48. data/write_xlsx.gemspec +2 -1
  49. metadata +9 -8
  50. data/test/package/table/test_write_xml_declaration.rb +0 -20
@@ -74,8 +74,8 @@ def write_number_format(writer) # :nodoc:
74
74
  end
75
75
 
76
76
  attributes = [
77
- 'formatCode', @num_format,
78
- 'sourceLinked', source_linked
77
+ ['formatCode', @num_format],
78
+ ['sourceLinked', source_linked]
79
79
  ]
80
80
 
81
81
  writer.empty_tag('c:numFmt', attributes)
@@ -106,8 +106,8 @@ def write_cat_number_format(writer, cat_has_num_fmt)
106
106
  end
107
107
 
108
108
  attributes = [
109
- 'formatCode', @num_format,
110
- 'sourceLinked', source_linked,
109
+ ['formatCode', @num_format],
110
+ ['sourceLinked', source_linked]
111
111
  ]
112
112
 
113
113
  writer.empty_tag('c:numFmt', attributes)
@@ -70,7 +70,7 @@ def write_chart_type(params)
70
70
  def write_bar_dir
71
71
  val = 'bar'
72
72
 
73
- attributes = ['val', val]
73
+ attributes = [ ['val', val] ]
74
74
 
75
75
  @writer.empty_tag('c:barDir', attributes)
76
76
  end
@@ -55,7 +55,7 @@ def write_chart_type(params)
55
55
  def write_bar_dir
56
56
  val = 'col'
57
57
 
58
- attributes = ['val', val]
58
+ attributes = [ ['val', val] ]
59
59
 
60
60
  @writer.empty_tag('c:barDir', attributes)
61
61
  end
@@ -141,7 +141,7 @@ def write_a_p_legend
141
141
  def write_a_p_pr_legend
142
142
  rtl = 0
143
143
 
144
- attributes = ['rtl', rtl]
144
+ attributes = [ ['rtl', rtl] ]
145
145
 
146
146
  @writer.tag_elements('a:pPr', attributes) do
147
147
  # Write the a:defRPr element.
@@ -155,7 +155,7 @@ def write_a_p_pr_legend
155
155
  def write_vary_colors
156
156
  val = 1
157
157
 
158
- attributes = ['val', val]
158
+ attributes = [ ['val', val] ]
159
159
 
160
160
  @writer.empty_tag('c:varyColors', attributes)
161
161
  end
@@ -166,7 +166,7 @@ def write_vary_colors
166
166
  def write_first_slice_ang
167
167
  val = 0
168
168
 
169
- attributes = ['val', val]
169
+ attributes = [ ['val', val] ]
170
170
 
171
171
  @writer.empty_tag('c:firstSliceAng', attributes)
172
172
  end
@@ -85,7 +85,7 @@ def write_radar_style
85
85
  val = 'filled'
86
86
  end
87
87
 
88
- attributes = ['val', val]
88
+ attributes = [ ['val', val] ]
89
89
 
90
90
  @writer.empty_tag('c:radarStyle', attributes)
91
91
  end
@@ -227,7 +227,7 @@ def write_y_val(series)
227
227
  # Write the <c:scatterStyle> element.
228
228
  #
229
229
  def write_scatter_style(val)
230
- attributes = ['val', val]
230
+ attributes = [ ['val', val] ]
231
231
 
232
232
  @writer.empty_tag('c:scatterStyle', attributes)
233
233
  end
@@ -59,38 +59,6 @@ def aref_to_formula(data) # :nodoc:
59
59
  xl_range_formula(*data)
60
60
  end
61
61
 
62
- #
63
- # Convert user defined line properties to the structure required internally.
64
- #
65
- def line_properties(line) # :nodoc:
66
- return { :_defined => 0 } unless line
67
-
68
- dash_types = {
69
- :solid => 'solid',
70
- :round_dot => 'sysDot',
71
- :square_dot => 'sysDash',
72
- :dash => 'dash',
73
- :dash_dot => 'dashDot',
74
- :long_dash => 'lgDash',
75
- :long_dash_dot => 'lgDashDot',
76
- :long_dash_dot_dot => 'lgDashDotDot',
77
- :dot => 'dot',
78
- :system_dash_dot => 'sysDashDot',
79
- :system_dash_dot_dot => 'sysDashDotDot'
80
- }
81
-
82
- # Check the dash type.
83
- dash_type = line[:dash_type]
84
-
85
- if dash_type
86
- line[:dash_type] = value_or_raise(dash_types, dash_type, 'dash type')
87
- end
88
-
89
- line[:_defined] = 1
90
-
91
- line
92
- end
93
-
94
62
  #
95
63
  # Convert user defined fill properties to the structure required internally.
96
64
  #
@@ -299,9 +267,4 @@ def labels_properties(labels) # :nodoc:
299
267
 
300
268
  labels
301
269
  end
302
-
303
- def value_or_raise(hash, key, msg)
304
- raise "Unknown #{msg} '#{key}'" unless hash[key.to_sym]
305
- hash[key.to_sym]
306
- end
307
270
  end
@@ -32,41 +32,29 @@ def initialize(workbook, index, name)
32
32
  #
33
33
  def assemble_xml_file # :nodoc:
34
34
  return unless @writer
35
- @writer.xml_decl
36
35
 
37
- # Write the root chartsheet element.
38
- write_chartsheet
39
-
40
- # Write the worksheet properties.
41
- write_sheet_pr
42
-
43
- # Write the sheet view properties.
44
- write_sheet_views
45
-
46
- # Write the sheetProtection element.
47
- write_sheet_protection
48
-
49
- # Write the printOptions element.
50
- write_print_options
51
-
52
- # Write the worksheet page_margins.
53
- write_page_margins
54
-
55
- # Write the worksheet page setup.
56
- write_page_setup
57
-
58
- # Write the headerFooter element.
59
- write_header_footer
60
-
61
- # Write the drawing element.
62
- write_drawings
63
-
64
- # Close the worksheet tag.
65
- @writer.end_tag('chartsheet')
66
-
67
- # Close the XML writer object and filehandle.
68
- @writer.crlf
69
- @writer.close
36
+ write_xml_declaration do
37
+ # Write the root chartsheet element.
38
+ write_chartsheet
39
+ # Write the worksheet properties.
40
+ write_sheet_pr
41
+ # Write the sheet view properties.
42
+ write_sheet_views
43
+ # Write the sheetProtection element.
44
+ write_sheet_protection
45
+ # Write the printOptions element.
46
+ write_print_options
47
+ # Write the worksheet page_margins.
48
+ write_page_margins
49
+ # Write the worksheet page setup.
50
+ write_page_setup
51
+ # Write the headerFooter element.
52
+ write_header_footer
53
+ # Write the drawing element.
54
+ write_drawings
55
+ # Close the worksheet tag.
56
+ @writer.end_tag('chartsheet')
57
+ end
70
58
  end
71
59
 
72
60
  def protect(password = '', options = {})
@@ -188,8 +176,8 @@ def write_chartsheet # :nodoc:
188
176
  mc_preserve_attributes = 'mv:*'
189
177
 
190
178
  attributes = [
191
- 'xmlns', xmlns,
192
- 'xmlns:r', xmlns_r
179
+ ['xmlns', xmlns],
180
+ ['xmlns:r', xmlns_r]
193
181
  ]
194
182
 
195
183
  @writer.start_tag('chartsheet', attributes)
@@ -202,7 +190,7 @@ def write_sheet_pr # :nodoc:
202
190
 
203
191
  attributes = []
204
192
 
205
- attributes << {'filterMode' => 1} if ptrue?(@filter_on)
193
+ attributes << ['filterMode', 1] if ptrue?(@filter_on)
206
194
 
207
195
  if ptrue?(@fit_page) || ptrue?(@tab_color)
208
196
  @writer.tag_elements('sheetPr', attributes) do
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'singleton'
3
+
4
+ class ColName
5
+ include Singleton
6
+
7
+ def initialize
8
+ @col_str_table = Hash.new
9
+ end
10
+
11
+ def col_str(col)
12
+ @col_str_table[col] = col_str_build(col) unless @col_str_table[col]
13
+ @col_str_table[col]
14
+ end
15
+
16
+ private
17
+
18
+ def col_str_build(col)
19
+ # Change from 0-indexed to 1 indexed.
20
+ col += 1
21
+ col_str = ''
22
+
23
+ while col > 0
24
+ # Set remainder from 1 .. 26
25
+ remainder = col % 26
26
+ remainder = 26 if remainder == 0
27
+
28
+ # Convert the remainder to a character. C-ishly.
29
+ col_letter = ("A".ord + remainder - 1).chr
30
+
31
+ # Accumulate the column letters, right to left.
32
+ col_str = col_letter + col_str
33
+
34
+ # Get the next order of magnitude.
35
+ col = (col - 1) / 26
36
+ end
37
+
38
+ col_str
39
+ end
40
+ end
@@ -27,30 +27,22 @@ def set_xml_writer(filename)
27
27
  # Assemble and write the XML file.
28
28
  #
29
29
  def assemble_xml_file
30
- @writer.xml_decl
31
-
32
- # Write the xdr:wsDr element.
33
- write_drawing_workspace
34
-
35
- if @embedded
36
- index = 0
37
- @drawings.each do |dimensions|
38
- # Write the xdr:twoCellAnchor element.
39
- index += 1
40
-
41
- write_two_cell_anchor(index, *(dimensions.flatten))
30
+ write_xml_declaration do
31
+ # Write the xdr:wsDr element.
32
+ write_drawing_workspace do
33
+ if @embedded
34
+ index = 0
35
+ @drawings.each do |dimensions|
36
+ # Write the xdr:twoCellAnchor element.
37
+ index += 1
38
+ write_two_cell_anchor(index, *(dimensions.flatten))
39
+ end
40
+ else
41
+ # Write the xdr:absoluteAnchor element.
42
+ write_absolute_anchor(1)
43
+ end
42
44
  end
43
- else
44
- index = 0
45
-
46
- # Write the xdr:absoluteAnchor element.
47
- index += 1
48
- write_absolute_anchor(index)
49
45
  end
50
-
51
- @writer.end_tag('xdr:wsDr')
52
- @writer.crlf
53
- @writer.close
54
46
  end
55
47
 
56
48
  #
@@ -68,11 +60,11 @@ def add_drawing_object(*args)
68
60
  def write_drawing_workspace
69
61
  schema = 'http://schemas.openxmlformats.org/drawingml/'
70
62
  attributes = [
71
- 'xmlns:xdr', "#{schema}2006/spreadsheetDrawing",
72
- 'xmlns:a', "#{schema}2006/main"
63
+ ['xmlns:xdr', "#{schema}2006/spreadsheetDrawing"],
64
+ ['xmlns:a', "#{schema}2006/main"]
73
65
  ]
74
66
 
75
- @writer.start_tag('xdr:wsDr', attributes)
67
+ @writer.tag_elements('xdr:wsDr', attributes) { yield }
76
68
  end
77
69
 
78
70
  #
@@ -86,10 +78,10 @@ def write_two_cell_anchor(*args)
86
78
  attributes = []
87
79
 
88
80
  # Add attribute for images.
89
- attributes << :editAs << 'oneCell' if type == 2
81
+ attributes << [:editAs, 'oneCell'] if type == 2
90
82
 
91
83
  # Add attribute for shapes.
92
- attributes << :editAs << shape.edit_as if shape && !shape.edit_as.nil?
84
+ attributes << [:editAs, shape.edit_as] if shape && !shape.edit_as.nil?
93
85
 
94
86
  @writer.tag_elements('xdr:twoCellAnchor', attributes) do
95
87
  # Write the xdr:from element.
@@ -213,8 +205,8 @@ def write_row_off(data)
213
205
  #
214
206
  def write_pos(x, y)
215
207
  attributes = [
216
- 'x', x,
217
- 'y', y
208
+ ['x', x],
209
+ ['y', y]
218
210
  ]
219
211
 
220
212
  @writer.empty_tag('xdr:pos', attributes)
@@ -225,8 +217,8 @@ def write_pos(x, y)
225
217
  #
226
218
  def write_ext(cx, cy)
227
219
  attributes = [
228
- 'cx', cx,
229
- 'cy', cy
220
+ ['cx', cx],
221
+ ['cy', cy]
230
222
  ]
231
223
 
232
224
  @writer.empty_tag('xdr:ext', attributes)
@@ -238,7 +230,7 @@ def write_ext(cx, cy)
238
230
  def write_graphic_frame(index, name = nil)
239
231
  macro = ''
240
232
 
241
- attributes = ['macro', macro]
233
+ attributes = [ ['macro', macro] ]
242
234
 
243
235
  @writer.tag_elements('xdr:graphicFrame', attributes) do
244
236
  # Write the xdr:nvGraphicFramePr element.
@@ -269,12 +261,12 @@ def write_nv_graphic_frame_pr(index, name = nil)
269
261
  #
270
262
  def write_c_nv_pr(id, name, descr = nil)
271
263
  attributes = [
272
- 'id', id,
273
- 'name', name
264
+ ['id', id],
265
+ ['name', name]
274
266
  ]
275
267
 
276
268
  # Add description attribute for images.
277
- attributes << 'descr' << descr if descr
269
+ attributes << ['descr', descr] if descr
278
270
 
279
271
  @writer.empty_tag('xdr:cNvPr', attributes)
280
272
  end
@@ -300,7 +292,7 @@ def write_c_nv_graphic_frame_pr
300
292
  def write_a_graphic_frame_locks
301
293
  no_grp = 1
302
294
 
303
- attributes = ['noGrp', no_grp ]
295
+ attributes = [ ['noGrp', no_grp ] ]
304
296
 
305
297
  @writer.empty_tag('a:graphicFrameLocks', attributes)
306
298
  end
@@ -325,8 +317,8 @@ def write_xfrm_offset
325
317
  y = 0
326
318
 
327
319
  attributes = [
328
- 'x', x,
329
- 'y', y
320
+ ['x', x],
321
+ ['y', y]
330
322
  ]
331
323
 
332
324
  @writer.empty_tag('a:off', attributes)
@@ -340,8 +332,8 @@ def write_xfrm_extension
340
332
  y = 0
341
333
 
342
334
  attributes = [
343
- 'cx', x,
344
- 'cy', y
335
+ ['cx', x],
336
+ ['cy', y]
345
337
  ]
346
338
 
347
339
  @writer.empty_tag('a:ext', attributes)
@@ -363,7 +355,7 @@ def write_atag_graphic(index)
363
355
  def write_atag_graphic_data(index)
364
356
  uri = 'http://schemas.openxmlformats.org/drawingml/2006/chart'
365
357
 
366
- attributes = ['uri', uri]
358
+ attributes = [ ['uri', uri] ]
367
359
 
368
360
  @writer.tag_elements('a:graphicData', attributes) do
369
361
  # Write the c:chart element.
@@ -380,8 +372,11 @@ def write_c_chart(id)
380
372
  xmlns_r = "#{schema}officeDocument/2006/relationships"
381
373
 
382
374
 
383
- attributes = ['xmlns:c', xmlns_c, 'xmlns:r', xmlns_r]
384
- attributes += r_id_attributes(id)
375
+ attributes = [
376
+ ['xmlns:c', xmlns_c],
377
+ ['xmlns:r', xmlns_r]
378
+ ]
379
+ attributes << r_id_attributes(id)
385
380
 
386
381
  @writer.empty_tag('c:chart', attributes)
387
382
  end
@@ -398,7 +393,7 @@ def write_client_data
398
393
  #
399
394
  def write_sp(index, col_absolute, row_absolute, width, height, shape)
400
395
  if shape.connect != 0
401
- attributes = [:macro, '']
396
+ attributes = [ [:macro, ''] ]
402
397
  @writer.tag_elements('xdr:cxnSp', attributes) do
403
398
 
404
399
  # Write the xdr:nvCxnSpPr element.
@@ -409,7 +404,10 @@ def write_sp(index, col_absolute, row_absolute, width, height, shape)
409
404
  end
410
405
  else
411
406
  # Add attribute for shapes.
412
- attributes = [:macro, '', :textlink, '']
407
+ attributes = [
408
+ [:macro, ''],
409
+ [:textlink, '']
410
+ ]
413
411
  @writer.tag_elements('xdr:sp', attributes) do
414
412
 
415
413
  # Write the xdr:nvSpPr element.
@@ -437,16 +435,22 @@ def write_nv_cxn_sp_pr(index, shape)
437
435
 
438
436
  @writer.tag_elements('xdr:cNvCxnSpPr') do
439
437
 
440
- attributes = [:noChangeShapeType, '1']
438
+ attributes = [ [:noChangeShapeType, '1'] ]
441
439
  @writer.empty_tag('a:cxnSpLocks', attributes)
442
440
 
443
441
  if shape.start
444
- attributes = ['id', shape.start, 'idx', shape.start_index]
442
+ attributes = [
443
+ ['id', shape.start],
444
+ ['idx', shape.start_index]
445
+ ]
445
446
  @writer.empty_tag('a:stCxn', attributes)
446
447
  end
447
448
 
448
449
  if shape.end
449
- attributes = ['id', shape.end, 'idx', shape.end_index]
450
+ attributes = [
451
+ ['id', shape.end],
452
+ ['idx', shape.end_index]
453
+ ]
450
454
  @writer.empty_tag('a:endCxn', attributes)
451
455
  end
452
456
  end
@@ -458,13 +462,13 @@ def write_nv_cxn_sp_pr(index, shape)
458
462
  #
459
463
  def write_nv_sp_pr(index, shape)
460
464
  attributes = []
461
- attributes << 'txBox' << 1 if shape.tx_box
465
+ attributes << ['txBox', 1] if shape.tx_box
462
466
 
463
467
  @writer.tag_elements('xdr:nvSpPr') do
464
468
  write_c_nv_pr(shape.id, "#{shape.type} #{index}")
465
469
 
466
470
  @writer.tag_elements('xdr:cNvSpPr', attributes) do
467
- @writer.empty_tag('a:spLocks', [:noChangeArrowheads, '1'])
471
+ @writer.empty_tag('a:spLocks', [ [:noChangeArrowheads, '1'] ])
468
472
  end
469
473
  end
470
474
  end
@@ -516,7 +520,7 @@ def write_c_nv_pic_pr
516
520
  def write_a_pic_locks
517
521
  no_change_aspect = 1
518
522
 
519
- attributes = ['noChangeAspect', no_change_aspect]
523
+ attributes = [ ['noChangeAspect', no_change_aspect] ]
520
524
 
521
525
  @writer.empty_tag('a:picLocks', attributes)
522
526
  end
@@ -542,8 +546,8 @@ def write_a_blip(index)
542
546
  r_embed = "rId#{index}"
543
547
 
544
548
  attributes = [
545
- 'xmlns:r', xmlns_r,
546
- 'r:embed', r_embed
549
+ ['xmlns:r', xmlns_r],
550
+ ['r:embed', r_embed]
547
551
  ]
548
552
 
549
553
  @writer.empty_tag('a:blip', attributes)
@@ -582,7 +586,7 @@ def write_sp_pr(col_absolute, row_absolute, width, height, shape = {})
582
586
  # Write the <xdr:spPr> element for shapes.
583
587
  #
584
588
  def write_xdr_sp_pr(index, col_absolute, row_absolute, width, height, shape)
585
- attributes = ['bwMode', 'auto']
589
+ attributes = [ ['bwMode', 'auto'] ]
586
590
 
587
591
  @writer.tag_elements('xdr:spPr', attributes) do
588
592
 
@@ -613,9 +617,9 @@ def write_a_xfrm(col_absolute, row_absolute, width, height, shape = nil)
613
617
  rotation = shape ? shape.rotation : 0
614
618
  rotation *= 60000
615
619
 
616
- attributes << 'rot' << rotation if rotation != 0
617
- attributes << 'flipH' << 1 if shape && ptrue?(shape.flip_h)
618
- attributes << 'flipV' << 1 if shape && ptrue?(shape.flip_v)
620
+ attributes << ['rot', rotation] if rotation != 0
621
+ attributes << ['flipH', 1] if shape && ptrue?(shape.flip_h)
622
+ attributes << ['flipV', 1] if shape && ptrue?(shape.flip_v)
619
623
 
620
624
  @writer.tag_elements('a:xfrm', attributes) do
621
625
  # Write the a:off element.
@@ -630,8 +634,8 @@ def write_a_xfrm(col_absolute, row_absolute, width, height, shape = nil)
630
634
  #
631
635
  def write_a_off(x, y)
632
636
  attributes = [
633
- 'x', x,
634
- 'y', y
637
+ ['x', x],
638
+ ['y', y]
635
639
  ]
636
640
 
637
641
  @writer.empty_tag('a:off', attributes)
@@ -643,8 +647,8 @@ def write_a_off(x, y)
643
647
  #
644
648
  def write_a_ext(cx, cy)
645
649
  attributes = [
646
- 'cx', cx,
647
- 'cy', cy
650
+ ['cx', cx],
651
+ ['cy', cy]
648
652
  ]
649
653
 
650
654
  @writer.empty_tag('a:ext', attributes)
@@ -655,7 +659,7 @@ def write_a_ext(cx, cy)
655
659
  #
656
660
  def write_a_prst_geom(shape = {})
657
661
  attributes = []
658
- attributes << 'prst' << shape.type if shape.type
662
+ attributes << ['prst', shape.type] if shape.type
659
663
 
660
664
  @writer.tag_elements('a:prstGeom', attributes) do
661
665
  # Write the a:avLst element.
@@ -686,7 +690,10 @@ def write_a_av_lst(shape = {})
686
690
  # Scale Adjustments: 100,000 = 100%.
687
691
  adj_int = (adj * 1000).to_i
688
692
 
689
- attributes = [:name, "adj#{suffix}", :fmla, "val #{adj_int}"]
693
+ attributes = [
694
+ [:name, "adj#{suffix}"],
695
+ [:fmla, "val #{adj_int}"]
696
+ ]
690
697
  @writer.empty_tag('a:gd', attributes)
691
698
  end
692
699
  end
@@ -699,7 +706,7 @@ def write_a_av_lst(shape = {})
699
706
  # Write the <a:solidFill> element.
700
707
  #
701
708
  def write_a_solid_fill(rgb = '000000')
702
- attributes = ['val', rgb]
709
+ attributes = [ ['val', rgb] ]
703
710
 
704
711
  @writer.tag_elements('a:solidFill') do
705
712
  @writer.empty_tag('a:srgbClr', attributes)
@@ -711,7 +718,7 @@ def write_a_solid_fill(rgb = '000000')
711
718
  #
712
719
  def write_a_ln(shape = {})
713
720
  weight = shape.line_weight || 0
714
- attributes = ['w', weight * 9525]
721
+ attributes = [ ['w', weight * 9525] ]
715
722
  @writer.tag_elements('a:ln', attributes) do
716
723
  line = shape.line || 0
717
724
  if line.to_s.bytesize > 1
@@ -722,14 +729,14 @@ def write_a_ln(shape = {})
722
729
  end
723
730
 
724
731
  if shape.line_type != ''
725
- attributes = ['val', shape.line_type]
732
+ attributes = [ ['val', shape.line_type] ]
726
733
  @writer.empty_tag('a:prstDash', attributes)
727
734
  end
728
735
 
729
736
  if shape.connect != 0
730
737
  @writer.empty_tag('a:round')
731
738
  else
732
- attributes = ['lim', 800000]
739
+ attributes = [ ['lim', 800000] ]
733
740
  @writer.empty_tag('a:miter', attributes)
734
741
  end
735
742
 
@@ -743,14 +750,14 @@ def write_a_ln(shape = {})
743
750
  #
744
751
  def write_txBody(col_absolute, row_absolute, width, height, shape)
745
752
  attributes = [
746
- :vertOverflow, "clip",
747
- :wrap, "square",
748
- :lIns, "27432",
749
- :tIns, "22860",
750
- :rIns, "27432",
751
- :bIns, "22860",
752
- :anchor, shape.valign,
753
- :upright, "1"
753
+ [:vertOverflow, "clip"],
754
+ [:wrap, "square"],
755
+ [:lIns, "27432"],
756
+ [:tIns, "22860"],
757
+ [:rIns, "27432"],
758
+ [:bIns, "22860"],
759
+ [:anchor, shape.valign],
760
+ [:upright, "1"]
754
761
  ]
755
762
  @writer.tag_elements('xdr:txBody') do
756
763
  @writer.empty_tag('a:bodyPr', attributes)
@@ -760,9 +767,12 @@ def write_txBody(col_absolute, row_absolute, width, height, shape)
760
767
  rotation = shape.format[:rotation] || 0
761
768
  rotation *= 60000
762
769
 
763
- attributes = [:algn, shape.align, :rtl, rotation]
770
+ attributes = [
771
+ [:algn, shape.align],
772
+ [:rtl, rotation]
773
+ ]
764
774
  @writer.tag_elements('a:pPr', attributes) do
765
- attributes = [:sz, "1000"]
775
+ attributes = [ [:sz, "1000"] ]
766
776
  @writer.empty_tag('a:defRPr', attributes)
767
777
  end
768
778
 
@@ -776,13 +786,13 @@ def write_txBody(col_absolute, row_absolute, width, height, shape)
776
786
  strike = ptrue?(shape.format[:font_strikeout]) ? 'Strike' : 'noStrike'
777
787
 
778
788
  attributes = [
779
- :lang, "en-US",
780
- :sz, size,
781
- :b, bold,
782
- :i, italic,
783
- :u, underline,
784
- :strike, strike,
785
- :baseline, 0
789
+ [:lang, "en-US"],
790
+ [:sz, size],
791
+ [:b, bold],
792
+ [:i, italic],
793
+ [:u, underline],
794
+ [:strike, strike],
795
+ [:baseline, 0]
786
796
  ]
787
797
  @writer.tag_elements('a:rPr', attributes) do
788
798
  color = shape.format[:color]
@@ -796,7 +806,7 @@ def write_txBody(col_absolute, row_absolute, width, height, shape)
796
806
  write_a_solid_fill(color)
797
807
 
798
808
  font = shape.format[:font] || 'Calibri'
799
- attributes = [:typeface, font]
809
+ attributes = [ [:typeface, font] ]
800
810
  @writer.empty_tag('a:latin', attributes)
801
811
  @writer.empty_tag('a:cs', attributes)
802
812
  end