[goffice] When writing fractions, don't just assume that we are writing ODF1.2.



commit 37d69aff3dd50e502099643b5f0b926c49b56369
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jun 10 00:04:58 2011 -0600

    When writing fractions, don't just assume that we are writing ODF1.2.
    
    2011-06-10  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* configure.in: check for get_gsf_odf_version
    	* goffice/utils/go-format.c (go_format_output_fraction_to_odf):
    	don't just assume that we are writing ODF 1.2

 ChangeLog                 |    8 +++++++-
 configure.in              |    1 +
 goffice/utils/go-format.c |   29 +++++++++++++++++++++++++++--
 3 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6424398..98080c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
+2011-06-10  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* configure.in: check for get_gsf_odf_version
+	* goffice/utils/go-format.c (go_format_output_fraction_to_odf): 
+	don't just assume that we are writing ODF 1.2
+
 2011-06-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
-	* goffice/utils/go-format.c (go_format_output_fraction_to_odf): in 
+	* goffice/utils/go-format.c (go_format_output_fraction_to_odf): in
 	ODF 1.2 we do not need to use gnm:no-integer-part any more
 
 2011-05-24  Morten Welinder  <terra gnome org>
diff --git a/configure.in b/configure.in
index 53bc405..c9d717f 100644
--- a/configure.in
+++ b/configure.in
@@ -476,6 +476,7 @@ LIBS="$GOFFICE_LIBS $LIBS"
 AC_CHECK_FUNCS(cairo_surface_set_fallback_resolution cairo_ps_surface_set_eps)
 AC_CHECK_FUNCS(g_file_new_for_commandline_arg g_file_new_for_uri g_hash_table_iter_init)
 AC_CHECK_FUNCS(g_content_type_from_mime_type)
+AC_CHECK_FUNCS(get_gsf_odf_version)
 AC_CHECK_FUNCS(gtk_adjustment_get_page_size gtk_adjustment_get_upper \
 	gtk_color_selection_dialog_get_color_selection gtk_dialog_get_action_area \
 	gtk_layout_get_bin_window gtk_menu_shell_get_active gtk_selection_data_get_data \
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 5bddbd4..de13fdb 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -33,6 +33,7 @@
 
 #include <goffice/goffice-config.h>
 #include <gsf/gsf-msole-utils.h>
+#include <gsf/gsf-opendoc-utils.h>
 #include "go-format.h"
 #include "go-locale.h"
 #include "go-font.h"
@@ -6002,8 +6003,21 @@ go_format_output_fraction_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 				gsf_xml_out_start_element (xout, NUMBER "fraction");
 				odf_add_bool (xout, NUMBER "grouping", FALSE);
 				gsf_xml_out_add_int (xout, NUMBER "min-denominator-digits", 3);
-				gsf_xml_out_add_int (xout, NUMBER "min-integer-digits",
-						     int_digits > 0 ? int_digits : 0);
+				if (int_digits >= 0)
+					gsf_xml_out_add_int (xout, NUMBER "min-integer-digits", int_digits);
+				else
+#ifdef HAVE_GET_GSF_ODF_VERSION
+					if (get_gsf_odf_version () < 102)
+#endif
+						{
+							gsf_xml_out_add_int (xout, NUMBER "min-integer-digits", 0);
+							if (with_extension)
+								gsf_xml_out_add_cstr_unchecked
+									(xout, GNMSTYLE "no-integer-part", "true");
+							
+						}
+				/* In ODF1.2, absence of NUMBER "min-integer-digits" means not to show an       */
+				/* integer part. In ODF 1.1 we used a foreign element: gnm:no-integer-part=true */
 				gsf_xml_out_add_int (xout, NUMBER "min-numerator-digits", 1);
 				gsf_xml_out_end_element (xout); /* </number:fraction> */
 			}
@@ -6067,6 +6081,17 @@ go_format_output_fraction_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 
 			if (int_digits >= 0)
 				gsf_xml_out_add_int (xout, NUMBER "min-integer-digits", int_digits);
+			else
+#ifdef HAVE_GET_GSF_ODF_VERSION
+				if (get_gsf_odf_version () < 102)
+#endif
+					{
+						gsf_xml_out_add_int (xout, NUMBER "min-integer-digits", 0);
+						if (with_extension)
+							gsf_xml_out_add_cstr_unchecked
+								(xout, GNMSTYLE "no-integer-part", "true");
+
+					}
 			/* In ODF1.2, absence of NUMBER "min-integer-digits" means not to show an       */
 			/* integer part. In ODF 1.1 we used a foreign element: gnm:no-integer-part=true */
 			gsf_xml_out_add_int (xout, NUMBER "min-numerator-digits",



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