axlsx 2.1.0.pre → 3.0.0.pre
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 +5 -0
- data/README.md +17 -20
- data/Rakefile +0 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +15 -0
- data/examples/example.rb +31 -1
- data/lib/axlsx.rb +9 -4
- data/lib/axlsx/drawing/area_chart.rb +99 -0
- data/lib/axlsx/drawing/area_series.rb +110 -0
- data/lib/axlsx/drawing/bar_chart.rb +143 -0
- data/lib/axlsx/drawing/chart.rb +8 -1
- data/lib/axlsx/drawing/d_lbls.rb +3 -3
- data/lib/axlsx/drawing/drawing.rb +3 -0
- data/lib/axlsx/drawing/line_series.rb +18 -1
- data/lib/axlsx/drawing/num_val.rb +3 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +2 -1
- data/lib/axlsx/drawing/pic.rb +24 -17
- data/lib/axlsx/drawing/scaling.rb +2 -2
- data/lib/axlsx/drawing/scatter_series.rb +16 -2
- data/lib/axlsx/drawing/str_val.rb +3 -1
- data/lib/axlsx/drawing/title.rb +19 -1
- data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
- data/lib/axlsx/drawing/view_3D.rb +2 -2
- data/lib/axlsx/package.rb +7 -16
- data/lib/axlsx/rels/relationships.rb +5 -2
- data/lib/axlsx/stylesheet/num_fmt.rb +9 -0
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/util/constants.rb +8 -5
- data/lib/axlsx/util/mime_type_utils.rb +11 -0
- data/lib/axlsx/util/simple_typed_list.rb +1 -1
- data/lib/axlsx/util/validators.rb +14 -9
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +19 -1
- data/lib/axlsx/workbook/workbook_view.rb +5 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +26 -19
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +15 -5
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -0
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +36 -13
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +4 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +23 -3
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +28 -32
- data/lib/axlsx/workbook/worksheet/row.rb +7 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +3 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +8 -51
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
- data/test/axlsx.qcachegrind +2226 -0
- data/test/drawing/tc_area_chart.rb +39 -0
- data/test/drawing/tc_area_series.rb +71 -0
- data/test/drawing/tc_bar_chart.rb +71 -0
- data/test/drawing/tc_chart.rb +23 -10
- data/test/drawing/tc_drawing.rb +2 -2
- data/test/drawing/tc_line_series.rb +38 -5
- data/test/drawing/tc_pic.rb +11 -19
- data/test/drawing/tc_scatter_series.rb +16 -5
- data/test/drawing/tc_str_val.rb +9 -0
- data/test/drawing/tc_title.rb +5 -0
- data/test/stylesheet/tc_styles.rb +2 -2
- data/test/tc_axlsx.rb +31 -0
- data/test/tc_helper.rb +3 -1
- data/test/tc_package.rb +12 -0
- data/test/util/tc_mime_type_utils.rb +13 -0
- data/test/util/tc_simple_typed_list.rb +1 -1
- data/test/util/tc_validators.rb +34 -10
- data/test/workbook/tc_shared_strings_table.rb +16 -1
- data/test/workbook/tc_workbook.rb +22 -1
- data/test/workbook/worksheet/tc_cell.rb +53 -11
- data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
- data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
- data/test/workbook/worksheet/tc_rich_text_run.rb +11 -11
- data/test/workbook/worksheet/tc_row.rb +5 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
- data/test/workbook/worksheet/tc_table.rb +2 -3
- data/test/workbook/worksheet/tc_worksheet.rb +53 -38
- metadata +72 -20
- data/examples/IMAGE1UP.JPEG +0 -0
- data/lib/axlsx/util/string.rb +0 -7
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'tc_helper.rb'
|
2
|
+
|
3
|
+
class TestAreaChart < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@p = Axlsx::Package.new
|
7
|
+
ws = @p.workbook.add_worksheet
|
8
|
+
@row = ws.add_row ["one", 1, Time.now]
|
9
|
+
@chart = ws.add_chart Axlsx::AreaChart, :title => "fishery"
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initialization
|
16
|
+
assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
|
17
|
+
assert_equal(@chart.series_type, Axlsx::AreaSeries, "series type incorrect")
|
18
|
+
assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created")
|
19
|
+
assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_grouping
|
23
|
+
assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted }
|
24
|
+
assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked }
|
25
|
+
assert(@chart.grouping == :stacked)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_to_xml
|
29
|
+
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
30
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
31
|
+
errors = []
|
32
|
+
schema.validate(doc).each do |error|
|
33
|
+
errors.push error
|
34
|
+
puts error.message
|
35
|
+
end
|
36
|
+
assert(errors.empty?, "error free validation")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'tc_helper.rb'
|
2
|
+
|
3
|
+
class TestAreaSeries < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
p = Axlsx::Package.new
|
7
|
+
@ws = p.workbook.add_worksheet :name=>"hmmm"
|
8
|
+
chart = @ws.add_chart Axlsx::AreaChart, :title => "fishery"
|
9
|
+
@series = chart.add_series(
|
10
|
+
:data => [0,1,2],
|
11
|
+
:labels => ["zero", "one", "two"],
|
12
|
+
:title => "bob",
|
13
|
+
:color => "#FF0000",
|
14
|
+
:show_marker => true,
|
15
|
+
:smooth => true
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_initialize
|
20
|
+
assert_equal(@series.title.text, "bob", "series title has been applied")
|
21
|
+
assert_equal(@series.labels.class, Axlsx::AxDataSource)
|
22
|
+
assert_equal(@series.data.class, Axlsx::NumDataSource)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_show_marker
|
26
|
+
assert_equal(true, @series.show_marker)
|
27
|
+
@series.show_marker = false
|
28
|
+
assert_equal(false, @series.show_marker)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_smooth
|
32
|
+
assert_equal(true, @series.smooth)
|
33
|
+
@series.smooth = false
|
34
|
+
assert_equal(false, @series.smooth)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_marker_symbol
|
38
|
+
assert_equal(:default, @series.marker_symbol)
|
39
|
+
@series.marker_symbol = :circle
|
40
|
+
assert_equal(:circle, @series.marker_symbol)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_to_xml_string
|
44
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
45
|
+
assert(doc.xpath("//srgbClr[@val='#{@series.color}']"))
|
46
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker").size, 0)
|
47
|
+
assert(doc.xpath("//smooth"))
|
48
|
+
|
49
|
+
@series.marker_symbol = :diamond
|
50
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
51
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size, 1)
|
52
|
+
|
53
|
+
@series.show_marker = false
|
54
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
55
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size, 1)
|
56
|
+
end
|
57
|
+
|
58
|
+
def wrap_with_namespaces(series)
|
59
|
+
'<c:chartSpace xmlns:c="' <<
|
60
|
+
Axlsx::XML_NS_C <<
|
61
|
+
'" xmlns:a="' <<
|
62
|
+
Axlsx::XML_NS_A <<
|
63
|
+
'">' <<
|
64
|
+
series.to_xml_string <<
|
65
|
+
'</c:chartSpace>'
|
66
|
+
end
|
67
|
+
|
68
|
+
def xpath_with_namespaces(doc, xpath)
|
69
|
+
doc.xpath(xpath, "a" => Axlsx::XML_NS_A, "c" => Axlsx::XML_NS_C)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'tc_helper.rb'
|
2
|
+
|
3
|
+
class TestBarChart < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@p = Axlsx::Package.new
|
7
|
+
ws = @p.workbook.add_worksheet
|
8
|
+
@row = ws.add_row ["one", 1, Time.now]
|
9
|
+
@chart = ws.add_chart Axlsx::BarChart, :title => "fishery"
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initialization
|
16
|
+
assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect")
|
17
|
+
assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect")
|
18
|
+
assert_equal(@chart.bar_dir, :bar, " bar direction incorrect")
|
19
|
+
assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created")
|
20
|
+
assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created")
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_bar_direction
|
24
|
+
assert_raise(ArgumentError, "require valid bar direction") { @chart.bar_dir = :left }
|
25
|
+
assert_nothing_raised("allow valid bar direction") { @chart.bar_dir = :col }
|
26
|
+
assert(@chart.bar_dir == :col)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_grouping
|
30
|
+
assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted }
|
31
|
+
assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard }
|
32
|
+
assert(@chart.grouping == :standard)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def test_gapWidth
|
37
|
+
assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 }
|
38
|
+
assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" }
|
39
|
+
assert(@chart.gap_width == "200%")
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_gapDepth
|
43
|
+
assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 }
|
44
|
+
assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" }
|
45
|
+
assert(@chart.gap_depth == "200%")
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_shape
|
49
|
+
assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
|
50
|
+
assert_nothing_raised("allow valid shape") { @chart.shape = :cone }
|
51
|
+
assert(@chart.shape == :cone)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_to_xml_string
|
55
|
+
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
56
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
57
|
+
errors = []
|
58
|
+
schema.validate(doc).each do |error|
|
59
|
+
errors.push error
|
60
|
+
puts error.message
|
61
|
+
end
|
62
|
+
assert(errors.empty?, "error free validation")
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_to_xml_string_has_axes_in_correct_order
|
66
|
+
str = @chart.to_xml_string
|
67
|
+
cat_axis_position = str.index(@chart.axes[:cat_axis].id.to_s)
|
68
|
+
val_axis_position = str.index(@chart.axes[:val_axis].id.to_s)
|
69
|
+
assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML")
|
70
|
+
end
|
71
|
+
end
|
data/test/drawing/tc_chart.rb
CHANGED
@@ -6,7 +6,7 @@ class TestChart < Test::Unit::TestCase
|
|
6
6
|
@p = Axlsx::Package.new
|
7
7
|
ws = @p.workbook.add_worksheet
|
8
8
|
@row = ws.add_row ["one", 1, Time.now]
|
9
|
-
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
9
|
+
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery", :bg_color => "000000"
|
10
10
|
end
|
11
11
|
|
12
12
|
def teardown
|
@@ -27,17 +27,30 @@ class TestChart < Test::Unit::TestCase
|
|
27
27
|
assert_equal(@chart.title.cell, @row.cells.first)
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_style
|
31
|
+
assert_raise(ArgumentError) { @chart.style = 49 }
|
32
|
+
assert_nothing_raised { @chart.style = 2 }
|
33
|
+
assert_equal(@chart.style, 2)
|
34
|
+
end
|
35
|
+
|
30
36
|
def test_to_from_marker_access
|
31
37
|
assert(@chart.to.is_a?(Axlsx::Marker))
|
32
38
|
assert(@chart.from.is_a?(Axlsx::Marker))
|
33
39
|
end
|
34
40
|
|
35
|
-
def
|
36
|
-
assert_raise(ArgumentError) { @chart.
|
37
|
-
assert_nothing_raised { @chart.
|
38
|
-
assert_equal(@chart.
|
41
|
+
def test_bg_color
|
42
|
+
assert_raise(ArgumentError) { @chart.bg_color = 2 }
|
43
|
+
assert_nothing_raised { @chart.bg_color = "FFFFFF" }
|
44
|
+
assert_equal(@chart.bg_color, "FFFFFF")
|
45
|
+
|
39
46
|
end
|
40
|
-
|
47
|
+
|
48
|
+
def test_title_size
|
49
|
+
assert_raise(ArgumentError) { @chart.title_size = 2 }
|
50
|
+
assert_nothing_raised { @chart.title_size = "100" }
|
51
|
+
assert_equal(@chart.title.text_size, "100")
|
52
|
+
end
|
53
|
+
|
41
54
|
def test_vary_colors
|
42
55
|
assert_equal(true, @chart.vary_colors)
|
43
56
|
assert_raise(ArgumentError) { @chart.vary_colors = 7 }
|
@@ -63,7 +76,7 @@ class TestChart < Test::Unit::TestCase
|
|
63
76
|
@chart.start_at [5,6]
|
64
77
|
assert_equal(@chart.graphic_frame.anchor.from.col, 5)
|
65
78
|
assert_equal(@chart.graphic_frame.anchor.from.row, 6)
|
66
|
-
|
79
|
+
|
67
80
|
end
|
68
81
|
|
69
82
|
def test_end_at
|
@@ -76,7 +89,7 @@ class TestChart < Test::Unit::TestCase
|
|
76
89
|
@chart.end_at [10,11]
|
77
90
|
assert_equal(@chart.graphic_frame.anchor.to.col, 10)
|
78
91
|
assert_equal(@chart.graphic_frame.anchor.to.row, 11)
|
79
|
-
|
92
|
+
|
80
93
|
end
|
81
94
|
|
82
95
|
def test_add_series
|
@@ -88,13 +101,13 @@ class TestChart < Test::Unit::TestCase
|
|
88
101
|
def test_pn
|
89
102
|
assert_equal(@chart.pn, "charts/chart1.xml")
|
90
103
|
end
|
91
|
-
|
104
|
+
|
92
105
|
def test_d_lbls
|
93
106
|
assert_equal(nil, @chart.instance_values[:d_lbls])
|
94
107
|
@chart.d_lbls.d_lbl_pos = :t
|
95
108
|
assert(@chart.d_lbls.is_a?(Axlsx::DLbls), 'DLbls instantiated on access')
|
96
109
|
end
|
97
|
-
|
110
|
+
|
98
111
|
def test_to_xml_string
|
99
112
|
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
|
100
113
|
doc = Nokogiri::XML(@chart.to_xml_string)
|
data/test/drawing/tc_drawing.rb
CHANGED
@@ -59,9 +59,9 @@ class TestDrawing < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_relationships
|
62
|
-
|
62
|
+
@ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
|
63
63
|
assert_equal(@ws.drawing.relationships.size, 1, "adding a chart adds a relationship")
|
64
|
-
|
64
|
+
@ws.add_chart(Axlsx::Pie3DChart, :title=>"nancy", :start_at=>[1,5], :end_at=>[5,10])
|
65
65
|
assert_equal(@ws.drawing.relationships.size, 2, "adding a chart adds a relationship")
|
66
66
|
end
|
67
67
|
|
@@ -6,14 +6,20 @@ class TestLineSeries < Test::Unit::TestCase
|
|
6
6
|
p = Axlsx::Package.new
|
7
7
|
@ws = p.workbook.add_worksheet :name=>"hmmm"
|
8
8
|
chart = @ws.add_chart Axlsx::Line3DChart, :title => "fishery"
|
9
|
-
@series = chart.add_series
|
9
|
+
@series = chart.add_series(
|
10
|
+
:data => [0,1,2],
|
11
|
+
:labels => ["zero", "one", "two"],
|
12
|
+
:title => "bob",
|
13
|
+
:color => "#FF0000",
|
14
|
+
:show_marker => true,
|
15
|
+
:smooth => true
|
16
|
+
)
|
10
17
|
end
|
11
18
|
|
12
19
|
def test_initialize
|
13
20
|
assert_equal(@series.title.text, "bob", "series title has been applied")
|
14
21
|
assert_equal(@series.labels.class, Axlsx::AxDataSource)
|
15
22
|
assert_equal(@series.data.class, Axlsx::NumDataSource)
|
16
|
-
|
17
23
|
end
|
18
24
|
|
19
25
|
def test_show_marker
|
@@ -28,11 +34,38 @@ class TestLineSeries < Test::Unit::TestCase
|
|
28
34
|
assert_equal(false, @series.smooth)
|
29
35
|
end
|
30
36
|
|
37
|
+
def test_marker_symbol
|
38
|
+
assert_equal(:default, @series.marker_symbol)
|
39
|
+
@series.marker_symbol = :circle
|
40
|
+
assert_equal(:circle, @series.marker_symbol)
|
41
|
+
end
|
42
|
+
|
31
43
|
def test_to_xml_string
|
32
|
-
doc = Nokogiri::XML(@series
|
44
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
33
45
|
assert(doc.xpath("//srgbClr[@val='#{@series.color}']"))
|
34
|
-
|
46
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker").size, 0)
|
35
47
|
assert(doc.xpath("//smooth"))
|
48
|
+
|
49
|
+
@series.marker_symbol = :diamond
|
50
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
51
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size, 1)
|
52
|
+
|
53
|
+
@series.show_marker = false
|
54
|
+
doc = Nokogiri::XML(wrap_with_namespaces(@series))
|
55
|
+
assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size, 1)
|
56
|
+
end
|
57
|
+
|
58
|
+
def wrap_with_namespaces(series)
|
59
|
+
'<c:chartSpace xmlns:c="' <<
|
60
|
+
Axlsx::XML_NS_C <<
|
61
|
+
'" xmlns:a="' <<
|
62
|
+
Axlsx::XML_NS_A <<
|
63
|
+
'">' <<
|
64
|
+
series.to_xml_string <<
|
65
|
+
'</c:chartSpace>'
|
66
|
+
end
|
67
|
+
|
68
|
+
def xpath_with_namespaces(doc, xpath)
|
69
|
+
doc.xpath(xpath, "a" => Axlsx::XML_NS_A, "c" => Axlsx::XML_NS_C)
|
36
70
|
end
|
37
|
-
#TODO serialization testing
|
38
71
|
end
|
data/test/drawing/tc_pic.rb
CHANGED
@@ -5,12 +5,11 @@ class TestPic < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@p = Axlsx::Package.new
|
7
7
|
ws = @p.workbook.add_worksheet
|
8
|
-
@test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
|
9
|
-
@
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
def teardown
|
8
|
+
@test_img = @test_img_jpg = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
|
9
|
+
@test_img_png = File.dirname(__FILE__) + "/../../examples/image1.png"
|
10
|
+
@test_img_gif = File.dirname(__FILE__) + "/../../examples/image1.gif"
|
11
|
+
@test_img_fake = File.dirname(__FILE__) + "/../../examples/image1_fake.jpg"
|
12
|
+
@image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_initialization
|
@@ -38,6 +37,7 @@ class TestPic < Test::Unit::TestCase
|
|
38
37
|
assert_equal(200, @image.width)
|
39
38
|
|
40
39
|
end
|
40
|
+
|
41
41
|
def test_hyperlink
|
42
42
|
assert_equal(@image.hyperlink.href, "https://github.com/randym")
|
43
43
|
@image.hyperlink = "http://axlsx.blogspot.com"
|
@@ -70,19 +70,12 @@ class TestPic < Test::Unit::TestCase
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_image_src
|
73
|
-
assert_raise(ArgumentError) { @image.image_src = 49 }
|
74
|
-
assert_raise(ArgumentError) { @image.image_src = 'Unknown' }
|
75
73
|
assert_raise(ArgumentError) { @image.image_src = __FILE__ }
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
assert_nothing_raised { @image.image_src = @test_img_up }
|
82
|
-
ct = @p.send(:content_types).detect do |t|
|
83
|
-
t.respond_to?(:extension) && t.extension.downcase == @image.extname.downcase
|
84
|
-
end
|
85
|
-
assert_equal("image/jpeg", ct.content_type)
|
74
|
+
assert_raise(ArgumentError) { @image.image_src = @test_img_fake }
|
75
|
+
assert_nothing_raised { @image.image_src = @test_img_gif }
|
76
|
+
assert_nothing_raised { @image.image_src = @test_img_png }
|
77
|
+
assert_nothing_raised { @image.image_src = @test_img_jpg }
|
78
|
+
assert_equal(@image.image_src, @test_img_jpg)
|
86
79
|
end
|
87
80
|
|
88
81
|
def test_descr
|
@@ -107,5 +100,4 @@ class TestPic < Test::Unit::TestCase
|
|
107
100
|
doc = Nokogiri::XML(@image.anchor.drawing.to_xml_string)
|
108
101
|
assert_equal r_id, doc.xpath("//a:blip").first["r:embed"]
|
109
102
|
end
|
110
|
-
|
111
103
|
end
|
@@ -18,28 +18,39 @@ class TestScatterSeries < Test::Unit::TestCase
|
|
18
18
|
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents"
|
19
19
|
assert(@series.smooth, "series is smooth by default on smooth charts")
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def test_unsmoothed_chart_default_smoothing
|
23
23
|
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart", :scatter_style => :line
|
24
24
|
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents"
|
25
25
|
assert(!@series.smooth, "series is not smooth by default on non-smooth charts")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def test_explicit_smoothing
|
29
29
|
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart, Smooth Series", :scatter_style => :line
|
30
30
|
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents", :smooth => true
|
31
31
|
assert(@series.smooth, "series is smooth when overriding chart default")
|
32
|
-
end
|
33
|
-
|
32
|
+
end
|
33
|
+
|
34
34
|
def test_explicit_unsmoothing
|
35
35
|
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart, Unsmooth Series", :scatter_style => :smoothMarker
|
36
36
|
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents", :smooth => false
|
37
37
|
assert(!@series.smooth, "series is not smooth when overriding chart default")
|
38
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_ln_width
|
41
|
+
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "ln width", :scatter_style => :line
|
42
|
+
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"ln_width"
|
43
|
+
@series.ln_width = 12700
|
44
|
+
assert_equal(@series.ln_width, 12700, 'line width assigment is allowed')
|
45
|
+
end
|
39
46
|
|
40
47
|
def test_to_xml_string
|
48
|
+
@chart.scatter_style = :line
|
49
|
+
@series.ln_width = 12700
|
41
50
|
doc = Nokogiri::XML(@chart.to_xml_string)
|
51
|
+
assert_equal(12700, @series.ln_width)
|
42
52
|
assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size,4)
|
53
|
+
assert_equal(doc.xpath("//a:ln[@w='#{@series.ln_width}']").length, 1)
|
43
54
|
end
|
44
55
|
|
45
56
|
end
|
data/test/drawing/tc_str_val.rb
CHANGED
@@ -4,6 +4,7 @@ class TestStrVal < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@str_val = Axlsx::StrVal.new :v => "1"
|
7
|
+
@str_val_with_special_characters = Axlsx::StrVal.new :v => "a & b <c>"
|
7
8
|
end
|
8
9
|
|
9
10
|
def test_initialize
|
@@ -18,4 +19,12 @@ class TestStrVal < Test::Unit::TestCase
|
|
18
19
|
assert_equal(doc.xpath("//c:pt/c:v[text()='1']").size, 1)
|
19
20
|
end
|
20
21
|
|
22
|
+
def test_to_xml_string_special_characters
|
23
|
+
str = '<?xml version="1.0" encoding="UTF-8"?>'
|
24
|
+
str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">'
|
25
|
+
str << @str_val_with_special_characters.to_xml_string(0)
|
26
|
+
doc = Nokogiri::XML(str)
|
27
|
+
assert_equal(doc.xpath("//c:pt/c:v[text()='a & b <c>']").size, 1)
|
28
|
+
end
|
29
|
+
|
21
30
|
end
|