[goffice] Fix color scale reference to its axis. [#766829]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fix color scale reference to its axis. [#766829]
- Date: Thu, 26 May 2016 13:06:42 +0000 (UTC)
commit 7ea91bb1e08cd24a6efebbac6fed818feb2e7770
Author: Jean Brefort <jean brefort normalesup org>
Date: Thu May 26 15:06:20 2016 +0200
Fix color scale reference to its axis. [#766829]
ChangeLog | 6 +++++
NEWS | 3 ++
goffice/graph/gog-color-scale.c | 44 +++++++++++++++++++++++++++++---------
3 files changed, 42 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6e51000..3dc9ee2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-26 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-color-scale.c (gog_color_scale_set_property),
+ (gog_color_scale_get_property): properly save and load the reference to
+ the axis. [#766829]
+
2016-05-06 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index 2022bde..13d3eae 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.10.30:
+Jean:
+ * Fix color scale reference to its axis. [#766829]
+
--------------------------------------------------------------------------
goffice 0.10.29:
diff --git a/goffice/graph/gog-color-scale.c b/goffice/graph/gog-color-scale.c
index 717376d..32275be 100644
--- a/goffice/graph/gog-color-scale.c
+++ b/goffice/graph/gog-color-scale.c
@@ -241,20 +241,36 @@ gog_color_scale_set_property (GObject *obj, guint param_id,
GogChart *chart = GOG_CHART (gog_object_get_parent (GOG_OBJECT (obj)));
GSList *ptr;
char const *buf = g_value_get_string (value);
+ GogAxisType type;
+ int id;
GogAxis *axis = NULL;
- for (ptr = gog_chart_get_axes (chart, GOG_AXIS_COLOR); ptr && ptr->data; ptr = ptr->next) {
- if (!strcmp (buf, gog_object_get_name (GOG_OBJECT (ptr->data)))) {
+ if (!strncmp (buf, "color", 5)) {
+ type = GOG_AXIS_COLOR;
+ buf += 5;
+ } else if (!strncmp (buf, "3d", 2)) {
+ type = GOG_AXIS_PSEUDO_3D;
+ buf += 2;
+ } else {
+ unsigned index;
+ /* kludge: old file searching for 3D in all known locales */
+ type = (strstr (buf, "3D") != NULL || strstr (buf , "3d") !=NULL ||
+ strstr (buf, "3Д") != NULL || strstr (buf, "3Δ") != NULL ||
+ strstr (buf, "ترويسات متعلقة بالمحور") != NULL)?
+ GOG_AXIS_PSEUDO_3D: GOG_AXIS_COLOR;
+ index = strlen (buf) - 1;
+ while (index > 0 && buf[index] <= '9' && buf[index] >= '0')
+ index--;
+ buf += index + 1;
+ }
+ id = atoi (buf);
+ if (id < 1) /* this should not happen */
+ id = 1;
+ for (ptr = gog_chart_get_axes (chart, type); ptr && ptr->data; ptr = ptr->next) {
+ if ((unsigned ) id == gog_object_get_id (GOG_OBJECT (ptr->data))) {
axis = GOG_AXIS (ptr->data);
break;
}
}
- if (axis == NULL) /* try with the pseudo-3d axes */
- for (ptr = gog_chart_get_axes (chart, GOG_AXIS_PSEUDO_3D); ptr && ptr->data; ptr =
ptr->next) {
- if (!strcmp (buf, gog_object_get_name (GOG_OBJECT (ptr->data)))) {
- axis = GOG_AXIS (ptr->data);
- break;
- }
- }
gog_color_scale_set_axis (scale, axis);
break;
}
@@ -282,9 +298,15 @@ gog_color_scale_get_property (GObject *obj, guint param_id,
case COLOR_SCALE_PROP_WIDTH:
g_value_set_double (value, scale->width);
break;
- case COLOR_SCALE_PROP_AXIS:
- g_value_set_string (value, gog_object_get_name (GOG_OBJECT (scale->color_axis)));
+ case COLOR_SCALE_PROP_AXIS: {
+ char buf[16];
+ if (gog_axis_get_atype (scale->color_axis) == GOG_AXIS_COLOR)
+ snprintf (buf, 16, "color%u", gog_object_get_id (GOG_OBJECT (scale->color_axis)));
+ else
+ snprintf (buf, 16, "3d%u", gog_object_get_id (GOG_OBJECT (scale->color_axis)));
+ g_value_set_string (value, buf);
break;
+ }
case COLOR_SCALE_PROP_TICK_SIZE_PTS:
g_value_set_int (value, scale->tick_size);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]