gnumeric r16527 - in trunk: . src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16527 - in trunk: . src
- Date: Mon, 28 Apr 2008 18:00:42 +0100 (BST)
Author: mortenw
Date: Mon Apr 28 17:00:41 2008
New Revision: 16527
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16527&view=rev
Log:
2008-04-28 Morten Welinder <terra gnome org>
* src/wbc-gtk-actions.c (cb_calc_decs): Use rendered value, if
available.
Modified:
trunk/ChangeLog
trunk/src/wbc-gtk-actions.c
Modified: trunk/src/wbc-gtk-actions.c
==============================================================================
--- trunk/src/wbc-gtk-actions.c (original)
+++ trunk/src/wbc-gtk-actions.c Mon Apr 28 17:00:41 2008
@@ -67,6 +67,7 @@
#include <goffice/graph/gog-data-allocator.h>
#include <goffice/graph/gog-data-set.h>
#include <goffice/utils/go-file.h>
+#include <goffice/utils/go-locale.h>
#include <goffice/utils/go-glib-extras.h>
#include "widgets/widget-editable-label.h"
@@ -1382,28 +1383,33 @@
{
int *pdecs = user;
int decs = 0;
- GnmCell const *cell = iter->cell;
- gnm_float f;
- gnm_float eps = 1e-6;
+ GnmCell *cell = iter->cell;
+ char *text;
+ const char *p;
+ GString const *dec = go_locale_get_decimal ();
if (!cell || !cell->value || !VALUE_IS_NUMBER (cell->value))
return NULL;
- f = gnm_abs (value_get_as_float (cell->value));
- if (*pdecs > 0) {
- decs = *pdecs;
- f *= gnm_pow10 (decs);
- }
+ /*
+ * If we are displaying an equation, we don't want to look into
+ * the rendered text.
+ */
+ if (gnm_cell_has_expr (cell) && cell->base.sheet->display_formulas)
+ return NULL;
- while (decs < 8) {
- f -= gnm_floor (f);
- if (f < eps || f > 1 - eps)
- break;
- f *= 10;
- decs++;
+ text = gnm_cell_get_rendered_text (cell);
+ p = strstr (text, dec->str);
+ if (p) {
+ p += dec->len;
+
+ while (g_ascii_isdigit (*p))
+ decs++, p++;
}
- *pdecs = decs;
+ *pdecs = MAX (*pdecs, decs);
+
+ g_free (text);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]