[gnumeric] xlsx: don't write % for overlap and gap after all.



commit 30082a1299f9848ffa9607b44853fb90177add16
Author: Morten Welinder <terra gnome org>
Date:   Wed Jan 21 10:26:45 2015 -0500

    xlsx: don't write % for overlap and gap after all.
    
    The spec insists on having a % there:
    
          <xsd:pattern value="0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%"/>
    
    but Excel cannot handle it.  Go figure.  (Local copy of spec modified
    to handle either.)
    
    We will still read either.

 plugins/excel/xlsx-read-drawing.c  |    2 ++
 plugins/excel/xlsx-write-drawing.c |   11 ++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 8f6498d..402d672 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -443,6 +443,7 @@ xlsx_chart_bar_overlap (GsfXMLIn *xin, xmlChar const **attrs)
 
        for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
                if (0 == strcmp (attrs[0], "val")) {
+                       /* Spec says add "%" at end; XL cannot handle that. */
                        int overlap = strtol (attrs[1], NULL, 10);
                        g_object_set (G_OBJECT (state->plot),
                                      "overlap-percentage", CLAMP (overlap, -100, 100),
@@ -476,6 +477,7 @@ xlsx_chart_bar_gap (GsfXMLIn *xin, xmlChar const **attrs)
        for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
                if (0 == strcmp (attrs[0], "val")) {
                        int gap = strtol (attrs[1], NULL, 10);
+                       /* Spec says add "%" at end; XL cannot handle that. */
                        g_object_set (G_OBJECT (state->plot),
                                      "gap-percentage", CLAMP (gap, 0, 500), NULL);
                }
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index f16388f..1d67558 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -588,7 +588,6 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
 
        switch (plot_type) {
        case XLSX_PT_GOGBARCOLPLOT: {
-               char *s;
                int overlap_percentage, gap_percentage;
 
                g_object_get (G_OBJECT (plot),
@@ -596,13 +595,11 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
                        "gap-percentage",       &gap_percentage,
                        NULL);
 
-               s = g_strdup_printf ("%d%%", CLAMP (gap_percentage, 0, 500));
-               xlsx_write_chart_cstr_unchecked (xml, "c:gapWidth", s);
-               g_free (s);
+               /* Spec says add "%" at end; XL cannot handle that. */
+               xlsx_write_chart_int (xml, "c:gapWidth", 150, CLAMP (gap_percentage, 0, 500));
 
-               s = g_strdup_printf ("%d%%", CLAMP (overlap_percentage, 0, 100));
-               xlsx_write_chart_cstr_unchecked (xml, "c:overlap", s);
-               g_free (s);
+               /* Spec says add "%" at end; XL cannot handle that. */
+               xlsx_write_chart_int (xml, "c:overlap", 0, CLAMP (overlap_percentage, 0, 100));
                break;
        }
 


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