[goffice] Improve fraction format selector. [#117215]



commit aea5c4211c1aa08d6efea39e758cd66303afd97c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Aug 24 16:13:57 2011 -0600

    Improve fraction format selector. [#117215]
    
    2011-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/gtk/go-format-sel.c (FormatWidget): add widgets for fraction
    	formatting
    	(cb_denominator_changed): new
    	(cb_max_denom_digits_changed): new
    	(cb_min_integer_digits_changed): new
    	(cb_min_denom_digits_changed): new
    	(cb_exp_digits_changed): check for active type
    	(cb_split_fraction_toggle): new
    	(cb_fraction_automatic_toggle): new
    	(fmt_dialog_enable_widgets): increase maximum number of widgets per format
    	type, add widgets for fraction formatting
    	(nfs_init): connect new callbacks
    	* goffice/gtk/go-format-sel.ui: add widgets for fraction formatting
    	* goffice/utils/go-format.c (go_format_generate_fraction_str): new
    	(go_format_generate_str): call go_format_generate_fraction_str
    	(go_format_details_init): initialize new fields
    	* goffice/utils/go-format.h (GOFormatDetails): add fields to support
    	fractions

 ChangeLog                    |   21 ++
 NEWS                         |    1 +
 goffice/gtk/go-format-sel.c  |  221 +++++++++++-
 goffice/gtk/go-format-sel.ui |  756 +++++++++++++++++++++++++++++++-----------
 goffice/utils/go-format.c    |   48 +++
 goffice/utils/go-format.h    |   10 +-
 6 files changed, 839 insertions(+), 218 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3091239..d33e93c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/gtk/go-format-sel.c (FormatWidget): add widgets for fraction
+	formatting
+	(cb_denominator_changed): new
+	(cb_max_denom_digits_changed): new
+	(cb_min_integer_digits_changed): new
+	(cb_min_denom_digits_changed): new
+	(cb_exp_digits_changed): check for active type
+	(cb_split_fraction_toggle): new
+	(cb_fraction_automatic_toggle): new
+	(fmt_dialog_enable_widgets): increase maximum number of widgets per format
+	type, add widgets for fraction formatting
+	(nfs_init): connect new callbacks
+	* goffice/gtk/go-format-sel.ui: add widgets for fraction formatting
+	* goffice/utils/go-format.c (go_format_generate_fraction_str): new
+	(go_format_generate_str): call go_format_generate_fraction_str
+	(go_format_details_init): initialize new fields
+	* goffice/utils/go-format.h (GOFormatDetails): add fields to support
+	fractions
+
 2011-08-23  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* goffice/gtk/go-format-sel.c (cb_exp_digits_changed): new
diff --git a/NEWS b/NEWS
index d5d391d..1787f27 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
 	* Fix date format on Windows. [#655573]
 	* Extend encoding specification from file-openers to plugin services.
 	* Improve the scientific number formats selector. [#657187][#623847]
+	* Improve fraction format selector. [#117215]
 
 Jean:
 	* Port to gtk+-3.0.
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index b1cdfa6..4bb2814 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -96,6 +96,18 @@ typedef enum {
 	F_EXP_DIGITS,           F_EXP_DIGITS_LABEL,
 	F_NEGATIVE_LABEL,	F_NEGATIVE_SCROLL,	F_NEGATIVE,
 	F_DECIMAL_LABEL,	F_CODE_LABEL,
+	F_FRACTION_SEPARATE_INTEGER,
+	F_FRACTION_MIN_INTEGER_DIGITS_LABEL,
+	F_FRACTION_MIN_INTEGER_DIGITS,
+	F_FRACTION_MIN_NUMERATOR_DIGITS_LABEL,
+	F_FRACTION_SPECIFIED,
+	F_FRACTION_AUTOMATIC,
+	F_FRACTION_DENOMINATOR_LABEL,
+	F_FRACTION_DENOMINATOR,
+	F_FRACTION_MAX_DENOM_DIGITS_LABEL,
+	F_FRACTION_MIN_DENOM_DIGITS_LABEL,
+	F_FRACTION_MAX_DENOM_DIGITS,
+	F_FRACTION_MIN_DENOM_DIGITS,
 	F_MAX_WIDGET
 } FormatWidget;
 
@@ -291,13 +303,57 @@ cb_decimals_changed (GtkSpinButton *spin, GOFormatSel *gfs)
 }
 
 static void
-cb_exp_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
+cb_denominator_changed (GtkSpinButton *spin, GOFormatSel *gfs)
 {
-	gfs->format.details.exponent_digits =
+	gfs->format.details.denominator =
 		gtk_spin_button_get_value_as_int (spin);
 
-	if (gtk_widget_get_visible (gfs->format.widget[F_NEGATIVE]))
-		fillin_negative_samples (gfs);
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
+cb_max_denom_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
+{
+	int val = gtk_spin_button_get_value_as_int (spin);
+
+	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);
+
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
+cb_min_integer_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
+{
+	gfs->format.details.min_digits =
+		gtk_spin_button_get_value_as_int (spin);
+
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
+cb_min_denom_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
+{
+	gfs->format.details.denominator_min_digits =
+		gtk_spin_button_get_value_as_int (spin);
+
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
+cb_exp_digits_changed (GtkSpinButton *spin, GOFormatSel *gfs)
+{
+	int val = gtk_spin_button_get_value_as_int (spin);
+
+	if (gfs->format.current_type == GO_FORMAT_FRACTION)
+		gfs->format.details.numerator_min_digits = val;
+	else {
+		gfs->format.details.exponent_digits = val;
+		if (gtk_widget_get_visible (gfs->format.widget[F_NEGATIVE]))
+			fillin_negative_samples (gfs);
+	}
 
 	draw_format_preview (gfs, TRUE);
 }
@@ -346,6 +402,36 @@ cb_superscript_hide_1_toggle (GtkWidget *w, GOFormatSel *gfs)
 }
 
 static void
+cb_split_fraction_toggle (GtkWidget *w, GOFormatSel *gfs)
+{
+	gboolean act = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+	gfs->format.details.split_fraction = act;
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MIN_INTEGER_DIGITS_LABEL],
+				  act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MIN_INTEGER_DIGITS],
+				  act);
+
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
+cb_fraction_automatic_toggle (GtkWidget *w, GOFormatSel *gfs)
+{
+	gboolean act =gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+	gfs->format.details.automatic_denominator = act;
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MAX_DENOM_DIGITS_LABEL], 
+				  act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MIN_DENOM_DIGITS_LABEL], 
+				  act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MAX_DENOM_DIGITS], act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_MIN_DENOM_DIGITS], act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_DENOMINATOR_LABEL], !act);
+	gtk_widget_set_sensitive (gfs->format.widget[F_FRACTION_DENOMINATOR], !act);
+
+	draw_format_preview (gfs, TRUE);
+}
+
+static void
 fmt_dialog_init_fmt_list (GOFormatSel *gfs, char const *const *formats,
 			  GtkTreeIter *select)
 {
@@ -410,7 +496,7 @@ static void
 fmt_dialog_enable_widgets (GOFormatSel *gfs, int page)
 {
 	SETUP_LOCALE_SWITCH;
-	static FormatWidget const contents[][12] = {
+	static FormatWidget const contents[][15] = {
 		/* General */
 		{
 			F_GENERAL_EXPLANATION,
@@ -479,9 +565,19 @@ fmt_dialog_enable_widgets (GOFormatSel *gfs, int page)
 		/* Fraction */
 		{
 			F_FRACTION_EXPLANATION,
-			F_LIST_LABEL,
-			F_LIST_SCROLL,
-			F_LIST,
+			F_FRACTION_SEPARATE_INTEGER,
+			F_FRACTION_MIN_INTEGER_DIGITS_LABEL,
+			F_FRACTION_MIN_INTEGER_DIGITS,
+			F_FRACTION_MIN_NUMERATOR_DIGITS_LABEL,
+			F_EXP_DIGITS,
+			F_FRACTION_SPECIFIED,
+			F_FRACTION_AUTOMATIC,
+			F_FRACTION_DENOMINATOR_LABEL,
+			F_FRACTION_DENOMINATOR,
+			F_FRACTION_MAX_DENOM_DIGITS_LABEL,
+			F_FRACTION_MIN_DENOM_DIGITS_LABEL,
+			F_FRACTION_MAX_DENOM_DIGITS,
+			F_FRACTION_MIN_DENOM_DIGITS,
 			F_MAX_WIDGET
 		},
 		/* Scientific */
@@ -567,7 +663,6 @@ stays:
 				;
 			case GO_FORMAT_DATE:
 			case GO_FORMAT_TIME:
-			case GO_FORMAT_FRACTION:
 				start = end = page;
 				break;
 
@@ -623,7 +718,7 @@ stays:
 			break;
 
 		case F_DECIMAL_SPIN:
-			gtk_spin_button_set_value (GTK_SPIN_BUTTON (gfs->format.widget[F_DECIMAL_SPIN]),
+			gtk_spin_button_set_value (GTK_SPIN_BUTTON (w),
 						   gfs->format.details.num_decimals);
 			break;
 
@@ -646,20 +741,82 @@ stays:
 			break;
 
 		case F_EXP_DIGITS:
-			gtk_spin_button_set_value 
-				(GTK_SPIN_BUTTON (gfs->format.widget[F_EXP_DIGITS]),
-						   gfs->format.details.exponent_digits);
+			if (page == GO_FORMAT_FRACTION)
+				gtk_spin_button_set_value 
+					(GTK_SPIN_BUTTON (w),
+					 gfs->format.details.numerator_min_digits);
+			else
+				gtk_spin_button_set_value 
+					(GTK_SPIN_BUTTON (w),
+					 gfs->format.details.exponent_digits);
 			break;
 
 		case F_ENGINEERING_BUTTON:
 			gtk_toggle_button_set_active
-				(GTK_TOGGLE_BUTTON (gfs->format.widget[F_ENGINEERING_BUTTON]),
+				(GTK_TOGGLE_BUTTON (w),
 				 gfs->format.details.exponent_step == 3);
 			break;
 
 		case F_SEPARATOR:
-			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gfs->format.widget[F_SEPARATOR]),
-						      gfs->format.details.thousands_sep);
+			gtk_toggle_button_set_active 
+				(GTK_TOGGLE_BUTTON (w),
+				 gfs->format.details.thousands_sep);
+			break;
+
+		case F_FRACTION_SEPARATE_INTEGER:
+			gtk_toggle_button_set_active 
+				(GTK_TOGGLE_BUTTON (w),
+				 gfs->format.details.split_fraction);
+			break;
+
+		case F_FRACTION_MIN_INTEGER_DIGITS:
+			gtk_spin_button_set_value 
+				(GTK_SPIN_BUTTON (w), 
+				 gfs->format.details.min_digits);
+			gtk_widget_set_sensitive 
+				(w, gfs->format.details.split_fraction);
+			gtk_widget_set_sensitive 
+				(gfs->format.widget[F_FRACTION_MIN_INTEGER_DIGITS_LABEL], 
+				 gfs->format.details.split_fraction);
+			break;
+
+		case F_FRACTION_AUTOMATIC:
+			gtk_toggle_button_set_active 
+				(GTK_TOGGLE_BUTTON (w),
+				 gfs->format.details.automatic_denominator);
+			break;
+
+		case F_FRACTION_DENOMINATOR:
+			gtk_spin_button_set_value 
+				(GTK_SPIN_BUTTON (w),
+				 gfs->format.details.denominator);
+			gtk_widget_set_sensitive 
+				(w, !gfs->format.details.automatic_denominator);
+			gtk_widget_set_sensitive 
+				(gfs->format.widget[F_FRACTION_DENOMINATOR_LABEL], 
+				 !gfs->format.details.automatic_denominator);
+			break;
+
+		case F_FRACTION_MAX_DENOM_DIGITS:
+			gtk_spin_button_set_value 
+				(GTK_SPIN_BUTTON (w),
+				 gfs->format.details.denominator_max_digits);
+			gtk_widget_set_sensitive 
+				(w, gfs->format.details.automatic_denominator);
+			gtk_widget_set_sensitive 
+				(gfs->format.widget[F_FRACTION_MAX_DENOM_DIGITS_LABEL], 
+				 gfs->format.details.automatic_denominator);
+			break;
+
+		case F_FRACTION_MIN_DENOM_DIGITS:
+			gtk_spin_button_set_value 
+				(GTK_SPIN_BUTTON (w),
+				 gfs->format.details.denominator_min_digits);
+			gtk_widget_set_sensitive 
+				(w, gfs->format.details.automatic_denominator);
+			gtk_widget_set_sensitive 
+				(gfs->format.widget[F_FRACTION_MIN_DENOM_DIGITS_LABEL], 
+				 gfs->format.details.automatic_denominator);
 			break;
 
 		default:
@@ -971,6 +1128,18 @@ nfs_init (GOFormatSel *gfs)
 		"format_negatives",
 		"format_decimal_label",
 		"format_code_label",
+		"format_separate_integer_part",
+		"format_minimum_integer_digits_label",
+		"format_minimum_integer_digits",
+		"format_minimum_numerator_digits_label",
+		"format_fraction_specified_button",
+		"format_fraction_automatic_button",
+		"format_denominator_label",
+		"format_denominator",
+		"format_max_denominator_digits_label",
+		"format_min_denominator_digits_label",
+		"format_maximum_denominator_digits",
+		"format_minimum_denominator_digits",
 		NULL
 	};
 
@@ -1096,8 +1265,24 @@ nfs_init (GOFormatSel *gfs)
 		G_CALLBACK (cb_engineering_toggle), gfs);
 	g_signal_connect (G_OBJECT (gfs->format.widget[F_SUPERSCRIPT_BUTTON]), "toggled",
 		G_CALLBACK (cb_superscript_toggle), gfs);
-	g_signal_connect (G_OBJECT (gfs->format.widget[F_SUPERSCRIPT_HIDE_1_BUTTON]), "toggled",
-		G_CALLBACK (cb_superscript_hide_1_toggle), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_SUPERSCRIPT_HIDE_1_BUTTON]), 
+			  "toggled", G_CALLBACK (cb_superscript_hide_1_toggle), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_AUTOMATIC]), 
+			  "toggled", G_CALLBACK (cb_fraction_automatic_toggle), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_SEPARATE_INTEGER]), 
+			  "toggled", G_CALLBACK (cb_split_fraction_toggle), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_MIN_INTEGER_DIGITS]), 
+			  "value_changed",
+			  G_CALLBACK (cb_min_integer_digits_changed), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_DENOMINATOR]), 
+			  "value_changed",
+			  G_CALLBACK (cb_denominator_changed), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_MAX_DENOM_DIGITS]), 
+			  "value_changed",
+			  G_CALLBACK (cb_max_denom_digits_changed), gfs);
+	g_signal_connect (G_OBJECT (gfs->format.widget[F_FRACTION_MIN_DENOM_DIGITS]), 
+			  "value_changed",
+			  G_CALLBACK (cb_min_denom_digits_changed), gfs);	
 
 	/* setup custom format list */
 	gfs->format.formats.model = gtk_list_store_new (1, G_TYPE_STRING);
diff --git a/goffice/gtk/go-format-sel.ui b/goffice/gtk/go-format-sel.ui
index 5595fac..5f1b35e 100644
--- a/goffice/gtk/go-format-sel.ui
+++ b/goffice/gtk/go-format-sel.ui
@@ -13,6 +13,29 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkAdjustment" id="adjustment3">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment4">
+    <property name="lower">2</property>
+    <property name="upper">1000000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">100</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment5">
+    <property name="lower">1</property>
+    <property name="upper">30</property>
+    <property name="step_increment">1</property>
+    <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>
+  </object>
   <object class="GtkBox" id="number_box">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -160,196 +183,15 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
             <child>
-              <object class="GtkTable" id="table1">
+              <object class="GtkLabel" id="format_general_explanation">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="n_rows">2</property>
-                <property name="n_columns">2</property>
-                <child>
-                  <object class="GtkLabel" id="format_number_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display numeric values with a fixed number of decimals.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_currency_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display currency amounts.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_accounting_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display amounts in traditional accounting styles.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_date_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display dates and optionally times of day.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_time_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display times of day.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_fraction_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display values as closest fractional approximation.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_scientific_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display values with power-of-ten scaling.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_text_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display and input values as strings with no interpretation.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_custom_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Specify an XL-style format directly</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_special_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_percentage_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Display values as percentages.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_general_explanation">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">Select an appropriate format automatically.</property>
-                    <property name="wrap">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_SHRINK</property>
-                  </packing>
-                </child>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Select an appropriate format automatically.</property>
+                <property name="wrap">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -358,9 +200,14 @@
               </packing>
             </child>
             <child>
-              <object class="GtkSeparator" id="hseparator1">
+              <object class="GtkLabel" id="format_number_explanation">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display numeric values with a fixed number of decimals.</property>
+                <property name="wrap">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -369,6 +216,178 @@
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="format_currency_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display currency amounts.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_accounting_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display amounts in traditional accounting styles.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_date_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display dates and optionally times of day.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_time_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display times of day.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_fraction_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display values as closest fractional approximation.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">6</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_scientific_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display values with power-of-ten scaling.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">7</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_text_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display and input values as strings with no interpretation.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">8</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_custom_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Specify an XL-style format directly</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">9</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_special_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">10</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="format_percentage_explanation">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Display values as percentages.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">11</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="hseparator1">
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">12</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkBox" id="format_decimal_box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -430,7 +449,96 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">2</property>
+                <property name="position">13</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="format_superscript_box1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkCheckButton" id="format_separate_integer_part">
+                    <property name="label" translatable="yes">Show _separate integer part</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">Use superscript for exponent (e.g. 4Ã10Â)</property>
+                    <property name="tooltip_text" translatable="yes">Use superscript for exponent (e.g. 4Ã10Â)</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">24</property>
+                    <child>
+                      <object class="GtkBox" id="format_decimal_box2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="format_minimum_integer_digits_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Minimum number of integer digits:</property>
+                            <property name="use_underline">True</property>
+                            <property name="justify">center</property>
+                            <property name="mnemonic_widget">format_minimum_integer_digits</property>
+                            <accessibility>
+                              <relation type="label-for" target="format_number_decimals"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="format_minimum_integer_digits">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">adjustment3</property>
+                            <property name="climb_rate">1.0099999997764826</property>
+                            <property name="numeric">True</property>
+                            <accessibility>
+                              <relation type="labelled-by" target="format_decimal_label"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">14</property>
               </packing>
             </child>
             <child>
@@ -439,6 +547,25 @@
                 <property name="can_focus">False</property>
                 <property name="spacing">6</property>
                 <child>
+                  <object class="GtkLabel" id="format_minimum_numerator_digits_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Minimum number of _numerator digits:</property>
+                    <property name="use_underline">True</property>
+                    <property name="justify">center</property>
+                    <property name="mnemonic_widget">format_exp_digits</property>
+                    <accessibility>
+                      <relation type="label-for" target="format_number_decimals"/>
+                    </accessibility>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkLabel" id="format_exp_digits_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -446,7 +573,7 @@
                     <property name="label" translatable="yes">Minimum number of e_xponent digits:</property>
                     <property name="use_underline">True</property>
                     <property name="justify">center</property>
-                    <property name="mnemonic_widget">format_number_decimals</property>
+                    <property name="mnemonic_widget">format_exp_digits</property>
                     <accessibility>
                       <relation type="label-for" target="format_number_decimals"/>
                     </accessibility>
@@ -454,7 +581,7 @@
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
                 <child>
@@ -473,14 +600,244 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">1</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">3</property>
+                <property name="position">15</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="format_fraction_specified_box">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkRadioButton" id="format_fraction_specified_button">
+                    <property name="label" translatable="yes">Specified denominator:</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="xalign">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">24</property>
+                    <child>
+                      <object class="GtkBox" id="format_decimal_box3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="format_denominator_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Denominator:</property>
+                            <property name="use_underline">True</property>
+                            <property name="justify">center</property>
+                            <property name="mnemonic_widget">format_denominator</property>
+                            <accessibility>
+                              <relation type="label-for" target="format_number_decimals"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="format_denominator">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">adjustment4</property>
+                            <property name="climb_rate">1.01</property>
+                            <property name="numeric">True</property>
+                            <accessibility>
+                              <relation type="labelled-by" target="format_decimal_label"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">16</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="format_fraction_automatic_box">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkRadioButton" id="format_fraction_automatic_button">
+                    <property name="label" translatable="yes">Automatic denominator</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="xalign">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">format_fraction_specified_button</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">24</property>
+                    <child>
+                      <object class="GtkBox" id="format_decimal_box4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="format_max_denominator_digits_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Maximum number of denominator digits:</property>
+                            <property name="use_underline">True</property>
+                            <property name="justify">center</property>
+                            <property name="mnemonic_widget">format_maximum_denominator_digits</property>
+                            <accessibility>
+                              <relation type="label-for" target="format_number_decimals"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="format_maximum_denominator_digits">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">adjustment5</property>
+                            <property name="climb_rate">1.01</property>
+                            <property name="numeric">True</property>
+                            <accessibility>
+                              <relation type="labelled-by" target="format_decimal_label"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">24</property>
+                    <child>
+                      <object class="GtkBox" id="format_decimal_box5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="format_min_denominator_digits_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Minimum number of denominator digits:</property>
+                            <property name="use_underline">True</property>
+                            <property name="justify">center</property>
+                            <property name="mnemonic_widget">format_minimum_denominator_digits</property>
+                            <accessibility>
+                              <relation type="label-for" target="format_number_decimals"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="format_minimum_denominator_digits">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="adjustment">adjustment6</property>
+                            <property name="climb_rate">1.0099999997764826</property>
+                            <property name="numeric">True</property>
+                            <accessibility>
+                              <relation type="labelled-by" target="format_decimal_label"/>
+                            </accessibility>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">17</property>
               </packing>
             </child>
             <child>
@@ -497,7 +854,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">4</property>
+                <property name="position">18</property>
               </packing>
             </child>
             <child>
@@ -505,7 +862,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
                 <child>
                   <object class="GtkCheckButton" id="format_superscript_button">
                     <property name="label" translatable="yes">Use _superscript</property>
@@ -551,7 +907,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">5</property>
+                <property name="position">19</property>
               </packing>
             </child>
             <child>
@@ -580,7 +936,8 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">6</property>
+                <property name="padding">3</property>
+                <property name="position">20</property>
               </packing>
             </child>
             <child>
@@ -676,7 +1033,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">7</property>
+                <property name="position">21</property>
               </packing>
             </child>
             <child>
@@ -720,7 +1077,8 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">8</property>
+                <property name="padding">3</property>
+                <property name="position">22</property>
               </packing>
             </child>
           </object>
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 914fe46..28a6da2 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -5267,6 +5267,45 @@ go_format_generate_scientific_str (GString *dst, GOFormatDetails const *details)
 
 #ifdef DEFINE_COMMON
 static void
+go_format_generate_fraction_str (GString *dst, GOFormatDetails const *details)
+{
+	/* Maximum not terribly important. */
+	int numerator_min_digits = CLAMP (details->numerator_min_digits, 0, 30);
+	
+	if (details->split_fraction) {
+		/* Maximum not terribly important. */
+		int min_digits = CLAMP (details->min_digits, 0, 30);
+		if (min_digits > 0)
+			go_string_append_c_n (dst, '0', min_digits);
+		else
+			g_string_append_c (dst, '#');
+		g_string_append_c (dst, ' ');
+	}
+	
+	if  (numerator_min_digits > 0)
+		go_string_append_c_n (dst, '0', numerator_min_digits);
+	else
+		g_string_append_c (dst, '?');
+	
+	g_string_append_c (dst, '/');
+	
+	if (details->automatic_denominator) {
+		int denominator_max_digits = CLAMP (details->denominator_max_digits, 1, 30);
+		int denominator_min_digits = CLAMP (details->denominator_min_digits, 
+						    0, denominator_max_digits);
+		go_string_append_c_n (dst, '?', 
+				      denominator_max_digits - denominator_min_digits);
+		go_string_append_c_n (dst, '0', 
+				      denominator_min_digits);
+	} else {
+		int denominator = CLAMP (details->denominator, 2, G_MAXINT);
+		g_string_append_printf (dst, "%d", denominator); 
+	}
+}
+#endif
+
+#ifdef DEFINE_COMMON
+static void
 go_format_generate_accounting_str (GString *dst,
 				   GOFormatDetails const *details)
 {
@@ -5468,6 +5507,9 @@ go_format_generate_str (GString *dst, GOFormatDetails const *details)
 	case GO_FORMAT_SCIENTIFIC:
 		go_format_generate_scientific_str (dst, details);
 		break;
+	case GO_FORMAT_FRACTION:
+		go_format_generate_fraction_str (dst, details);
+		break;
 	default:
 		break;
 	}
@@ -5510,6 +5552,12 @@ go_format_details_init (GOFormatDetails *details, GOFormatFamily family)
 	details->exponent_step = 1;
 	details->exponent_digits = 2;
 	details->min_digits = 1;
+	details->split_fraction = TRUE;
+	details->numerator_min_digits = 1;
+	details->denominator_min_digits = 1;
+	details->denominator_max_digits = 1;
+	details->denominator = 8;
+	details->automatic_denominator = TRUE;
 }
 #endif
 
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 43790d6..3e1495c 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -73,7 +73,7 @@ typedef struct {
 	GOFormatFamily family;
 	GOFormatMagic magic;
 
-	/* NUMBER, SCIENTIFIC, CURRENCY, ACCOUNTING, PERCENTAGE: */
+	/* NUMBER, SCIENTIFIC, CURRENCY, ACCOUNTING, FRACTION, PERCENTAGE: */
 	int min_digits;
 	int num_decimals;
 
@@ -96,6 +96,14 @@ typedef struct {
 	gboolean use_markup;
 	gboolean simplify_mantissa;
 
+	/* FRACTION: */
+	gboolean automatic_denominator;
+	gboolean split_fraction;
+	int numerator_min_digits;
+	int denominator_min_digits;
+	int denominator_max_digits;
+	int denominator;
+
 	int expansion[30];
 } GOFormatDetails;
 



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