[gnumeric] ODF: regression equation position



commit c3cbae9057f206e6b5bd3e3e3c310c62158b39dc
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Aug 27 03:01:28 2010 -0600

    ODF: regression equation position
    
    2010-08-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* developer/odf-foreign.txt: update
    
    2010-08-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_prop_list_free): use go_slist_free_custom
    	(od_style_prop_chart): new attributes
    	(odf_gog_check_position): new
    	(odf_gog_plot_area_check_position): new
    	(oo_plot_area): check position
    	(od_series_reg_equation): ditto
    	* openoffice-write.c (odf_write_gog_position): new
    	(odf_write_gog_plot_area_position): new
    	(odf_write_standard_series): write equation position
    	(odf_write_plot): write plot area size

 doc/ChangeLog                         |    4 +
 doc/developer/odf-foreign.txt         |    5 ++
 plugins/openoffice/ChangeLog          |   13 ++++
 plugins/openoffice/openoffice-read.c  |  115 +++++++++++++++++++++++++++------
 plugins/openoffice/openoffice-write.c |   49 ++++++++++++++
 5 files changed, 165 insertions(+), 21 deletions(-)
---
diff --git a/doc/ChangeLog b/doc/ChangeLog
index b295bf2..0d9d2c3 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* developer/odf-foreign.txt: update
+
 2010-08-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* developer/odf-foreign.txt: update
diff --git a/doc/developer/odf-foreign.txt b/doc/developer/odf-foreign.txt
index feeee1c..620e8f2 100644
--- a/doc/developer/odf-foreign.txt
+++ b/doc/developer/odf-foreign.txt
@@ -82,6 +82,11 @@ whether a given regression is affine or not
 gnm:regression-polynomial-dims
 dimension for a polynomial regression
 
+gnm:is-position-manual
+gnm:position
+gnm:anchor
+position of GogObject
+
 3) Attribute _values_ added by Gnumeric. 
 Since these are not eleemnts or new attributes they are used in all ODF exports.
 
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index e0b0def..aa03b70 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_prop_list_free): use go_slist_free_custom
+	(od_style_prop_chart): new attributes
+	(odf_gog_check_position): new
+	(odf_gog_plot_area_check_position): new
+	(oo_plot_area): check position
+	(od_series_reg_equation): ditto
+	* openoffice-write.c (odf_write_gog_position): new
+	(odf_write_gog_plot_area_position): new
+	(odf_write_standard_series): write equation position
+	(odf_write_plot): write plot area size
+
 2010-08-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (od_series_reg_equation): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index ea2643c..3b605ce 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1,4 +1,4 @@
-/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vm: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
 /*
  * openoffice-read.c : import open/star calc files
@@ -3277,10 +3277,7 @@ oo_prop_free (OOProp *prop)
 static void
 oo_prop_list_free (GSList *props)
 {
-	GSList *ptr;
-	for (ptr = props; NULL != ptr; ptr = ptr->next)
-		oo_prop_free (ptr->data);
-	g_slist_free (props);
+	go_slist_free_custom (props, (GFreeFunc) oo_prop_free);
 }
 
 static void
@@ -3507,13 +3504,15 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		} else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "reverse-direction", &btmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
 				oo_prop_new_bool ("invert-axis", btmp));
-		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "reverse-direction", &btmp)) {
+		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, 
+					 "reverse-direction", &btmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
 				oo_prop_new_bool ("invert-axis", btmp));
 		} else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, 
 					 "vary-style-by-element", &btmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_bool ("vary-style-by-element", btmp));
+				oo_prop_new_bool ("vary-style-by-element", 
+						  btmp));
 		} else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, 
 					 "show-negatives", &btmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
@@ -3537,22 +3536,30 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		} else if (oo_attr_int_range (xin, attrs, OO_NS_CHART, 
 					      "pie-offset", &tmp, 0, 500)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("default-separation", tmp/100.));
-		} else if (oo_attr_percent (xin, attrs, OO_NS_CHART, "hole-size", &ftmp)) {
+				oo_prop_new_float ("default-separation", 
+						   tmp/100.));
+		} else if (oo_attr_percent (xin, attrs, OO_NS_CHART, 
+					    "hole-size", &ftmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
 				oo_prop_new_float ("center-size", ftmp));
 		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, 
 					 "reverse-direction", &btmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
 				oo_prop_new_bool ("invert-axis", btmp));
-		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "stacked", &btmp)) {
+		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "stacked", 
+					 &btmp)) {
 			if (btmp)
-				style->plot_props = g_slist_prepend (style->plot_props,
-					oo_prop_new_string ("type", "stacked"));
-		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "percentage", &btmp)) {
+				style->plot_props = g_slist_prepend 
+					(style->plot_props,
+					 oo_prop_new_string ("type", 
+							     "stacked"));
+		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "percentage",
+					 &btmp)) {
 			if (btmp)
-				style->plot_props = g_slist_prepend (style->plot_props,
-					oo_prop_new_string ("type", "as_percentage"));
+				style->plot_props = g_slist_prepend 
+					(style->plot_props,
+					oo_prop_new_string ("type", 
+							    "as_percentage"));
 		} else if (oo_attr_int_range (xin, attrs, OO_NS_CHART, 
 					      "overlap", &tmp, -150, 150)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
@@ -3570,7 +3577,8 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 			style->series_props = g_slist_prepend
 				(style->series_props,
 				 oo_prop_new_int ("symbol-type", tmp));
-		} else if (oo_attr_enum (xin, attrs, OO_NS_CHART, "symbol-name", 
+		} else if (oo_attr_enum (xin, attrs, OO_NS_CHART, 
+					 "symbol-name", 
 					 named_symbols, &tmp)) {
 			style->series_props = g_slist_prepend
 				(style->series_props,
@@ -3589,8 +3597,8 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 				interpolation = CXML2C(attrs[1]) + 4;
 			else oo_warning 
 				     (xin, _("Unknown interpolation type "
-					     "encountered: %s"), CXML2C(attrs[1]));
-
+					     "encountered: %s"), 
+				      CXML2C(attrs[1]));
 			if (interpolation != NULL) {
 				style->series_props = g_slist_prepend
 					(style->series_props,
@@ -3697,6 +3705,27 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 				       &btmp))
 			style->other_props = g_slist_prepend (style->other_props,
 				oo_prop_new_bool ("regression-affine", btmp));
+		else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, 
+				       "is-position-manual", 
+				       &btmp))
+			style->plot_props = g_slist_prepend
+					(style->plot_props,
+					 oo_prop_new_bool 
+					 ("is-position-manual", btmp));
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					     OO_GNUM_NS_EXT, 
+					     "position"))
+			style->plot_props = g_slist_prepend
+					(style->plot_props,
+					 oo_prop_new_string
+					 ("position", CXML2C(attrs[1])));
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					     OO_GNUM_NS_EXT, 
+					     "anchor"))
+			style->plot_props = g_slist_prepend
+					(style->plot_props,
+					 oo_prop_new_string
+					 ("anchor", CXML2C(attrs[1])));
 
 	}
 
@@ -4433,6 +4462,37 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type, char cons
 }
 
 static void
+odf_gog_check_position (GsfXMLIn *xin, xmlChar const **attrs, GSList **list)
+{
+	gboolean b;
+
+	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+		if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "is-position-manual", &b))
+			*list = g_slist_prepend (*list, oo_prop_new_bool("is-position-manual",
+									 b));
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "position"))
+			*list = g_slist_prepend (*list, oo_prop_new_string ("position", 
+									    CXML2C(attrs[1])));
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "anchor"))
+			*list = g_slist_prepend (*list, oo_prop_new_string ("anchor", 
+									    CXML2C(attrs[1])));
+}
+
+static void
+odf_gog_plot_area_check_position (GsfXMLIn *xin, xmlChar const **attrs, GSList **list)
+{
+	gboolean b;
+
+	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+		if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "is-position-manual", &b))
+			*list = g_slist_prepend (*list, oo_prop_new_bool("is-plot-area-manual",
+									 b));
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "position"))
+			*list = g_slist_prepend (*list, oo_prop_new_string ("plot-area", 
+									    CXML2C(attrs[1])));
+}
+
+static void
 oo_plot_area (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	static OOEnum const labels[] = {
@@ -4449,6 +4509,9 @@ oo_plot_area (GsfXMLIn *xin, xmlChar const **attrs)
 	xmlChar const   *source_range_str = NULL;
 	int label_flags = 0;
 	GSList *l;
+	GSList *prop_list = NULL;
+	
+	odf_gog_plot_area_check_position (xin, attrs, &prop_list);
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
@@ -4565,6 +4628,10 @@ oo_plot_area (GsfXMLIn *xin, xmlChar const **attrs)
 	state->chart.plot = gog_plot_new_by_name (type);
 	gog_object_add_by_name (GOG_OBJECT (state->chart.chart),
 		"Plot", GOG_OBJECT (state->chart.plot));
+
+	oo_prop_list_apply (prop_list, G_OBJECT (state->chart.chart));
+	oo_prop_list_free (prop_list);
+
 	for (l = state->chart.these_plot_styles; l != NULL; l = l->next) {
 		style = l->data;
 		oo_prop_list_apply (style->plot_props, G_OBJECT (state->chart.plot));
@@ -4785,7 +4852,9 @@ od_series_reg_equation (GsfXMLIn *xin, xmlChar const **attrs)
 	gboolean automatic_content = TRUE;
 	gboolean dispay_equation = TRUE;
 	gboolean display_r_square = TRUE;
+	GSList *prop_list = NULL;
 	
+	odf_gog_check_position (xin, attrs, &prop_list);
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "style-name"))
@@ -4800,8 +4869,7 @@ od_series_reg_equation (GsfXMLIn *xin, xmlChar const **attrs)
 				       &dispay_equation));
 		else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "display-r-square", 
 				       &display_r_square));
-		else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "display-r-square", 
-				       &display_r_square));
+
 	
 	equation = gog_object_add_by_name (GOG_OBJECT (state->chart.regression), 
 						     "Equation", NULL);
@@ -4810,7 +4878,10 @@ od_series_reg_equation (GsfXMLIn *xin, xmlChar const **attrs)
 		      "show-eq", dispay_equation, 
 		      "show-r2", display_r_square,
 		      NULL);
-
+	
+	oo_prop_list_apply (prop_list, G_OBJECT (equation));
+	oo_prop_list_free (prop_list);
+	
 	if (!automatic_content)
 		oo_warning (xin, _("Gnumeric does not support non-automatic"
 				   " regression equations. Using automatic"
@@ -4825,6 +4896,8 @@ od_series_reg_equation (GsfXMLIn *xin, xmlChar const **attrs)
 			odf_apply_style_props (chart_style->style_props, style);
 			g_object_unref (style);			
 		}
+		/* In the moment we don't need this. */
+/* 		oo_prop_list_apply (chart_style->plot_props, G_OBJECT (equation)); */
 	}	
 }
 
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 4585a9c..c0ac081 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -683,6 +683,52 @@ odf_write_table_styles (GnmOOExport *state)
 	}
 }
 
+static void
+odf_write_gog_position (GnmOOExport *state, GogObject const *obj)
+{
+	gboolean is_position_manual = TRUE;
+	gchar *position = NULL, *anchor = NULL;
+
+	if (!state->with_extension)
+		return;
+
+	g_object_get (G_OBJECT (obj), 
+		      "is-position-manual", &is_position_manual,
+		      "position", &position,
+		      "anchor", &anchor, 
+		      NULL);
+	odf_add_bool (state->xml, GNMSTYLE "is-position-manual", is_position_manual);
+	if (is_position_manual) {
+		if (position)
+			gsf_xml_out_add_cstr (state->xml, GNMSTYLE "position", position);
+		if (anchor)
+			gsf_xml_out_add_cstr (state->xml, GNMSTYLE "anchor", anchor);
+	}
+
+	g_free (position);
+	g_free (anchor);
+}
+
+static void
+odf_write_gog_plot_area_position (GnmOOExport *state, GogObject const *obj)
+{
+	gboolean is_position_manual = TRUE;
+	gchar *position = NULL;
+
+	if (!state->with_extension)
+		return;
+
+	g_object_get (G_OBJECT (obj), 
+		      "is-plot-area-manual", &is_position_manual,
+		      "plot-area", &position,
+		      NULL);
+	odf_add_bool (state->xml, GNMSTYLE "is-position-manual", is_position_manual);
+	if (is_position_manual && position)
+			gsf_xml_out_add_cstr (state->xml, GNMSTYLE "position", position);
+
+	g_free (position);
+}
+
 static char *
 odf_get_border_format (GnmBorder   *border)
 {
@@ -3720,6 +3766,7 @@ odf_write_standard_series (GnmOOExport *state, GSList const *series)
 							str = odf_get_gog_style_name_from_obj 
 								(GOG_OBJECT (equation));
 							gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
+							odf_write_gog_position (state, equation);
 							gsf_xml_out_end_element (state->xml); /* </chart:equation> */
 						}
 
@@ -4859,6 +4906,8 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 		}
 	}
 
+	odf_write_gog_plot_area_position (state, chart);
+
 	if (this_plot->odf_write_z_axis)
 		this_plot->odf_write_z_axis 
 			(state, chart, this_plot->z_axis_name, z_style, "z", 



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