[gnumeric] xlsx: make sure Excel can read our xml.



commit 9a3f14c87e9299cbd5d43a1503e3d3e29b260ab9
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 20 13:24:32 2014 -0400

    xlsx: make sure Excel can read our xml.

 plugins/excel/ChangeLog    |    6 ++++++
 plugins/excel/xlsx-read.c  |    9 ++++++---
 plugins/excel/xlsx-write.c |   33 ++++++++++++++++++++-------------
 3 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index e4789f5..824dc26 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-20  Morten Welinder  <terra gnome org>
+
+       * xlsx-write.c (xlsx_write_background): Be careful about fields
+       ordering.  Excel cares.
+       (xlsx_write_cond_rule): Fix misunderstanding about type names.
+
 2014-03-19  Morten Welinder  <terra gnome org>
 
        * xlsx-write.c (xlsx_find_predefined_fill): Take care not to drop
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 2a0e619..8d07687 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -2534,13 +2534,16 @@ xlsx_cond_fmt_rule_begin (GsfXMLIn *xin, xmlChar const **attrs)
                { "uniqueValues",       XLSX_CF_TYPE_UNIQUE_VALUES },
                { "duplicateValues",    XLSX_CF_TYPE_DUPLICATE_VALUES },
                { "containsText",       XLSX_CF_TYPE_CONTAINS_STR },
-               { "doesNotContainText", XLSX_CF_TYPE_NOT_CONTAINS_STR },
+               { "doesNotContainText", XLSX_CF_TYPE_NOT_CONTAINS_STR },  /* ??? */
+               { "notContainsText",    XLSX_CF_TYPE_NOT_CONTAINS_STR },
                { "beginsWith",         XLSX_CF_TYPE_BEGINS_WITH },
                { "endsWith",           XLSX_CF_TYPE_ENDS_WITH },
                { "containsBlanks",     XLSX_CF_TYPE_CONTAINS_BLANKS },
-               { "containsNoBlanks",   XLSX_CF_TYPE_NOT_CONTAINS_BLANKS },
+               { "containsNoBlanks",   XLSX_CF_TYPE_NOT_CONTAINS_BLANKS },  /* ??? */
+               { "notContainsBlanks",  XLSX_CF_TYPE_NOT_CONTAINS_BLANKS },
                { "containsErrors",     XLSX_CF_TYPE_CONTAINS_ERRORS },
-               { "containsNoErrors",   XLSX_CF_TYPE_NOT_CONTAINS_ERRORS },
+               { "containsNoErrors",   XLSX_CF_TYPE_NOT_CONTAINS_ERRORS },  /* ??? */
+               { "notContainsErrors",  XLSX_CF_TYPE_NOT_CONTAINS_ERRORS },
                { "compareColumns",     XLSX_CF_TYPE_COMPARE_COLUMNS },
                { "timePeriod",         XLSX_CF_TYPE_TIME_PERIOD },
                { "aboveAverage",       XLSX_CF_TYPE_ABOVE_AVERAGE },
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 4f9d99f..e2e55a3 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -637,6 +637,8 @@ xlsx_write_background (XLSXWriteState *state, GsfXMLOut *xml,
         * for dxfs with solid fills for no apparent reason.
         */
        gboolean invert = FALSE;
+       GnmColor *fg;
+       GnmColor *bg;
 
        gsf_xml_out_start_element (xml, "fill");
        gsf_xml_out_start_element (xml, "patternFill");
@@ -652,17 +654,22 @@ xlsx_write_background (XLSXWriteState *state, GsfXMLOut *xml,
                gsf_xml_out_add_cstr_unchecked (xml, "patternType", type);
        }
 
-       if (gnm_style_is_element_set (style, MSTYLE_COLOR_BACK))
-               xlsx_write_color_element
-                       (xml,
-                        invert ? "bgColor" : "fgColor",
-                        gnm_style_get_back_color (style)->go_color);
+       fg = gnm_style_is_element_set (style, MSTYLE_COLOR_BACK)
+               ? gnm_style_get_back_color (style)
+               : NULL;
+       bg = gnm_style_is_element_set (style, MSTYLE_COLOR_PATTERN)
+               ? gnm_style_get_pattern_color (style)
+               : NULL;
+       if (invert) {
+               GnmColor *tmp = fg;
+               fg = bg;
+               bg = tmp;
+       }
 
-       if (gnm_style_is_element_set (style, MSTYLE_COLOR_PATTERN))
-               xlsx_write_color_element
-                       (xml,
-                        invert ? "fgColor" : "bgColor",
-                        gnm_style_get_pattern_color (style)->go_color);
+       if (fg)
+               xlsx_write_color_element (xml, "fgColor", fg->go_color);
+       if (bg)
+               xlsx_write_color_element (xml, "bgColor", bg->go_color);
 
        gsf_xml_out_end_element (xml);
        gsf_xml_out_end_element (xml);
@@ -1587,13 +1594,13 @@ xlsx_write_cond_rule (XLSXWriteState *state, GsfXMLOut *xml,
                n = 0; type = "containsBlanks";
                break;
        case GNM_STYLE_COND_NOT_CONTAINS_BLANKS:
-               n = 0; type = "containsNoBlanks";
+               n = 0; type = "notContainsBlanks";
                break;
        case GNM_STYLE_COND_CONTAINS_ERR:
                n = 0; type = "containsErrors";
                break;
        case GNM_STYLE_COND_NOT_CONTAINS_ERR:
-               n = 0; type = "containsNoErrors";
+               n = 0; type = "notContainsErrors";
                break;
        case GNM_STYLE_COND_CUSTOM:
                n = 1; type = "expression";
@@ -1602,7 +1609,7 @@ xlsx_write_cond_rule (XLSXWriteState *state, GsfXMLOut *xml,
                n = 1; type = "containsText";
                break;
        case GNM_STYLE_COND_NOT_CONTAINS_STR:
-               n = 1; type = "doesNotContainText";
+               n = 1; type = "notContainsText";
                break;
        case GNM_STYLE_COND_BEGINS_WITH_STR:
                n = 1; type = "beginsWith";


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