[goffice] permit 0 denominator digits
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] permit 0 denominator digits
- Date: Sat, 27 Aug 2011 07:13:25 +0000 (UTC)
commit 4688b73f244f48283a9e203c6d786bb8550af0d5
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sat Aug 27 01:12:48 2011 -0600
permit 0 denominator digits
2011-08-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (GOFormatOp): add ops
(go_format_parse_number_fraction): create more program steps for fractions
(go_format_dump_program): handle new ops
(go_format_execute): ditto
* goffice/gtk/go-format-sel.ui: change spin button bounds
* goffice/gtk/go-format-sel.c (cb_max_denom_digits_changed): permit
0 denominator digits
ChangeLog | 10 ++++++++
goffice/gtk/go-format-sel.c | 2 +-
goffice/gtk/go-format-sel.ui | 1 -
goffice/utils/go-format.c | 50 +++++++++++++++++++++++++++--------------
4 files changed, 44 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 19b6927..d53184f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-08-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * goffice/utils/go-format.c (GOFormatOp): add ops
+ (go_format_parse_number_fraction): create more program steps for fractions
+ (go_format_dump_program): handle new ops
+ (go_format_execute): ditto
+ * goffice/gtk/go-format-sel.ui: change spin button bounds
+ * goffice/gtk/go-format-sel.c (cb_max_denom_digits_changed): permit
+ 0 denominator digits
+
2011-08-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (GOFormatOp): add ops
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index 40503da..8648587 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -321,7 +321,7 @@ cb_max_denom_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
gfs->format.details.denominator_max_digits = val;
gtk_spin_button_set_range
(GTK_SPIN_BUTTON (gfs->format.widget[F_FRACTION_MIN_DENOM_DIGITS]),
- 1, val);
+ 0, val);
draw_format_preview (gfs, TRUE);
}
diff --git a/goffice/gtk/go-format-sel.ui b/goffice/gtk/go-format-sel.ui
index 0623de5..6acff4d 100644
--- a/goffice/gtk/go-format-sel.ui
+++ b/goffice/gtk/go-format-sel.ui
@@ -31,7 +31,6 @@
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment6">
- <property name="lower">1</property>
<property name="upper">30</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 068ade1..3f1d511 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -107,7 +107,7 @@
/* ------------------------------------------------------------------------- */
-#define DEBUG_PROGRAMS
+#undef DEBUG_PROGRAMS
#undef DEBUG_REF_COUNT
/***************************************************************************/
@@ -194,10 +194,12 @@ typedef enum {
OP_NUM_FRACTION_SLASH,
OP_NUM_FRACTION_SIGN,
OP_NUM_FRACTION_SIMPLIFY,
+ OP_NUM_FRACTION_SIMPLIFY_NUMERATOR,
#ifdef ALLOW_PI_SLASH
OP_NUM_FRACTION_BLANK_PI,
OP_NUM_FRACTION_SCALE_PI,
OP_NUM_FRACTION_SIMPLIFY_PI,
+ OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI,
OP_NUM_FRACTION_PI_SUM_START,
#endif
OP_NUM_GENERAL_MARK,
@@ -1832,6 +1834,8 @@ go_format_parse_number_fraction (GOFormatParseState *pstate)
gboolean explicit_denom = FALSE;
int denominator_digits = 0;
gboolean inhibit_blank = FALSE;
+ gboolean inhibit_blank_denom = FALSE;
+ gboolean inhibit_blank_numerator = FALSE;
gboolean inhibit_blank_whole = TRUE;
int scale = 0;
#ifdef ALLOW_PI_SLASH
@@ -1977,7 +1981,7 @@ go_format_parse_number_fraction (GOFormatParseState *pstate)
if (!go_format_parse_number_new_1 (prg, pstate,
tno_endwhole + 1,
pi_scale ? tno_slash - 2 :tno_slash,
- 0, 2, NULL))
+ 0, 2, &inhibit_blank_numerator))
return NULL;
scale += pstate->scale;
@@ -1990,20 +1994,29 @@ go_format_parse_number_fraction (GOFormatParseState *pstate)
ADD_OP (OP_NUM_FRACTION_DENOMINATOR);
if (!go_format_parse_number_new_1 (prg, pstate,
tno_slash + 1, tno_suffix,
- 0, 3, NULL))
+ 0, 3, &inhibit_blank_denom))
return NULL;
scale += pstate->scale;
ADD_OP (OP_NUM_FRACTION_ALIGN);
- ADD_OP (OP_NUM_FRACTION_SIMPLIFY);
#ifdef ALLOW_PI_SLASH
if (pi_scale) {
- ADD_OP (OP_NUM_FRACTION_SIMPLIFY_PI);
if (!inhibit_blank)
ADD_OP (OP_NUM_FRACTION_BLANK_PI);
+ if (!inhibit_blank_denom)
+ ADD_OP (OP_NUM_FRACTION_SIMPLIFY_PI);
+ if (!inhibit_blank_numerator)
+ ADD_OP (OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI);
+
} else
#endif
- if (!inhibit_blank)
- ADD_OP (OP_NUM_FRACTION_BLANK);
+ {
+ if (!inhibit_blank)
+ ADD_OP (OP_NUM_FRACTION_BLANK);
+ if (!inhibit_blank_denom)
+ ADD_OP (OP_NUM_FRACTION_SIMPLIFY);
+ if (!inhibit_blank_numerator)
+ ADD_OP (OP_NUM_FRACTION_SIMPLIFY_NUMERATOR);
+ }
if (!inhibit_blank_whole)
ADD_OP (OP_NUM_FRACTION_BLANK_WHOLE);
@@ -2361,10 +2374,12 @@ go_format_dump_program (const guchar *prg)
REGULAR(OP_NUM_FRACTION_ALIGN);
REGULAR(OP_NUM_FRACTION_SLASH);
REGULAR(OP_NUM_FRACTION_SIMPLIFY);
+ REGULAR(OP_NUM_FRACTION_SIMPLIFY_NUMERATOR);
#ifdef ALLOW_PI_SLASH
REGULAR(OP_NUM_FRACTION_BLANK_PI);
REGULAR(OP_NUM_FRACTION_SCALE_PI);
REGULAR(OP_NUM_FRACTION_SIMPLIFY_PI);
+ REGULAR(OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI);
REGULAR(OP_NUM_FRACTION_PI_SUM_START);
#endif
REGULAR(OP_NUM_GENERAL_MARK);
@@ -3429,21 +3444,23 @@ SUFFIX(go_format_execute) (PangoLayout *layout, GString *dst,
}
break;
+
+#ifdef ALLOW_PI_SLASH
+ case OP_NUM_FRACTION_SIMPLIFY_PI:
+#endif
case OP_NUM_FRACTION_SIMPLIFY:
- if (fraction.d == 1 && (fraction.n != 0 || !fraction.use_whole))
+ if (!fraction.blanked && fraction.d == 1)
blank_characters (dst, attrs, fraction.denominator_start - 1,
2, layout);
break;
+ case OP_NUM_FRACTION_SIMPLIFY_NUMERATOR:
+ /* Nothing to simplify */
+ break;
+
#ifdef ALLOW_PI_SLASH
- case OP_NUM_FRACTION_SIMPLIFY_PI:
- if (fraction.n == 0 && !fraction.use_whole) {
- gsize start = fraction.denominator_start - 1
- - UNICODE_PI_number_of_bytes;
- blank_characters (dst, attrs, start, UNICODE_PI_number_of_bytes,
- layout);
- fraction.denominator_start -= UNICODE_PI_number_of_bytes - 1;
- } else if (fraction.n == 1 || fraction.n == -1) {
+ case OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI:
+ if (!fraction.blanked && (fraction.n == 1 || fraction.n == -1)) {
/* Remove "1". */
gsize p = fraction.nominator_start;
gsize length = fraction.denominator_start - p - 1 -
@@ -5728,7 +5745,6 @@ go_format_details_init (GOFormatDetails *details, GOFormatFamily family)
details->exponent_digits = 2;
details->min_digits = (family == GO_FORMAT_FRACTION) ? 0 : 1;
details->split_fraction = TRUE;
- details->denominator_min_digits = 1;
details->denominator_max_digits = 1;
details->denominator = 8;
details->automatic_denominator = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]