[gnumeric] Use chart:three-dimensional in ODF import/export



commit db1be20cd102524e029a1464e56533710918df93
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri Jul 31 01:31:48 2009 -0600

    Use chart:three-dimensional in ODF import/export
    
    2009-07-31 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_surface_chart_style): new
    	(odf_write_contour_chart_style): new
    	(odf_write_plot): hook-up above functions and drop
    	  gnm:xyz-surface & gnm:surface
    	* openoffice-read.c (OOChartStyle): add new field
    	(oo_style): initialize new field
    	(oo_chart_style_free): free new field
    	(oo_prop_list_has_three_dimensional): new
    	(oo_style_have_three_dimensional): new
    	(od_style_prop_chart): read chart:three-dimensional
    	(oo_plot_area): handle chart:three-dimensional spec
    	(oo_chart): drop unneeded gnm:xyz-surface & gnm:surface

 plugins/openoffice/ChangeLog          |   15 ++++++++++
 plugins/openoffice/openoffice-read.c  |   48 ++++++++++++++++++++++++++++++---
 plugins/openoffice/openoffice-write.c |   24 ++++++++++++----
 3 files changed, 77 insertions(+), 10 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 7e08ebf..c138380 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,18 @@
+2009-07-31 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-write.c (odf_write_surface_chart_style): new
+	(odf_write_contour_chart_style): new
+	(odf_write_plot): hook-up above functions and drop
+	  gnm:xyz-surface & gnm:surface
+	* openoffice-read.c (OOChartStyle): add new field
+	(oo_style): initialize new field
+	(oo_chart_style_free): free new field
+	(oo_prop_list_has_three_dimensional): new
+	(oo_style_have_three_dimensional): new
+	(od_style_prop_chart): read chart:three-dimensional
+	(oo_plot_area): handle chart:three-dimensional spec
+	(oo_chart): drop unneeded gnm:xyz-surface & gnm:surface
+
 2009-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-write.c (odf_write_series): renamed to
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 26c326a..ff92ad7 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -153,6 +153,7 @@ typedef struct {
 	gboolean src_in_rows;	/* orientation of graph data: rows or columns */
 	GSList	*axis_props;	/* axis properties */
 	GSList	*plot_props;	/* plot properties */
+	GSList	*other_props;	/* any other properties */
 } OOChartStyle;
 
 typedef struct {
@@ -1556,6 +1557,7 @@ oo_style (GsfXMLIn *xin, xmlChar const **attrs)
 			cur_style = g_new0(OOChartStyle, 1);
 			cur_style->axis_props = NULL;
 			cur_style->plot_props = NULL;
+			cur_style->other_props = NULL;
 			state->chart.cur_graph_style = cur_style;
 			g_hash_table_replace (state->chart.graph_styles,
 					      g_strdup (name),
@@ -2878,6 +2880,30 @@ oo_prop_list_apply (GSList *props, GObject *obj)
 }
 
 static void
+oo_prop_list_has_three_dimensional (GSList *props, gboolean *threed)
+{
+	GSList *ptr;
+	for (ptr = props; ptr; ptr = ptr->next) {
+		OOProp *prop = ptr->data;
+		if (0 == strcmp (prop->name, "three-dimensional") && g_value_get_boolean (&prop->value))
+			*threed = TRUE;
+	}
+}
+
+static gboolean
+oo_style_have_three_dimensional (GSList *styles)
+{
+	GSList *l;
+	gboolean is_three_dimensional = FALSE;
+	for (l = styles; l != NULL; l = l->next) { 
+		OOChartStyle *style = l->data;
+		oo_prop_list_has_three_dimensional (style->other_props, 
+						    &is_three_dimensional);
+	}
+	return is_three_dimensional;
+}
+
+static void
 od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
@@ -2933,6 +2959,9 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 			default_style_has_lines_set = TRUE;
 		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "series-source"))
 			style->src_in_rows = attr_eq (attrs[1], "rows");
+		else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "three-dimensional", &btmp))
+			style->other_props = g_slist_prepend (style->other_props,
+				oo_prop_new_bool ("three-dimensional", btmp));
 	}
 
 	if (draw_stroke_set && !default_style_has_lines_set)
@@ -3514,11 +3543,23 @@ 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_CONTOUR:	type = "GogContourPlot"; break;
+	case OO_PLOT_CONTOUR:
+		if (oo_style_have_three_dimensional (state->chart.these_plot_styles)) {
+			type = "GogSurfacePlot";
+			state->chart.plot_type = OO_PLOT_SURFACE;
+		} else 
+			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_XYZ_CONTOUR: 
+		if (oo_style_have_three_dimensional (state->chart.these_plot_styles)) {
+			type = "GogXYZSurfacePlot";
+			state->chart.plot_type = OO_PLOT_XYZ_SURFACE;
+		} else 
+			type = "GogXYZContourPlot"; 
+		break;
 	case OO_PLOT_XYZ_SURFACE: type = "GogXYZSurfacePlot"; break;
 	case OO_PLOT_SURFACE: type = "GogSurfacePlot"; break;
 	case OO_PLOT_SCATTER_COLOUR: type = "GogXYColorPlot";	break;
@@ -3731,8 +3772,6 @@ oo_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		{ "chart:surface",	OO_PLOT_CONTOUR },
 		{ "gnm:polar",  	OO_PLOT_POLAR },
 		{ "gnm:xyz-contour", 	OO_PLOT_XYZ_CONTOUR },
-		{ "gnm:xyz-surface", 	OO_PLOT_XYZ_SURFACE },
-		{ "gnm:surface", 	OO_PLOT_SURFACE },
 		{ "gnm:scatter-color", 	OO_PLOT_SCATTER_COLOUR },
 		{ NULL,	0 },
 	};
@@ -3833,6 +3872,7 @@ oo_chart_style_free (OOChartStyle *cstyle)
 {
 	oo_prop_list_free (cstyle->axis_props);
 	oo_prop_list_free (cstyle->plot_props);
+	oo_prop_list_free (cstyle->other_props);
 	g_free (cstyle);
 }
 
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 84fc313..f700aab 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3371,6 +3371,18 @@ odf_write_scatter_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const
 }
 
 static void
+odf_write_surface_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const *chart, G_GNUC_UNUSED GogObject const *plot)
+{
+	odf_add_bool (state->xml, CHART "three-dimensional", TRUE);
+}
+
+static void
+odf_write_contour_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const *chart, G_GNUC_UNUSED GogObject const *plot)
+{
+	odf_add_bool (state->xml, CHART "three-dimensional", FALSE);
+}
+
+static void
 odf_write_scatter_series_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const *series)
 {
 	gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
@@ -3539,16 +3551,16 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 		  odf_write_scatter_chart_style, NULL, odf_write_standard_series, odf_write_scatter_series_style},
 		{ "GogContourPlot", "chart:surface", ODF_SURF,
 		  20., "X-Axis", "Y-Axis", NULL, odf_write_standard_axes_styles,
-		  NULL, NULL, odf_write_bubble_series, NULL},
-		{ "GogXYZContourPlot", "gnm:xyz-contour", ODF_XYZ_SURF,
+		  odf_write_contour_chart_style, NULL, odf_write_bubble_series, NULL},
+		{ "GogXYZContourPlot", "gnm:xyz-surface", ODF_XYZ_SURF,
 		  20., "X-Axis", "Y-Axis", NULL, odf_write_standard_axes_styles,
-		  NULL, NULL, odf_write_bubble_series, NULL},
+		  odf_write_contour_chart_style, NULL, odf_write_bubble_series, NULL},
 		{ "GogXYZSurfacePlot", "gnm:xyz-surface", ODF_XYZ_GNM_SURF,
 		  20., "X-Axis", "Y-Axis", "Z-Axis", odf_write_surface_axes_styles,
-		  NULL, NULL, odf_write_bubble_series, NULL},
-		{ "GogSurfacePlot", "gnm:surface", ODF_GNM_SURF,
+		  odf_write_surface_chart_style, NULL, odf_write_bubble_series, NULL},
+		{ "GogSurfacePlot", "chart:surface", ODF_GNM_SURF,
 		  20., "X-Axis", "Y-Axis", "Z-Axis", odf_write_surface_axes_styles,
-		  NULL, NULL, odf_write_bubble_series, NULL},
+		  odf_write_surface_chart_style, NULL, odf_write_bubble_series, NULL},
 		{ "GogBubblePlot", "chart:bubble", ODF_BUBBLE,
 		  20., "X-Axis", "Y-Axis", NULL, odf_write_standard_axes_styles,
 		  NULL, NULL, odf_write_bubble_series, NULL},



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