[gnumeric] Export & import GogXYColorPlot to and from ODF



commit 0770e5a4b7163581c41e7f25ef2152ef83ffba36
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Jul 22 00:23:31 2009 -0600

    Export & import GogXYColorPlot to and from ODF
    
    2009-07-22 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_plot_series): handle OO_PLOT_SCATTER_COLOUR
    	(oo_series_domain): ditto
    	(oo_chart): ditto
    	* openoffice-write.c (odf_write_bubble_series): write all series
    	(odf_write_plot): handle GogXYColorPlot/ODF_SCATTER_COLOUR

 plugins/openoffice/ChangeLog          |    8 ++++++
 plugins/openoffice/openoffice-read.c  |    9 ++++++-
 plugins/openoffice/openoffice-write.c |   43 +++++++++++++++++---------------
 3 files changed, 39 insertions(+), 21 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 6ce35a0..5d0d1e5 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_plot_series): handle OO_PLOT_SCATTER_COLOUR
+	(oo_series_domain): ditto
+	(oo_chart): ditto
+	* openoffice-write.c (odf_write_bubble_series): write all series
+	(odf_write_plot): handle GogXYColorPlot/ODF_SCATTER_COLOUR
+
 2009-07-16 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (oo_plot_assign_dim): allow for 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 6d4df05..9f8bbe8 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -125,6 +125,7 @@ typedef enum {
 	OO_PLOT_GANTT,
 	OO_PLOT_POLAR,
 	OO_PLOT_XYZ_CONTOUR,
+	OO_PLOT_SCATTER_COLOUR,
 	OO_PLOT_UNKNOWN
 } OOPlotType;
 
@@ -3495,11 +3496,12 @@ oo_plot_area (GsfXMLIn *xin, xmlChar const **attrs)
 	case OO_PLOT_RING:	type = "GogRingPlot";	break;
 	case OO_PLOT_SCATTER:	type = "GogXYPlot";	break;
 	case OO_PLOT_STOCK:	type = "GogMinMaxPlot";	break;  /* This is not quite right! */
-	case OO_PLOT_SURF:	type = "GogContourPlot"; break; /* This might not be right!? */
+	case OO_PLOT_SURF:	type = "GogContourPlot"; break;
 	case OO_PLOT_BUBBLE:	type = "GogBubblePlot"; break;
 	case OO_PLOT_GANTT:	type = "GogDropBarPlot"; break;
 	case OO_PLOT_POLAR:	type = "GogPolarPlot"; break;
 	case OO_PLOT_XYZ_CONTOUR: type = "GogXYZContourPlot"; break;
+	case OO_PLOT_SCATTER_COLOUR: type = "GogXYColorPlot";	break;
 	default: return;
 	}
 
@@ -3612,6 +3614,9 @@ oo_plot_series (GsfXMLIn *xin, xmlChar const **attrs)
 				case OO_PLOT_BUBBLE:
 					dim = GOG_MS_DIM_BUBBLES;
 					break;
+				case OO_PLOT_SCATTER_COLOUR:
+					dim = GOG_MS_DIM_EXTRA1;
+					break;
 				default:
 					dim = GOG_MS_DIM_VALUES;
 					break;
@@ -3659,6 +3664,7 @@ oo_series_domain (GsfXMLIn *xin, xmlChar const **attrs)
 	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:
@@ -3701,6 +3707,7 @@ oo_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		{ "chart:surface",	OO_PLOT_SURF },
 		{ "gnm:polar",  	OO_PLOT_POLAR },
 		{ "gnm:xyz-contour", 	OO_PLOT_XYZ_CONTOUR },
+		{ "gnm:scatter-color", 	OO_PLOT_SCATTER_COLOUR },
 		{ NULL,	0 },
 	};
 	OOParseState *state = (OOParseState *)xin->user_state;
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 8b35296..e62f31d 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3171,6 +3171,7 @@ typedef enum {
 	ODF_SURF,
 	ODF_XYZ_SURF,
 	ODF_BUBBLE,
+	ODF_SCATTER_COLOUR,
 	ODF_POLAR
 } odf_chart_type_t; 
 
@@ -3269,11 +3270,10 @@ static void
 odf_write_bubble_series (GnmOOExport *state, GSList const *orig_series)
 {
 	GnmParsePos pp;
-	int i;
+	int i, j;
 	GSList const *series;
 	parse_pos_init (&pp, WORKBOOK (state->wb), NULL, 0,0 );
 
-	gsf_xml_out_start_element (state->xml, CHART "series");
 	for (series = orig_series, i = 1; NULL != series; series = series->next, i++) {
 		GOData const *dat = gog_dataset_get_dim (GOG_DATASET (series->data), 2);
 
@@ -3281,33 +3281,31 @@ odf_write_bubble_series (GnmOOExport *state, GSList const *orig_series)
 			GnmExprTop const *texpr = gnm_go_data_get_expr (dat);
 			if (NULL != texpr) {
 				char *str = gnm_expr_top_as_string (texpr, &pp, state->conv);
+				gsf_xml_out_start_element (state->xml, CHART "series");
 				gsf_xml_out_add_cstr (state->xml, CHART "values-cell-range-address",
 						      odf_strip_brackets (str));
 				g_free (str);
 				str = g_strdup_printf ("series%i", i);
 				gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
 				g_free (str);
-				break;
-			}
-		}
-	}
-	for (i = 1; i >= 0; i--) 
-		for (series = orig_series; NULL != series ; series = series->next) {
-			GOData const *dat = gog_dataset_get_dim (GOG_DATASET (series->data), i);
-			if (NULL != dat) {
-				GnmExprTop const *texpr = gnm_go_data_get_expr (dat);
-				if (NULL != texpr) {
-					char *str = gnm_expr_top_as_string (texpr, &pp, state->conv);
-					gsf_xml_out_start_element (state->xml, CHART "domain");
-					gsf_xml_out_add_cstr (state->xml, TABLE "cell-range-address", 
-							      odf_strip_brackets (str));
-					gsf_xml_out_end_element (state->xml); /* </chart:domain> */
-					g_free (str);
-					break;
+				for (j = 1; j >= 0; j--) {
+					dat = gog_dataset_get_dim (GOG_DATASET (series->data), j);
+					if (NULL != dat) {
+						texpr = gnm_go_data_get_expr (dat);
+						if (NULL != texpr) {
+							str = gnm_expr_top_as_string (texpr, &pp, state->conv);
+							gsf_xml_out_start_element (state->xml, CHART "domain");
+							gsf_xml_out_add_cstr (state->xml, TABLE "cell-range-address", 
+									      odf_strip_brackets (str));
+							gsf_xml_out_end_element (state->xml); /* </chart:domain> */
+							g_free (str);
+						}
+					}
 				}
 			}
+			gsf_xml_out_end_element (state->xml); /* </chart:series> */
 		}
-	gsf_xml_out_end_element (state->xml); /* </chart:series> */
+	}
 }
 
 static void
@@ -3521,6 +3519,10 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 		gtype = ODF_BUBBLE;
 		odf_plot_type = "chart:bubble";
 		pad = 20.;
+	} else if (0 == strcmp (plot_type, "GogXYColorPlot")) {
+		gtype = ODF_SCATTER_COLOUR;
+		odf_plot_type = "gnm:scatter-color";
+		pad = 20.;
 	} else {
 		g_print ("encountered unknown chart type %s\n", plot_type);
 		gtype = ODF_BARCOL;
@@ -3655,6 +3657,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 		odf_write_axis (state, chart, "Circular-Axis", "xaxis", "x", gtype);
 		odf_write_series (state, series);
 		break;
+	case ODF_SCATTER_COLOUR:
 	case ODF_BUBBLE:
 	case ODF_SURF:
 		odf_write_axis (state, chart, "Y-Axis", "yaxis", "y", gtype);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]