xlsxwriter 0.2.1.pre.2 → 0.2.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -3
  3. data/ext/xlsxwriter/chart.c +84 -20
  4. data/ext/xlsxwriter/chart.h +1 -0
  5. data/ext/xlsxwriter/chartsheet.c +34 -13
  6. data/ext/xlsxwriter/common.h +5 -5
  7. data/ext/xlsxwriter/extconf.rb +8 -8
  8. data/ext/xlsxwriter/libxlsxwriter/License.txt +24 -2
  9. data/ext/xlsxwriter/libxlsxwriter/Makefile +46 -12
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +1 -1
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +196 -30
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chartsheet.h +3 -3
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +24 -5
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +5 -1
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +6 -17
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +20 -6
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +3 -1
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +11 -5
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/md5.h +43 -0
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +42 -3
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +83 -18
  30. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +1519 -109
  31. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
  32. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +3 -2
  33. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +25 -7
  34. data/ext/xlsxwriter/libxlsxwriter/src/app.c +1 -1
  35. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +332 -48
  36. data/ext/xlsxwriter/libxlsxwriter/src/chartsheet.c +20 -19
  37. data/ext/xlsxwriter/libxlsxwriter/src/comment.c +443 -0
  38. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +20 -1
  39. data/ext/xlsxwriter/libxlsxwriter/src/core.c +2 -2
  40. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +1 -1
  41. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +58 -20
  42. data/ext/xlsxwriter/libxlsxwriter/src/format.c +98 -25
  43. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +1 -1
  44. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +269 -12
  45. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +1 -1
  46. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +2 -4
  47. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +334 -48
  48. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +1 -1
  49. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +71 -8
  50. data/ext/xlsxwriter/libxlsxwriter/src/vml.c +1032 -0
  51. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +343 -27
  52. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +3759 -478
  53. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +81 -2
  54. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/Makefile +42 -0
  55. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.c +291 -0
  56. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.h +43 -0
  57. data/ext/xlsxwriter/rich_string.c +28 -9
  58. data/ext/xlsxwriter/shared_strings.c +75 -0
  59. data/ext/xlsxwriter/shared_strings.h +15 -0
  60. data/ext/xlsxwriter/workbook.c +87 -13
  61. data/ext/xlsxwriter/workbook.h +1 -0
  62. data/ext/xlsxwriter/workbook_properties.c +2 -2
  63. data/ext/xlsxwriter/worksheet.c +75 -23
  64. data/ext/xlsxwriter/worksheet.h +1 -0
  65. data/ext/xlsxwriter/xlsxwriter.c +2 -0
  66. data/lib/xlsxwriter/rich_string.rb +0 -2
  67. data/lib/xlsxwriter/version.rb +1 -1
  68. data/lib/xlsxwriter/worksheet.rb +2 -2
  69. data/test/{run-test.rb → run_test.rb} +3 -3
  70. data/test/support/chart_test.rb +3 -3
  71. data/test/support/with_xlsx_file.rb +4 -2
  72. data/test/support/xlsx_comparable.rb +40 -26
  73. data/test/test_array_formula.rb +42 -0
  74. data/test/test_autofilter.rb +72 -0
  75. data/test/{test-chart-area.rb → test_chart_area.rb} +2 -2
  76. data/test/{test-chart-axis.rb → test_chart_axis.rb} +16 -16
  77. data/test/test_chart_bar.rb +382 -0
  78. data/test/test_chart_blank.rb +27 -0
  79. data/test/{test-chart-column.rb → test_chart_column.rb} +2 -2
  80. data/test/{test-chart-doughnut.rb → test_chart_doughnut.rb} +2 -2
  81. data/test/{test-chart-legend.rb → test_chart_legend.rb} +2 -2
  82. data/test/{test-chart-pie.rb → test_chart_pie.rb} +2 -2
  83. data/test/{test-chart-scatter.rb → test_chart_scatter.rb} +3 -4
  84. data/test/{test-chart-size.rb → test_chart_size.rb} +2 -2
  85. data/test/{test-chart-title.rb → test_chart_title.rb} +3 -3
  86. data/test/{test-chartsheet.rb → test_chartsheet.rb} +2 -2
  87. data/test/{test-data.rb → test_data.rb} +1 -1
  88. data/test/{test-data-validation.rb → test_data_validation.rb} +23 -24
  89. data/test/{test-default-row.rb → test_default_row.rb} +1 -1
  90. data/test/{test-defined-name.rb → test_defined_name.rb} +12 -12
  91. data/test/{test-escapes.rb → test_escapes.rb} +5 -2
  92. data/test/{test-fit-to-pages.rb → test_fit_to_pages.rb} +6 -6
  93. data/test/{test-formatting.rb → test_formatting.rb} +10 -10
  94. data/test/{test-gridlines.rb → test_gridlines.rb} +3 -3
  95. data/test/{test-hyperlink.rb → test_hyperlink.rb} +22 -11
  96. data/test/{test-image.rb → test_image.rb} +6 -4
  97. data/test/{test-macro.rb → test_macro.rb} +1 -1
  98. data/test/{test-merge-range.rb → test_merge_range.rb} +1 -1
  99. data/test/{test-misc.rb → test_misc.rb} +2 -2
  100. data/test/{test-optimize.rb → test_optimize.rb} +2 -4
  101. data/test/{test-outline.rb → test_outline.rb} +14 -14
  102. data/test/{test-page-breaks.rb → test_page_breaks.rb} +2 -2
  103. data/test/{test-page-setup.rb → test_page_setup.rb} +2 -2
  104. data/test/{test-panes.rb → test_panes.rb} +1 -1
  105. data/test/{test-print-area.rb → test_print_area.rb} +3 -3
  106. data/test/{test-print-options.rb → test_print_options.rb} +7 -7
  107. data/test/{test-print-scale.rb → test_print_scale.rb} +2 -2
  108. data/test/{test-properties.rb → test_properties.rb} +2 -2
  109. data/test/{test-protect.rb → test_protect.rb} +3 -3
  110. data/test/{test-repeat.rb → test_repeat.rb} +3 -3
  111. data/test/{test-rich-string.rb → test_rich_string.rb} +5 -9
  112. data/test/{test-row-col-format.rb → test_row_col_format.rb} +1 -1
  113. data/test/{test-ruby-worksheet.rb → test_ruby_worksheet.rb} +2 -2
  114. data/test/{test-set-selection.rb → test_set_selection.rb} +2 -2
  115. data/test/{test-set-start-page.rb → test_set_start_page.rb} +2 -2
  116. data/test/{test-simple.rb → test_simple.rb} +10 -10
  117. data/test/{test-types.rb → test_types.rb} +1 -1
  118. data/test/{xlsx-func-testcase.rb → xlsx_func_testcase.rb} +1 -0
  119. metadata +127 -106
  120. data/test/test-array-formula.rb +0 -35
  121. data/test/test-autofilter.rb +0 -72
  122. data/test/test-chart-bar.rb +0 -74
  123. /data/test/{test-errors.rb → test_errors.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 785d6f62717613d9737bd4879dedc8077ac690de96bf3f4fafd7b2c7917956c9
4
- data.tar.gz: 73d5337504d25eb891c34eeaa37fcebfa5961dd9e5d49276d27243198287af8a
3
+ metadata.gz: 5bf5fbd1b3f4d6e80dc28c189f63478ff9a7d6253e6630abf697ebfd5c9b7cb5
4
+ data.tar.gz: a75bd6805709c6688497e5df0bcc9a4b3a53b94361e7cc09d9d67843f2cd0501
5
5
  SHA512:
6
- metadata.gz: c0b99c9b0b3bf2ce4499f33acceda7596910beede83721018a38c04ae4b754b56b793b861bb5af59dc0bcdbeb55f473eaa7b9b16c34cef021575c14ec001c382
7
- data.tar.gz: 00e8d80d92f11aec6366f3ead33d64251787d54cffb77bfd0769299079d904595ed22d5eaaa8dcc40d4a098eedfeecdf4d553a0a0a30f1a8710c4be8f33577e0
6
+ metadata.gz: d5be08fe10209e21d0956b58366fb06a0480f8f0145e3607cffeb78ecc12b0eec375a450165384278a0a0770a4d409c1e4bd9f3bb9852297c421cae481d10591
7
+ data.tar.gz: 83d7ed483b2f2245b5fc4f22afeca555f8216eb1f084504df8075855c50a49a96b24878638b6a63a8e8eb84c1dcdca46c4c3c92bba37c9de85a6ea73a0b887fe
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rake/extensiontask'
3
4
 
4
5
  task default: :test
@@ -12,9 +13,9 @@ Rake::Task['compile'].prerequisites.unshift :patch_dep
12
13
  Gem::PackageTask.new(spec) do |pkg|
13
14
  end
14
15
 
15
- DEP_DIR='ext/xlsxwriter/libxlsxwriter'
16
+ DEP_DIR = 'ext/xlsxwriter/libxlsxwriter'
16
17
 
17
- desc "Checkout xlsxwriter C library"
18
+ desc 'Checkout xlsxwriter C library'
18
19
  task :patch_dep do
19
20
  patches = Dir["#{pwd}/dep_patches/*.patch"]
20
21
  chdir(DEP_DIR) do
@@ -30,5 +31,5 @@ end
30
31
 
31
32
  desc 'Run specs'
32
33
  task test: :compile do
33
- ruby('test/run-test.rb')
34
+ ruby 'test/run_test.rb'
34
35
  end
@@ -10,9 +10,57 @@ VALUE cChart;
10
10
  VALUE cChartSeries;
11
11
  VALUE cChartAxis;
12
12
 
13
+ size_t
14
+ chart_size(const void *data) {
15
+ return sizeof(struct chart);
16
+ }
17
+
18
+ const rb_data_type_t chart_type = {
19
+ .wrap_struct_name = "chart",
20
+ .function = {
21
+ .dmark = NULL,
22
+ .dfree = ruby_xfree,
23
+ .dsize = chart_size,
24
+ },
25
+ .data = NULL,
26
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
27
+ };
28
+
29
+ size_t
30
+ chart_axis_size(const void *data) {
31
+ return sizeof(struct chart_axis);
32
+ }
33
+
34
+ const rb_data_type_t chart_axis_type = {
35
+ .wrap_struct_name = "chart_axis",
36
+ .function = {
37
+ .dmark = NULL,
38
+ .dfree = ruby_xfree,
39
+ .dsize = chart_axis_size,
40
+ },
41
+ .data = NULL,
42
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
43
+ };
44
+
45
+ size_t
46
+ chart_series_size(const void *data) {
47
+ return sizeof(struct chart_series);
48
+ }
49
+
50
+ const rb_data_type_t chart_series_type = {
51
+ .wrap_struct_name = "chart_series",
52
+ .function = {
53
+ .dmark = NULL,
54
+ .dfree = ruby_xfree,
55
+ .dsize = chart_series_size,
56
+ },
57
+ .data = NULL,
58
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
59
+ };
60
+
13
61
  #define DEF_PROP_SETTER(type, field, value) VALUE type ## _set_ ## field ## _ (VALUE self, VALUE val) { \
14
62
  struct type *ptr; \
15
- Data_Get_Struct(self, struct type, ptr); \
63
+ TypedData_Get_Struct(self, struct type, &(type ## _type), ptr); \
16
64
  type ## _set_ ## field (ptr->type, value); \
17
65
  return val; \
18
66
  }
@@ -20,10 +68,8 @@ VALUE cChartAxis;
20
68
 
21
69
  VALUE
22
70
  chart_alloc(VALUE klass) {
23
- VALUE obj;
24
71
  struct chart *ptr;
25
-
26
- obj = Data_Make_Struct(klass, struct chart, NULL, NULL, ptr);
72
+ VALUE obj = TypedData_Make_Struct(klass, struct chart, &chart_type, ptr);
27
73
 
28
74
  ptr->chart = NULL;
29
75
 
@@ -36,8 +82,8 @@ chart_init(VALUE self, VALUE workbook, VALUE type) {
36
82
  struct chart *ptr;
37
83
  struct workbook *wb_ptr;
38
84
 
39
- Data_Get_Struct(workbook, struct workbook, wb_ptr);
40
- Data_Get_Struct(self, struct chart, ptr);
85
+ TypedData_Get_Struct(workbook, struct workbook, &workbook_type, wb_ptr);
86
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
41
87
  if (wb_ptr && wb_ptr->workbook) {
42
88
  ptr->chart = workbook_add_chart(wb_ptr->workbook, NUM2INT(type));
43
89
  }
@@ -52,7 +98,7 @@ chart_axis_alloc(VALUE klass) {
52
98
  VALUE obj;
53
99
  struct chart_axis *ptr;
54
100
 
55
- obj = Data_Make_Struct(klass, struct chart_axis, NULL, NULL, ptr);
101
+ obj = TypedData_Make_Struct(klass, struct chart_axis, &chart_axis_type, ptr);
56
102
 
57
103
  return obj;
58
104
  }
@@ -63,8 +109,8 @@ chart_axis_init(VALUE self, VALUE chart, VALUE type) {
63
109
  struct chart_axis *ptr;
64
110
  struct chart *c_ptr;
65
111
 
66
- Data_Get_Struct(chart, struct chart, c_ptr);
67
- Data_Get_Struct(self, struct chart_axis, ptr);
112
+ TypedData_Get_Struct(chart, struct chart, &chart_type, c_ptr);
113
+ TypedData_Get_Struct(self, struct chart_axis, &chart_axis_type, ptr);
68
114
  rb_iv_set(self, "@chart", chart);
69
115
  if (c_ptr && c_ptr->chart) {
70
116
  ID axis = rb_check_id_cstr("x", 1, NULL);
@@ -92,7 +138,7 @@ chart_series_alloc(VALUE klass) {
92
138
  VALUE obj;
93
139
  struct chart_series *ptr;
94
140
 
95
- obj = Data_Make_Struct(klass, struct chart_series, NULL, NULL, ptr);
141
+ obj = TypedData_Make_Struct(klass, struct chart_series, &chart_series_type, ptr);
96
142
 
97
143
  ptr->chart_series = NULL;
98
144
 
@@ -107,8 +153,8 @@ chart_series_init(int argc, VALUE *argv, VALUE self) {
107
153
  char *cats = NULL, *vals = NULL;
108
154
  rb_check_arity(argc, 1, 3);
109
155
 
110
- Data_Get_Struct(argv[0], struct chart, c_ptr);
111
- Data_Get_Struct(self, struct chart_series, ptr);
156
+ TypedData_Get_Struct(argv[0], struct chart, &chart_type, c_ptr);
157
+ TypedData_Get_Struct(self, struct chart_series, &chart_series_type, ptr);
112
158
 
113
159
  if (argc > 2) {
114
160
  cats = StringValueCStr(argv[1]);
@@ -160,7 +206,7 @@ chart_y_axis_(VALUE self) {
160
206
  VALUE
161
207
  chart_title_set_name_(VALUE self, VALUE name) {
162
208
  struct chart *ptr;
163
- Data_Get_Struct(self, struct chart, ptr);
209
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
164
210
 
165
211
  if (RTEST(name)) {
166
212
  chart_title_set_name(ptr->chart, StringValueCStr(name));
@@ -253,12 +299,23 @@ DEF_PROP_SETTER(chart, rotation, NUM2UINT(rb_check_to_int(val)))
253
299
  */
254
300
  DEF_PROP_SETTER(chart, hole_size, NUM2UINT(rb_check_to_int(val)))
255
301
 
302
+ /* Document-method: XlsxWriter::Workbook::Chart#show_blanks_as=
303
+ *
304
+ */
305
+ VALUE
306
+ chart_set_show_blank_as_(VALUE self, VALUE val) {
307
+ struct chart *ptr;
308
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
309
+ ptr->chart->show_blanks_as = NUM2INT(rb_check_to_int(val));
310
+ return val;
311
+ }
312
+
256
313
 
257
314
  /* :nodoc: */
258
315
  VALUE
259
316
  chart_get_axis_id_1_(VALUE self) {
260
317
  struct chart *ptr;
261
- Data_Get_Struct(self, struct chart, ptr);
318
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
262
319
  return UINT2NUM(ptr->chart->axis_id_1);
263
320
  }
264
321
 
@@ -266,8 +323,8 @@ chart_get_axis_id_1_(VALUE self) {
266
323
  VALUE
267
324
  chart_set_axis_id_1_(VALUE self, VALUE val) {
268
325
  struct chart *ptr;
269
- Data_Get_Struct(self, struct chart, ptr);
270
- ptr->chart->axis_id_1 = NUM2UINT(val);
326
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
327
+ ptr->chart->axis_id_1 = NUM2UINT(rb_check_to_int(val));
271
328
  return val;
272
329
  }
273
330
 
@@ -275,7 +332,7 @@ chart_set_axis_id_1_(VALUE self, VALUE val) {
275
332
  VALUE
276
333
  chart_get_axis_id_2_(VALUE self) {
277
334
  struct chart *ptr;
278
- Data_Get_Struct(self, struct chart, ptr);
335
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
279
336
  return UINT2NUM(ptr->chart->axis_id_2);
280
337
  }
281
338
 
@@ -283,8 +340,8 @@ chart_get_axis_id_2_(VALUE self) {
283
340
  VALUE
284
341
  chart_set_axis_id_2_(VALUE self, VALUE val) {
285
342
  struct chart *ptr;
286
- Data_Get_Struct(self, struct chart, ptr);
287
- ptr->chart->axis_id_2 = NUM2UINT(val);
343
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
344
+ ptr->chart->axis_id_2 = NUM2UINT(rb_check_to_int(val));
288
345
  return val;
289
346
  }
290
347
 
@@ -445,7 +502,7 @@ VALUE
445
502
  chart_axis_set_source_linked_(VALUE self, VALUE val) {
446
503
  struct chart_axis *ptr;
447
504
 
448
- Data_Get_Struct(self, struct chart_axis, ptr);
505
+ TypedData_Get_Struct(self, struct chart_axis, &chart_axis_type, ptr);
449
506
 
450
507
  ptr->chart_axis->source_linked = NUM2UINT(rb_check_to_int(val));
451
508
 
@@ -611,17 +668,20 @@ void init_xlsxwriter_chart() {
611
668
 
612
669
 
613
670
  rb_define_alloc_func(cChart, chart_alloc);
671
+ rb_define_attr(cChart, "workbook", 1, 0);
614
672
  rb_define_method(cChart, "initialize", chart_init, 2);
615
673
  rb_define_method(cChart, "add_series", chart_add_series_, -1);
616
674
  rb_define_method(cChart, "x_axis", chart_x_axis_, 0);
617
675
  rb_define_method(cChart, "y_axis", chart_y_axis_, 0);
618
676
  rb_define_method(cChart, "title=", chart_title_set_name_, 1);
677
+ rb_define_method(cChart, "set_name_range", chart_title_set_name_range_, -1);
619
678
  rb_define_method(cChart, "legend_position=", chart_legend_set_position_, 1);
620
679
  rb_define_method(cChart, "legend_set_font", chart_legend_set_font_, 1);
621
680
  rb_define_method(cChart, "legend_delete_series", chart_legend_delete_series_, 1);
622
681
  rb_define_method(cChart, "style=", chart_set_style_, 1);
623
682
  rb_define_method(cChart, "rotation=", chart_set_rotation_, 1);
624
683
  rb_define_method(cChart, "hole_size=", chart_set_hole_size_, 1);
684
+ rb_define_method(cChart, "show_blank_as=", chart_set_show_blank_as_, 1);
625
685
 
626
686
  rb_define_method(cChart, "axis_id_1", chart_get_axis_id_1_, 0);
627
687
  rb_define_method(cChart, "axis_id_1=", chart_set_axis_id_1_, 1);
@@ -700,6 +760,10 @@ void init_xlsxwriter_chart() {
700
760
  MAP_CHART_CONST(AXIS_LABEL_ALIGN_CENTER);
701
761
  MAP_CHART_CONST(AXIS_LABEL_ALIGN_LEFT);
702
762
  MAP_CHART_CONST(AXIS_LABEL_ALIGN_RIGHT);
763
+
764
+ MAP_CHART_CONST(BLANKS_AS_GAP);
765
+ MAP_CHART_CONST(BLANKS_AS_ZERO);
766
+ MAP_CHART_CONST(BLANKS_AS_CONNECTED);
703
767
  #undef MAP_CHART_CONST
704
768
 
705
769
  #define MAP_CHART_AXIS_CONST(name) rb_define_const(cChartAxis, #name, INT2NUM(LXW_CHART_AXIS_##name))
@@ -25,5 +25,6 @@ void init_xlsxwriter_chart();
25
25
  extern VALUE cChart;
26
26
  extern VALUE cChartSeries;
27
27
  extern VALUE cChartAxis;
28
+ extern const rb_data_type_t chart_type;
28
29
 
29
30
  #endif // __CHART__
@@ -6,15 +6,31 @@
6
6
 
7
7
  VALUE cChartsheet;
8
8
 
9
+ void chartsheet_clear(void *p);
9
10
  void chartsheet_free(void *p);
10
11
 
12
+ size_t
13
+ chartsheet_size(const void *data) {
14
+ return sizeof(struct chartsheet);
15
+ }
16
+
17
+ const rb_data_type_t chartsheet_type = {
18
+ .wrap_struct_name = "chartsheet",
19
+ .function = {
20
+ .dmark = NULL,
21
+ .dfree = chartsheet_free,
22
+ .dsize = chartsheet_size,
23
+ },
24
+ .data = NULL,
25
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
26
+ };
11
27
 
12
28
  VALUE
13
29
  chartsheet_alloc(VALUE klass) {
14
30
  VALUE obj;
15
31
  struct chartsheet *ptr;
16
32
 
17
- obj = Data_Make_Struct(klass, struct chartsheet, NULL, chartsheet_free, ptr);
33
+ obj = TypedData_Make_Struct(klass, struct chartsheet, &chartsheet_type, ptr);
18
34
 
19
35
  ptr->chartsheet = NULL;
20
36
 
@@ -28,7 +44,7 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
28
44
  struct workbook *wb_ptr;
29
45
  struct chartsheet *ptr;
30
46
 
31
- Data_Get_Struct(self, struct chartsheet, ptr);
47
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
32
48
 
33
49
  if (argc == 2) {
34
50
  name = StringValueCStr(argv[1]);
@@ -36,7 +52,7 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
36
52
 
37
53
  rb_iv_set(self, "@workbook", argv[0]);
38
54
 
39
- Data_Get_Struct(argv[0], struct workbook, wb_ptr);
55
+ TypedData_Get_Struct(argv[0], struct workbook, &workbook_type, wb_ptr);
40
56
  ptr->chartsheet = workbook_add_chartsheet(wb_ptr->workbook, name);
41
57
  if (!ptr->chartsheet)
42
58
  rb_raise(eXlsxWriterError, "chartsheet was not created");
@@ -47,20 +63,25 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
47
63
  VALUE
48
64
  chartsheet_release(VALUE self) {
49
65
  struct chartsheet *ptr;
50
- Data_Get_Struct(self, struct chartsheet, ptr);
66
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
51
67
 
52
- chartsheet_free(ptr);
68
+ chartsheet_clear(ptr);
53
69
  return self;
54
70
  }
55
71
 
56
72
  void
57
- chartsheet_free(void *p) {
73
+ chartsheet_clear(void *p) {
58
74
  struct chartsheet *ptr = p;
59
75
 
60
76
  if (ptr->chartsheet)
61
77
  ptr->chartsheet = NULL;
62
78
  }
63
79
 
80
+ void
81
+ chartsheet_free(void *p) {
82
+ chartsheet_clear(p);
83
+ ruby_xfree(p);
84
+ }
64
85
 
65
86
  /* call-seq: cs.activate -> self
66
87
  *
@@ -79,7 +100,7 @@ chartsheet_activate_(VALUE self) {
79
100
  VALUE
80
101
  chartsheet_set_chart_(VALUE self, VALUE chart) {
81
102
  struct chart *chart_ptr;
82
- Data_Get_Struct(chart, struct chart, chart_ptr);
103
+ TypedData_Get_Struct(chart, struct chart, &chart_type, chart_ptr);
83
104
 
84
105
  LXW_ERR_RESULT_CALL(chartsheet, set_chart, chart_ptr->chart);
85
106
  return self;
@@ -139,7 +160,7 @@ chartsheet_set_footer_(int argc, VALUE *argv, VALUE self) {
139
160
  rb_check_arity(argc, 1, 2);
140
161
  struct _header_options ho = _extract_header_options(argc, argv);
141
162
  struct chartsheet *ptr;
142
- Data_Get_Struct(self, struct chartsheet, ptr);
163
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
143
164
  lxw_error err;
144
165
  if (!ho.with_options) {
145
166
  err = chartsheet_set_footer(ptr->chartsheet, ho.str);
@@ -169,7 +190,7 @@ chartsheet_set_header_(int argc, VALUE *argv, VALUE self) {
169
190
  rb_check_arity(argc, 1, 2);
170
191
  struct _header_options ho = _extract_header_options(argc, argv);
171
192
  struct chartsheet *ptr;
172
- Data_Get_Struct(self, struct chartsheet, ptr);
193
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
173
194
  lxw_error err;
174
195
  if (!ho.with_options) {
175
196
  err = chartsheet_set_header(ptr->chartsheet, ho.str);
@@ -236,7 +257,7 @@ chartsheet_set_zoom_(VALUE self, VALUE val) {
236
257
  VALUE
237
258
  chartsheet_get_horizontal_dpi_(VALUE self) {
238
259
  struct chartsheet *ptr;
239
- Data_Get_Struct(self, struct chartsheet, ptr);
260
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
240
261
  return INT2NUM(ptr->chartsheet->worksheet->horizontal_dpi);
241
262
  }
242
263
 
@@ -247,7 +268,7 @@ chartsheet_get_horizontal_dpi_(VALUE self) {
247
268
  VALUE
248
269
  chartsheet_set_horizontal_dpi_(VALUE self, VALUE val) {
249
270
  struct chartsheet *ptr;
250
- Data_Get_Struct(self, struct chartsheet, ptr);
271
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
251
272
  ptr->chartsheet->worksheet->horizontal_dpi = NUM2INT(val);
252
273
  return val;
253
274
  }
@@ -259,7 +280,7 @@ chartsheet_set_horizontal_dpi_(VALUE self, VALUE val) {
259
280
  VALUE
260
281
  chartsheet_get_vertical_dpi_(VALUE self) {
261
282
  struct chartsheet *ptr;
262
- Data_Get_Struct(self, struct chartsheet, ptr);
283
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
263
284
  return INT2NUM(ptr->chartsheet->worksheet->vertical_dpi);
264
285
  }
265
286
 
@@ -270,7 +291,7 @@ chartsheet_get_vertical_dpi_(VALUE self) {
270
291
  VALUE
271
292
  chartsheet_set_vertical_dpi_(VALUE self, VALUE val) {
272
293
  struct chartsheet *ptr;
273
- Data_Get_Struct(self, struct chartsheet, ptr);
294
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
274
295
  ptr->chartsheet->worksheet->vertical_dpi = NUM2INT(val);
275
296
  return val;
276
297
  }
@@ -1,18 +1,18 @@
1
1
  #include <ruby.h>
2
2
  #include <ruby/intern.h>
3
- #include <xlsxwriter_ext.h>
3
+ #include "xlsxwriter_ext.h"
4
4
 
5
5
  #ifndef __COMMON__
6
6
  #define __COMMON__
7
7
 
8
8
  #define LXW_NO_RESULT_CALL(cls, method, ...) { \
9
9
  struct cls *ptr; \
10
- Data_Get_Struct(self, struct cls, ptr); \
10
+ TypedData_Get_Struct(self, struct cls, &(cls ## _type), ptr); \
11
11
  cls ## _ ## method(ptr->cls, ##__VA_ARGS__); }
12
12
 
13
13
  #define LXW_ERR_RESULT_CALL(cls, method, ...) { \
14
14
  struct cls *ptr; \
15
- Data_Get_Struct(self, struct cls, ptr); \
15
+ TypedData_Get_Struct(self, struct cls, &(cls ## _type), ptr); \
16
16
  lxw_error err = cls ## _ ## method(ptr->cls, ##__VA_ARGS__); \
17
17
  handle_lxw_error(err); }
18
18
 
@@ -38,7 +38,7 @@ _extract_protect_options(int argc, VALUE *argv) {
38
38
  opts = argv[0];
39
39
  break;
40
40
  default:
41
- rb_raise(rb_eArgError, "Wrong argument %"PRIsVALUE", expected a String or Hash", rb_obj_class(argv[0]));
41
+ rb_raise(rb_eArgError, "Wrong argument %" PRIsVALUE ", expected a String or Hash", rb_obj_class(argv[0]));
42
42
  }
43
43
  }
44
44
 
@@ -46,7 +46,7 @@ _extract_protect_options(int argc, VALUE *argv) {
46
46
  if (TYPE(argv[1]) == T_HASH) {
47
47
  opts = argv[1];
48
48
  } else {
49
- rb_raise(rb_eArgError, "Expected a Hash, but got %"PRIsVALUE, rb_obj_class(argv[1]));
49
+ rb_raise(rb_eArgError, "Expected a Hash, but got %" PRIsVALUE, rb_obj_class(argv[1]));
50
50
  }
51
51
  }
52
52
 
@@ -1,14 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mkmf'
4
+ require 'English'
2
5
 
3
- libxlsxwriter_dir = File.expand_path('../libxlsxwriter', __FILE__)
4
- make_pid = spawn({'CFLAGS' => '-fPIC -O2'}, $make, chdir: libxlsxwriter_dir)
6
+ libxlsxwriter_dir = File.expand_path('libxlsxwriter', __dir__)
7
+ make_pid = spawn({ 'CFLAGS' => '-fPIC -O2' }, $make, chdir: libxlsxwriter_dir)
5
8
  Process.wait(make_pid)
6
- raise 'Make failed for xlsxwriter' unless $? == 0
9
+ raise 'Make failed for xlsxwriter' unless $CHILD_STATUS.success?
7
10
 
8
- # enable_config('static', true)
9
- # find_library('xlsxwriter', 'workbook_new', File.expand_path('../libxlsxwriter/lib', __FILE__))
10
- $CFLAGS="-I'#{libxlsxwriter_dir}/include' -g -Wall -O2"
11
- # $LDFLAGS="-L./libxlsxwriter/lib/ -Wl,-Bstatic -lxlsxwriter -Wl,-Bdynamic"
12
- $LDFLAGS="-lz #{libxlsxwriter_dir}/lib/libxlsxwriter.a"
11
+ $CFLAGS = "-I'#{libxlsxwriter_dir}/include' -g -Wall -Werror -O2"
12
+ $LDFLAGS = "-lz #{libxlsxwriter_dir}/lib/libxlsxwriter.a"
13
13
 
14
14
  create_makefile 'xlsxwriter/xlsxwriter'
@@ -4,7 +4,7 @@
4
4
 
5
5
  Libxlsxwriter is released under a FreeBSD license:
6
6
 
7
- Copyright 2014-2019, John McNamara <jmcnamara@cpan.org>
7
+ Copyright 2014-2020, John McNamara <jmcnamara@cpan.org>
8
8
  All rights reserved.
9
9
 
10
10
  Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,8 @@ Libxlsxwriter is released under a FreeBSD license:
35
35
 
36
36
 
37
37
  Libxlsxwriter includes `queue.h` and `tree.h` from FreeBSD, the `minizip`
38
- component of `zlib` and `tmpfileplus` which have the following licenses:
38
+ component of `zlib`, `tmpfileplus` and `md5` which have the following
39
+ licenses:
39
40
 
40
41
 
41
42
  Queue.h from FreeBSD:
@@ -146,5 +147,26 @@ See the [Mozilla Public License, v. 2.0](http://mozilla.org/MPL/2.0/).
146
147
  Note, it is possible to compile libxlsxwriter using the standard library
147
148
  `tmpfile()` function instead of `tmpfileplus`, see @ref gsg_tmpdir.
148
149
 
150
+ [Openwall MD5](https://openwall.info/wiki/people/solar/software/public-domain-source-code/md5)
151
+ has the following licence:
152
+
153
+ This software was written by Alexander Peslyak in 2001. No copyright is
154
+ claimed, and the software is hereby placed in the public domain.
155
+ In case this attempt to disclaim copyright and place the software in the
156
+ public domain is deemed null and void, then the software is
157
+ Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
158
+ general public under the following terms:
159
+
160
+ Redistribution and use in source and binary forms, with or without
161
+ modification, are permitted.
162
+
163
+ There's ABSOLUTELY NO WARRANTY, express or implied.
164
+
165
+ (This is a heavily cut-down "BSD license".)
166
+
167
+ Note, the MD5 library is used to avoid including duplicate image files in the
168
+ xlsx file. If this functionality isn't required it is possible to compile
169
+ libxlsxwriter without this library by passing `USE_NO_MD5=1` to make.
170
+
149
171
  Next: @ref changes
150
172
  */
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Makefile for libxlsxwriter library.
4
4
  #
5
- # Copyright 2014-2019, John McNamara, jmcnamara@cpan.org
5
+ # Copyright 2014-2020, John McNamara, jmcnamara@cpan.org
6
6
  #
7
7
 
8
8
  # Keep the output quiet by default.
@@ -11,9 +11,11 @@ ifdef V
11
11
  Q=
12
12
  endif
13
13
 
14
- INSTALL_DIR ?= /usr/local
14
+ DESTDIR ?=
15
+ PREFIX ?= /usr/local
15
16
 
16
17
  PYTEST ?= py.test
18
+ PYTESTFILES ?= test
17
19
 
18
20
  .PHONY: docs tags examples
19
21
 
@@ -24,6 +26,9 @@ ifndef USE_SYSTEM_MINIZIP
24
26
  endif
25
27
  ifndef USE_STANDARD_TMPFILE
26
28
  $(Q)$(MAKE) -C third_party/tmpfileplus
29
+ endif
30
+ ifndef USE_NO_MD5
31
+ $(Q)$(MAKE) -C third_party/md5
27
32
  endif
28
33
  $(Q)$(MAKE) -C src
29
34
 
@@ -41,15 +46,18 @@ clean :
41
46
  $(Q)rm -rf test/functional/__pycache__
42
47
  $(Q)rm -f test/functional/*.pyc
43
48
  $(Q)rm -f lib/*
44
- ifndef USE_STANDARD_TMPFILE
49
+ ifndef USE_SYSTEM_MINIZIP
45
50
  $(Q)$(MAKE) clean -C third_party/minizip
46
51
  endif
47
52
  ifndef USE_STANDARD_TMPFILE
48
53
  $(Q)$(MAKE) clean -C third_party/tmpfileplus
49
54
  endif
55
+ ifndef USE_NO_MD5
56
+ $(Q)$(MAKE) clean -C third_party/md5
57
+ endif
50
58
 
51
59
  # Run the unit tests.
52
- test : all test_functional test_unit
60
+ test : all test_unit test_functional
53
61
 
54
62
  # Test for C++ const correctness on APIs.
55
63
  test_const : all
@@ -60,7 +68,7 @@ test_const : all
60
68
  # Run the functional tests.
61
69
  test_functional : all
62
70
  $(Q)$(MAKE) -C test/functional/src
63
- $(Q)$(PYTEST) test/functional -v
71
+ $(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
64
72
 
65
73
  # Run all tests.
66
74
  test_unit :
@@ -70,10 +78,26 @@ ifndef USE_SYSTEM_MINIZIP
70
78
  endif
71
79
  ifndef USE_STANDARD_TMPFILE
72
80
  $(Q)$(MAKE) -C third_party/tmpfileplus
81
+ endif
82
+ ifndef USE_NO_MD5
83
+ $(Q)$(MAKE) -C third_party/md5
73
84
  endif
74
85
  $(Q)$(MAKE) -C src test_lib
75
86
  $(Q)$(MAKE) -C test/unit test
76
87
 
88
+ # Test Cmake. This test should really be done with Cmake in the cmake dir but
89
+ # this is a workaround for now.
90
+ test_cmake :
91
+ ifneq ($(findstring m32,$(CFLAGS)),m32)
92
+ $(Q)$(MAKE) -C src clean
93
+ $(Q)cd cmake; cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON; make clean; make; cp libxlsxwriter.a ../src/
94
+ $(Q)cmake/xlsxwriter_unit
95
+ $(Q)$(MAKE) -C test/functional/src
96
+ $(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
97
+ else
98
+ @echo "Skipping Cmake tests on 32 bit target."
99
+ endif
100
+
77
101
  # Test the functional test exes with valgrind (in 64bit mode only).
78
102
  test_valgrind : all
79
103
  ifndef NO_VALGRIND
@@ -98,17 +122,20 @@ doc: docs
98
122
  docs:
99
123
  $(Q)$(MAKE) -C docs
100
124
 
125
+ docs_doxygen_only:
126
+ $(Q)$(MAKE) -C docs docs_doxygen_only
127
+
101
128
  # Simple minded install.
102
129
  install: all
103
- $(Q)mkdir -p $(INSTALL_DIR)/include
104
- $(Q)cp -R include/* $(INSTALL_DIR)/include
105
- $(Q)mkdir -p $(INSTALL_DIR)/lib
106
- $(Q)cp lib/* $(INSTALL_DIR)/lib
130
+ $(Q)mkdir -p $(DESTDIR)$(PREFIX)/include
131
+ $(Q)cp -R include/* $(DESTDIR)$(PREFIX)/include
132
+ $(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib
133
+ $(Q)cp lib/* $(DESTDIR)$(PREFIX)/lib
107
134
 
108
135
  # Simpler minded uninstall.
109
136
  uninstall:
110
- $(Q)rm -rf $(INSTALL_DIR)/include/xlsxwriter*
111
- $(Q)rm $(INSTALL_DIR)/lib/libxlsxwriter.*
137
+ $(Q)rm -rf $(DESTDIR)$(PREFIX)/include/xlsxwriter*
138
+ $(Q)rm $(DESTDIR)$(PREFIX)/lib/libxlsxwriter.*
112
139
 
113
140
  # Strip the lib files.
114
141
  strip:
@@ -121,12 +148,15 @@ ifndef USE_SYSTEM_MINIZIP
121
148
  endif
122
149
  ifndef USE_STANDARD_TMPFILE
123
150
  $(Q)$(MAKE) -C third_party/tmpfileplus
151
+ endif
152
+ ifndef USE_NO_MD5
153
+ $(Q)$(MAKE) -C third_party/md5
124
154
  endif
125
155
  $(Q)$(MAKE) -C src clean
126
156
  $(Q)rm -f lib/*
127
157
  $(Q)rm -rf cov-int
128
158
  $(Q)rm -f libxlsxwriter-coverity.tgz
129
- $(Q)../../cov-analysis-linux64-8.7.0/bin/cov-build --dir cov-int make -C src libxlsxwriter.a
159
+ $(Q)../../cov-analysis-linux64-2019.03/bin/cov-build --dir cov-int make -C src libxlsxwriter.a
130
160
  $(Q)tar -czf libxlsxwriter-coverity.tgz cov-int
131
161
  $(Q)$(MAKE) -C src clean
132
162
  $(Q)rm -f lib/*
@@ -138,6 +168,9 @@ ifndef USE_SYSTEM_MINIZIP
138
168
  endif
139
169
  ifndef USE_STANDARD_TMPFILE
140
170
  $(Q)$(MAKE) -C third_party/tmpfileplus
171
+ endif
172
+ ifndef USE_NO_MD5
173
+ $(Q)$(MAKE) -C third_party/md5
141
174
  endif
142
175
  $(Q)$(MAKE) -C src clean
143
176
  $(Q)rm -f lib/*
@@ -152,6 +185,7 @@ spellcheck:
152
185
  $(Q)for f in examples/*.c; do aspell --lang=en_US --check $$f; done
153
186
  $(Q)aspell --lang=en_US --check Changes.txt
154
187
  $(Q)aspell --lang=en_US --check Readme.md
188
+ $(Q)aspell --lang=en_US --check docs/src/examples.txt
155
189
 
156
190
  releasecheck:
157
191
  $(Q)dev/release/release_check.sh
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * app - A libxlsxwriter library for creating Excel XLSX app files.
7
7
  *