[gnumeric] Handle contour plots in ODF export and import



commit 7155952a1f5b5f890bab30ce52a7c5ee60be4202
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Jul 16 23:34:42 2009 -0600

    Handle contour plots in ODF export and import
    
     2009-07-16 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_plot_assign_dim): allow for
    	  dim_type pass through.
    	(oo_plot_series): handle contour matrix
    	(oo_plot_series_end): we are already done for OO_PLOT_SURF
    	(oo_series_domain): handle OO_PLOT_SURF
    	* openoffice-write.c (odf_write_plot): handle ODF_SURF

 plugins/openoffice/ChangeLog          |    9 +++++
 plugins/openoffice/openoffice-read.c  |   61 +++++++++++++++++++++++++-------
 plugins/openoffice/openoffice-write.c |    1 +
 3 files changed, 57 insertions(+), 14 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 587468f..6ce35a0 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
 2009-07-16 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (oo_plot_assign_dim): allow for 
+	  dim_type pass through.
+	(oo_plot_series): handle contour matrix
+	(oo_plot_series_end): we are already done for OO_PLOT_SURF
+	(oo_series_domain): handle OO_PLOT_SURF
+	* openoffice-write.c (odf_write_plot): handle ODF_SURF
+
+2009-07-16 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (oo_plot_area): set up series handling for 
 	  Stock plot
 	(oo_plot_area_end): handle stock plot series
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index b41b0ec..6d4df05 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3359,7 +3359,7 @@ gog_series_map_dim (GogSeries const *series, GogMSDimType ms_type)
 }
 /* If range == %NULL use an implicit range */
 static void
-oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, GogMSDimType dim_type)
+oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
 
@@ -3371,7 +3371,10 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, GogMSDimType dim_type)
 
 	if (NULL == state->chart.series)
 		return;
-	dim = gog_series_map_dim (state->chart.series, dim_type);
+	if (dim_type < 0)
+		dim = - (1 + dim_type);
+	else
+		dim = gog_series_map_dim (state->chart.series, dim_type);
 	if (dim < -1)
 		return;
 
@@ -3569,20 +3572,38 @@ oo_plot_series (GsfXMLIn *xin, xmlChar const **attrs)
 	g_print ("<<<<< Start\n");
 #endif
 	state->chart.series_count++; 
+	state->chart.domain_count = 0;
 
-	if (state->chart.plot_type == OO_PLOT_STOCK) {
+	switch (state->chart.plot_type) {
+	case OO_PLOT_STOCK:
 		for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 			if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "values-cell-range-address"))
 				state->chart.stock_series = g_slist_append (state->chart.stock_series, 
 									    g_strdup (attrs[1]));
-	} else {
+		break;
+	case OO_PLOT_SURF:
+		state->chart.series = gog_plot_new_series (state->chart.plot);
+		for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+			if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "values-cell-range-address")) {
+				GnmRangeRef ref;
+				GnmValue *v;
+				GnmExprTop const *texpr;
+				GnmParsePos pp;
+				char const *ptr = oo_rangeref_parse (&ref, CXML2C (attrs[1]),
+								     parse_pos_init_sheet (&pp, state->pos.sheet));
+				if (ptr == CXML2C (attrs[1]))
+					return;
+				v = value_new_cellrange (&ref.a, &ref.b, 0, 0);
+				texpr = gnm_expr_top_new_constant (v);
+				if (NULL != texpr)
+					gog_series_set_dim (state->chart.series, 2,
+							    gnm_go_data_matrix_new_expr (state->pos.sheet, texpr), NULL);
+			}
+	default:
 		if (state->chart.series == NULL)
 			state->chart.series = gog_plot_new_series (state->chart.plot);
-		state->chart.domain_count = 0;
 		for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
-			if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "style"))
-				;
-			else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "values-cell-range-address")) {
+			if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "values-cell-range-address")) {
 				int dim;
 				switch (state->chart.plot_type) {
 				case OO_PLOT_GANTT:
@@ -3598,6 +3619,7 @@ oo_plot_series (GsfXMLIn *xin, xmlChar const **attrs)
 				oo_plot_assign_dim (xin, attrs[1], dim);
 			} 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);
+		break;
 	}
 }
 
@@ -3608,6 +3630,7 @@ oo_plot_series_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 	
 	switch (state->chart.plot_type) {
 	case OO_PLOT_STOCK:
+	case OO_PLOT_SURF:
 		break;
 	case OO_PLOT_GANTT:
 		if ((state->chart.series_count % 2) != 0)
@@ -3628,16 +3651,26 @@ oo_series_domain (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
 	xmlChar const *src = NULL;
+	int dim;
 
 	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.plot_type == OO_PLOT_BUBBLE && (state->chart.domain_count == 0))
-		oo_plot_assign_dim (xin, src, GOG_MS_DIM_VALUES);
-	else
-		oo_plot_assign_dim (xin, src, GOG_MS_DIM_CATEGORIES);
-
+	if (state->chart.domain_count == 0)
+		switch (state->chart.plot_type) {
+		case OO_PLOT_BUBBLE:
+			dim = GOG_MS_DIM_VALUES;
+			break;
+		case OO_PLOT_SURF:
+			dim = -1;
+			break;
+		default:
+			dim = GOG_MS_DIM_CATEGORIES;
+			break;
+		}
+	else 
+		dim = GOG_MS_DIM_CATEGORIES;
+	oo_plot_assign_dim (xin, src, dim);
 	state->chart.domain_count++;
 }
 
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 05accf0..8b35296 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3656,6 +3656,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 		odf_write_series (state, series);
 		break;
 	case ODF_BUBBLE:
+	case ODF_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]