[gnumeric] Improve format roundtrip through ODF.



commit cf790af91438c9593ec73b3b76fb92f116665a28
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Apr 24 00:39:02 2014 -0600

    Improve format roundtrip through ODF.
    
    2014-04-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_number): read gnm:min-integer-chars
        and create an appropriate number format

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    5 +++++
 plugins/openoffice/openoffice-read.c |   25 +++++++++++++++++++++----
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index db35447..3cb09f3 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
        * Fix chart size in ODF import. [#728278]
        * Improve chart roundtrip through ODF. [#728197]
        * Export centre-across-selection in a way LO can understand. [#726010]
+       * Improve format roundtrip through ODF.
 
 Morten:
        * For xlsx, don't complain over "ext" elements.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 8594aeb..3755bcd 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (odf_number): read gnm:min-integer-chars
+       and create an appropriate number format
+
 2014-04-22  Morten Welinder  <terra gnome org>
 
        * openoffice-write.c (odf_write_axis_style): Plug leak.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 7d314a6..b24af87 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -5201,6 +5201,7 @@ odf_number (GsfXMLIn *xin, xmlChar const **attrs)
        gboolean decimals_specified = FALSE;
 /*     gnm_float display_factor = 1.; */
        int min_i_digits = 1;
+       int min_i_chars = 1;
 
        if (state->cur_format.accum == NULL)
                return;
@@ -5218,11 +5219,27 @@ odf_number (GsfXMLIn *xin, xmlChar const **attrs)
                else if (oo_attr_int_range (xin, attrs, OO_NS_NUMBER,
                                              "min-integer-digits", &min_i_digits, 0, 30))
                        ;
+               else if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT,
+                                             "min-integer-chars", &min_i_chars, 0, 30))
+                       ;
 
-       if (decimals_specified || (min_i_digits != 1) || grouping)
-               go_format_generate_number_str (state->cur_format.accum,  min_i_digits, decimal_places,
-                                              grouping, FALSE, FALSE, NULL, NULL);
-       else
+       if (decimals_specified || (min_i_digits != 1) || grouping || (min_i_chars > min_i_digits)) {
+               if (min_i_chars > min_i_digits) {
+                       go_format_generate_number_str (state->cur_format.accum, min_i_chars, decimal_places,
+                                                      grouping, FALSE, FALSE, NULL, NULL);
+                       while (min_i_chars > min_i_digits) {
+                               /* substitute the left most 0 by ? */
+                               char *zero = strchr (state->cur_format.accum->str, '0');
+                               if (zero)
+                                       *zero = '?';
+                               min_i_chars--;
+                       }
+                       g_print ("format: %s\n", state->cur_format.accum->str);
+               } else 
+                       go_format_generate_number_str (state->cur_format.accum, min_i_digits, decimal_places,
+                                                      grouping, FALSE, FALSE, NULL, NULL);
+               
+       } else
                g_string_append (state->cur_format.accum, go_format_as_XL (go_format_general ()));
 }
 


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