[gnumeric] Read and write tick spacing from/to ODF files.



commit ef5864e0e83dd59f6cbbb92e00339672a4745684
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Sep 6 00:33:55 2011 -0600

    Read and write tick spacing from/to ODF files.
    
    2011-09-06  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_prop_list_apply_to_axis): handle
    	tick spacing, add argument and change caller
    	(od_style_prop_chart): read tick spacing
    	* openoffice-write.c (odf_write_axis_style): write tick spacing

 NEWS                                  |    4 ++-
 plugins/openoffice/ChangeLog          |    7 ++++++
 plugins/openoffice/openoffice-read.c  |   38 +++++++++++++++++++++++++++++++-
 plugins/openoffice/openoffice-write.c |   30 ++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index d15a05b..32d3100 100644
--- a/NEWS
+++ b/NEWS
@@ -13,9 +13,11 @@ Andreas:
 	* Add HPFILTER function calculating the Hodrick Prescott Filter.
 	* Fix saving of newlines to xls. [#356711]
 	* Enable markup selection in scientific format selector.
-	* Be compatible wih the changed LibreOffice ODF documents with tab colours.
+	* Be compatible wih the changed LibreOffice ODF documents with tab 
+	colours.
 	* Persist selection and edit positions through ODF files. [#657506]
 	* Some more number formatting improvements to ODF import/export.
+	* Read and write tick spacing from/to ODF files.
 
 Jean:
 	* Make things build against gtk+-3.0.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 013aaac..bd203a0 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-06  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_prop_list_apply_to_axis): handle
+	tick spacing, add argument and change caller
+	(od_style_prop_chart): read tick spacing
+	* openoffice-write.c (odf_write_axis_style): write tick spacing
+
 2011-09-04  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (odf_fraction): read pi-fraction foreign
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 77ecd60..d1531f6 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -5573,12 +5573,15 @@ oo_prop_list_apply (GSList *props, GObject *obj)
 }
 
 static void
-oo_prop_list_apply_to_axis (GSList *props, GObject *obj)
+oo_prop_list_apply_to_axis (OOParseState *state, GSList *props, GObject *obj)
 {
 	GSList *ptr;
 	OOProp *prop;
+	GOData *data;
 
 	double minimum = go_ninf, maximum = go_pinf;
+	double interval_major = 0.;
+	double interval_minor_divisor = 0.;
 
 	oo_prop_list_apply (props, obj);
 
@@ -5588,9 +5591,30 @@ oo_prop_list_apply_to_axis (GSList *props, GObject *obj)
 			minimum = g_value_get_double (&prop->value);
 		else if (0 == strcmp ("maximum", prop->name))
 			maximum = g_value_get_double (&prop->value);
+		else if (0 == strcmp ("interval-major", prop->name))
+			interval_major = g_value_get_double (&prop->value);
+		else if (0 == strcmp ("interval-minor-divisor", prop->name))
+			interval_minor_divisor 
+				= g_value_get_double (&prop->value);
+		
 	}
 
 	gog_axis_set_bounds (GOG_AXIS (obj), minimum, maximum);
+
+	if (interval_major > 0) {
+		data = gnm_go_data_scalar_new_expr
+			(state->chart.src_sheet, gnm_expr_top_new_constant
+			 (value_new_float(interval_major)));
+		gog_dataset_set_dim (GOG_DATASET (obj), 2, data, NULL);
+		if (interval_minor_divisor > 0) {
+			data = gnm_go_data_scalar_new_expr
+				(state->chart.src_sheet, 
+				 gnm_expr_top_new_constant 
+				 (value_new_float (interval_major/
+						   interval_minor_divisor)));
+			gog_dataset_set_dim (GOG_DATASET (obj), 3, data, NULL);
+		}
+	}
 }
 
 static void
@@ -5752,6 +5776,16 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 					  "maximum", &ftmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
 				oo_prop_new_double ("maximum", ftmp));
+		} else if (oo_attr_float (xin, attrs, OO_NS_CHART,
+					  "interval-major", &ftmp)) {
+			style->axis_props = g_slist_prepend (style->axis_props,
+				oo_prop_new_double ("interval-major", ftmp));
+		} else if (oo_attr_float (xin, attrs, OO_NS_CHART,
+					  "interval-minor-divisor", &ftmp)) {
+			style->axis_props = g_slist_prepend 
+				(style->axis_props,
+				 oo_prop_new_double ("interval-minor-divisor", 
+						     ftmp));
 		} else if (oo_attr_float (xin, attrs, OO_GNUM_NS_EXT,
 					  "radius-ratio", &ftmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
@@ -6946,7 +6980,7 @@ oo_chart_axis (GsfXMLIn *xin, xmlChar const **attrs)
 			GOStyle *gostyle;
 			g_object_get (G_OBJECT (state->chart.axis), "style", &gostyle, NULL);
 
-			oo_prop_list_apply_to_axis (style->axis_props,
+			oo_prop_list_apply_to_axis (state, style->axis_props,
 						    G_OBJECT (state->chart.axis));
 			odf_apply_style_props (xin, style->style_props, gostyle);
 			g_object_unref (gostyle);
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 4cd9443..c0a5d24 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -6217,6 +6217,7 @@ odf_write_axis_style (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
 	double minima = 0., maxima = 0.;
 	GObjectClass *klass = G_OBJECT_GET_CLASS (axis);
 	GParamSpec *spec;
+	GOData const *interval;
 
 	gsf_xml_out_add_cstr (state->xml, CHART "axis-position", "start");
 	odf_add_bool (state->xml, CHART "display-label", TRUE);
@@ -6233,6 +6234,35 @@ odf_write_axis_style (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
 		gsf_xml_out_add_float (state->xml, CHART "maximum", maxima, -1);
 	}
 
+
+	interval = gog_dataset_get_dim (GOG_DATASET(axis),2);
+	if (interval != NULL) {
+		GnmExprTop const *texpr
+			= gnm_go_data_get_expr (interval);
+		if (texpr != NULL &&
+		    GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_CONSTANT) {
+			double val = value_get_as_float 
+				(texpr->expr->constant.value);
+			gsf_xml_out_add_float 
+				(state->xml, 
+				 CHART "interval-major", val, -1);
+
+			interval = gog_dataset_get_dim (GOG_DATASET(axis),3);
+			if (interval != NULL) {
+				texpr = gnm_go_data_get_expr (interval);
+				if (texpr != NULL &&
+				    GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_CONSTANT) {
+					double val_minor = value_get_as_float 
+						(texpr->expr->constant.value);
+					if (val_minor > 0)
+						gsf_xml_out_add_float
+							(state->xml, 
+							 CHART "interval-minor-divisor", 
+							 val/val_minor, 0);
+				}
+			}
+		}
+	}
 	if (get_gsf_odf_version () > 101)
 		odf_write_plot_style_bool
 			(state->xml, axis, klass,



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