gnumeric r16962 - in branches/gnumeric-1-8: . plugins/excel
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16962 - in branches/gnumeric-1-8: . plugins/excel
- Date: Tue, 11 Nov 2008 13:44:13 +0000 (UTC)
Author: jbrefort
Date: Tue Nov 11 13:44:12 2008
New Revision: 16962
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16962&view=rev
Log:
2008-11-11 Jean Brefort <jean brefort normalesup org>
* ms-chart.c: (ms_excel_chart_write): fixed segfault when exporting
an empty contour plot. [#557027]
Modified:
branches/gnumeric-1-8/NEWS
branches/gnumeric-1-8/plugins/excel/ChangeLog
branches/gnumeric-1-8/plugins/excel/ms-chart.c
Modified: branches/gnumeric-1-8/NEWS
==============================================================================
--- branches/gnumeric-1-8/NEWS (original)
+++ branches/gnumeric-1-8/NEWS Tue Nov 11 13:44:12 2008
@@ -3,6 +3,7 @@
Jean:
* Import/export axis ticks labels orientation. [#544935]
* Fix an attribute order issue while loading. [#547183]
+ * Fix crash when exporting an empty contour plot to .xls. [#557027]
Jody:
* Fix OO.o import failure on win32. [#536552]
Modified: branches/gnumeric-1-8/plugins/excel/ms-chart.c
==============================================================================
--- branches/gnumeric-1-8/plugins/excel/ms-chart.c (original)
+++ branches/gnumeric-1-8/plugins/excel/ms-chart.c Tue Nov 11 13:44:12 2008
@@ -5648,26 +5648,40 @@
/* dump the associated series (skip any that we are dropping */
for (ptr = sets; ptr != NULL ; ptr = ptr->next) {
for (plots = ((XLAxisSet *)ptr->data)->plots ; plots != NULL ; plots = plots->next) {
- if (0 != strcmp (G_OBJECT_TYPE_NAME (plots->data), "GogContourPlot")) {
- for (series = gog_plot_get_series (plots->data) ; series != NULL ; series = series->next)
- num_series += chart_write_series (&state, series->data, num_series);
- } else {
- /* we should have only one series there */
- GogSeries *ser = GOG_SERIES (gog_plot_get_series (plots->data)->data);
- /* create an equivalent XLContourPlot and save its series */
- if (ser != NULL) {
- gboolean as_col, s_as_col;
- gboolean s_is_rc, mat_is_rc;
- GnmExprTop const *stexpr;
- GnmExprTop const *mattexpr;
- GnmValue const *sval, *matval;
- GnmValue *val;
- GogSeries *serbuf;
- GnmRange vector, svec;
- int i, j, m, n, sn, cur = 0, scur = 0;
+ /* first test if the plot uses a matrix or not */
+ gboolean has_matrix = FALSE;
+ GogPlotDesc const *desc = gog_plot_description (GOG_PLOT (plots->data));
+ int n = 0, m;
+ if (!desc) /* this should not happen, but ... */
+ continue;
+ for (m = 0; m < (int) desc->series.num_dim; m++)
+ if (desc->series.dim[m].val_type == GOG_DIM_MATRIX) {
+ n = m;
+ has_matrix = TRUE;
+ break; /* hopefully there is only one matrix */
+ }
+ if (!has_matrix) {
+ for (series = gog_plot_get_series (plots->data) ; series != NULL ; series = series->next)
+ num_series += chart_write_series (&state, series->data, num_series);
+ } else if (n == 2) { /* surfaces and countours have the matrix as third data, other
+ plot types that might use matrices will probably not be exportable
+ to any of excel formats */
+ /* we should have only one series there */
+ GogSeries *ser = GOG_SERIES (gog_plot_get_series (plots->data)->data);
+ /* create an equivalent XLContourPlot and save its series */
+ if (ser != NULL) {
+ gboolean as_col, s_as_col = FALSE;
+ gboolean s_is_rc = FALSE, mat_is_rc;
+ GnmExprTop const *stexpr = NULL;
+ GnmExprTop const *mattexpr;
+ GnmValue const *sval = NULL, *matval;
+ GnmValue *val;
+ GogSeries *serbuf;
+ GnmRange vector, svec;
+ int i, j, sn = 0, cur = 0, scur = 0;
GOData *s, *c, *mat = ser->values[2].data;
GODataMatrixSize size = go_data_matrix_get_size (GO_DATA_MATRIX (mat));
- GogPlot *plotbuf = (GogPlot*) gog_plot_new_by_name ("XLContourPlot");
+ GogPlot *plotbuf = (GogPlot*) gog_plot_new_by_name ((0 == strcmp (G_OBJECT_TYPE_NAME (plots->data), "GogContourPlot"))? "XLContourPlot": "XLSurfacePlot");
Sheet *sheet = sheet_object_get_sheet (so);
g_object_get (G_OBJECT (plots->data), "transposed", &as_col, NULL);
mattexpr = gnm_go_data_get_expr (mat);
@@ -5684,9 +5698,11 @@
c = ser->values[0].data;
s = ser->values[1].data;
}
- sn = go_data_vector_get_len (GO_DATA_VECTOR (s));
- stexpr = gnm_go_data_get_expr (s);
- s_is_rc = gnm_expr_top_is_rangeref (stexpr);
+ if (s) {
+ sn = go_data_vector_get_len (GO_DATA_VECTOR (s));
+ stexpr = gnm_go_data_get_expr (s);
+ s_is_rc = gnm_expr_top_is_rangeref (stexpr);
+ }
if (mat_is_rc) {
if (as_col) {
vector.start.row = matval->v_range.cell.a.row;
@@ -5699,19 +5715,21 @@
}
} else {
}
- if (s_is_rc) {
- sval = gnm_expr_top_get_range (stexpr);
- s_as_col = sval->v_range.cell.a.col == sval->v_range.cell.b.col;
- if (s_as_col) {
- svec.start.col = svec.end.col = sval->v_range.cell.a.col;
- scur = sval->v_range.cell.a.row;
+ if (s) {
+ if (s_is_rc) {
+ sval = gnm_expr_top_get_range (stexpr);
+ s_as_col = sval->v_range.cell.a.col == sval->v_range.cell.b.col;
+ if (s_as_col) {
+ svec.start.col = svec.end.col = sval->v_range.cell.a.col;
+ scur = sval->v_range.cell.a.row;
+ } else {
+ svec.start.row = svec.end.row = sval->v_range.cell.a.row;
+ scur = sval->v_range.cell.a.col;
+ }
} else {
- svec.start.row = svec.end.row = sval->v_range.cell.a.row;
- scur = sval->v_range.cell.a.col;
+ sval = gnm_expr_top_get_constant (stexpr);
+ s_as_col = sval->v_array.y > sval->v_array.x;
}
- } else {
- sval = gnm_expr_top_get_constant (stexpr);
- s_as_col = sval->v_array.y > sval->v_array.x;
}
n = (as_col)? size.columns: size.rows;
if (!mat_is_rc)
@@ -5720,9 +5738,11 @@
m = 0;
for (i = 0; i < n; i++) {
serbuf = gog_plot_new_series (plotbuf);
- g_object_ref (c);
- gog_series_set_dim (serbuf, 0, c, NULL);
- if (i < sn) {
+ if (c) {
+ g_object_ref (c);
+ gog_series_set_dim (serbuf, 0, c, NULL);
+ }
+ if (s && (i < sn)) {
if (s_is_rc) {
if (s_as_col)
svec.start.row = svec.end.row = scur++;
@@ -5763,7 +5783,7 @@
}
if (mat_is_rc)
value_release ((GnmValue*) matval);
- if (s_is_rc)
+ if (s && s_is_rc)
value_release ((GnmValue*) sval);
for (series = gog_plot_get_series (plotbuf) ; series != NULL ; series = series->next)
num_series += chart_write_series (&state, series->data, num_series);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]