[gnumeric] handle export and import of XYZ contour plot to/from ODF
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] handle export and import of XYZ contour plot to/from ODF
- Date: Thu, 23 Jul 2009 20:29:23 +0000 (UTC)
commit b5e6301df4e2deee201db4e0a51d24724a3b0ae7
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Thu Jul 23 14:27:32 2009 -0600
handle export and import of XYZ contour plot to/from ODF
2009-07-23 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (gog_series_map_dim_by_name): new
(oo_plot_assign_dim): add optional name argument and change all callers
(oo_series_domain): handle OO_PLOT_XYZ_CONTOUR
* openoffice-write.c (odf_write_plot): handle ODF_XYZ_SURF
plugins/openoffice/ChangeLog | 7 ++++
plugins/openoffice/openoffice-read.c | 64 ++++++++++++++++++++------------
plugins/openoffice/openoffice-write.c | 1 +
3 files changed, 48 insertions(+), 24 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 5d0d1e5..eeba0ce 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2009-07-23 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (gog_series_map_dim_by_name): new
+ (oo_plot_assign_dim): add optional name argument and change all callers
+ (oo_series_domain): handle OO_PLOT_XYZ_CONTOUR
+ * openoffice-write.c (odf_write_plot): handle ODF_XYZ_SURF
+
2009-07-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_plot_series): handle OO_PLOT_SCATTER_COLOUR
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 9f8bbe8..e55fa14 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3358,9 +3358,22 @@ gog_series_map_dim (GogSeries const *series, GogMSDimType ms_type)
return i;
return -2;
}
+
+static int
+gog_series_map_dim_by_name (GogSeries const *series, char const *dim_name)
+{
+ GogSeriesDesc const *desc = &series->plot->desc.series;
+ unsigned i = desc->num_dim;
+
+ while (i-- > 0)
+ if (desc->dim[i].name != NULL && strcmp (desc->dim[i].name, dim_name) == 0)
+ return i;
+ return -2;
+}
+
/* If range == %NULL use an implicit range */
static void
-oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type)
+oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type, char const *dim_name)
{
OOParseState *state = (OOParseState *)xin->user_state;
@@ -3374,8 +3387,10 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type)
return;
if (dim_type < 0)
dim = - (1 + dim_type);
- else
+ else if (dim_name == NULL)
dim = gog_series_map_dim (state->chart.series, dim_type);
+ else
+ dim = gog_series_map_dim_by_name (state->chart.series, dim_name);
if (dim < -1)
return;
@@ -3539,11 +3554,11 @@ odf_create_stock_plot (GsfXMLIn *xin)
if (len-- > 0) {
state->chart.series = gog_plot_new_series (state->chart.plot);
- oo_plot_assign_dim (xin, series_addresses->data, GOG_MS_DIM_LOW);
+ oo_plot_assign_dim (xin, series_addresses->data, GOG_MS_DIM_LOW, NULL);
}
if (len-- > 0) {
series_addresses = series_addresses->next;
- oo_plot_assign_dim (xin, series_addresses->data, GOG_MS_DIM_HIGH);
+ oo_plot_assign_dim (xin, series_addresses->data, GOG_MS_DIM_HIGH, NULL);
}
}
@@ -3556,7 +3571,7 @@ oo_plot_area_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
go_slist_free_custom (state->chart.stock_series, g_free);
state->chart.stock_series = NULL;
} else if (state->chart.series != NULL) {
- oo_plot_assign_dim (xin, NULL, GOG_MS_DIM_VALUES);
+ oo_plot_assign_dim (xin, NULL, GOG_MS_DIM_VALUES, NULL);
state->chart.series = NULL;
}
state->chart.plot = NULL;
@@ -3621,9 +3636,9 @@ oo_plot_series (GsfXMLIn *xin, xmlChar const **attrs)
dim = GOG_MS_DIM_VALUES;
break;
}
- oo_plot_assign_dim (xin, attrs[1], dim);
+ oo_plot_assign_dim (xin, attrs[1], dim, NULL);
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "label-cell-address"))
- oo_plot_assign_dim (xin, attrs[1], GOG_MS_DIM_LABELS);
+ oo_plot_assign_dim (xin, attrs[1], GOG_MS_DIM_LABELS, NULL);
break;
}
}
@@ -3642,7 +3657,7 @@ oo_plot_series_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
break;
/* else no break */
default:
- oo_plot_assign_dim (xin, NULL, GOG_MS_DIM_VALUES);
+ oo_plot_assign_dim (xin, NULL, GOG_MS_DIM_VALUES, NULL);
state->chart.series = NULL;
break;
}
@@ -3656,27 +3671,28 @@ oo_series_domain (GsfXMLIn *xin, xmlChar const **attrs)
{
OOParseState *state = (OOParseState *)xin->user_state;
xmlChar const *src = NULL;
- int dim;
+ int dim = GOG_MS_DIM_VALUES;
+ char const *name = NULL;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "cell-range-address"))
src = attrs[1];
- if (state->chart.domain_count == 0)
- switch (state->chart.plot_type) {
- case OO_PLOT_BUBBLE:
- case OO_PLOT_SCATTER_COLOUR:
- dim = GOG_MS_DIM_VALUES;
- break;
- case OO_PLOT_SURF:
- dim = -1;
- break;
- default:
- dim = GOG_MS_DIM_CATEGORIES;
- break;
- }
- else
+ switch (state->chart.plot_type) {
+ case OO_PLOT_BUBBLE:
+ case OO_PLOT_SCATTER_COLOUR:
+ dim = (state->chart.domain_count == 0) ? GOG_MS_DIM_VALUES : GOG_MS_DIM_CATEGORIES;
+ break;
+ case OO_PLOT_XYZ_CONTOUR:
+ name = (state->chart.domain_count == 0) ? "Y" : "X";
+ break;
+ case OO_PLOT_SURF:
+ dim = (state->chart.domain_count == 0) ? -1 : GOG_MS_DIM_CATEGORIES;
+ break;
+ default:
dim = GOG_MS_DIM_CATEGORIES;
- oo_plot_assign_dim (xin, src, dim);
+ break;
+ }
+ oo_plot_assign_dim (xin, src, dim, name);
state->chart.domain_count++;
}
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index e62f31d..6186a4e 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3660,6 +3660,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
case ODF_SCATTER_COLOUR:
case ODF_BUBBLE:
case ODF_SURF:
+ case ODF_XYZ_SURF:
odf_write_axis (state, chart, "Y-Axis", "yaxis", "y", gtype);
odf_write_axis (state, chart, "X-Axis", "xaxis", "x", gtype);
odf_write_bubble_series (state, series);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]