[gnumeric] xlsx: export bicolor gradients



commit 5e2483faf122fdf789390e6deb00589925f264d4
Author: Morten Welinder <terra gnome org>
Date:   Wed Feb 18 14:56:31 2015 -0500

    xlsx: export bicolor gradients

 NEWS                               |    3 +-
 plugins/excel/xlsx-write-drawing.c |   40 +++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 562e311..51b70cd 100644
--- a/NEWS
+++ b/NEWS
@@ -16,11 +16,12 @@ Andreas:
 Morten:
        * Initial xlsx import of sheet widgets.
        * Initial xlsx export of sheet widgets.
-       * xlsx import/exports of patterns.
+       * xlsx import/export of patterns.
        * Plug leaks.
        * Arrow properties editor.  [#158327]
        * Fix xlsx export of line style None.
        * Fix search-and-replace problem with text format.
+       * xlsx export of gradients.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.20
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index ece36b7..f7d393e 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -317,9 +317,47 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
 
                        break;
                }
-               case GO_STYLE_FILL_GRADIENT:
+               case GO_STYLE_FILL_GRADIENT: {
+                       GOGradientDirection dir = style->fill.gradient.dir;
+                       static gint16 angles[GO_GRADIENT_MAX] = {
+                               90, 270, 90, 90,
+                               0, 180, 0, 0,
+                               45, 225, 45, 45,
+                               135, 315, 135, 135
+                       };
+                       static gint8 flags[GO_GRADIENT_MAX] = {
+                               0, 0, 1, 3,
+                               0, 0, 1, 3,
+                               0, 0, 1, 3,
+                               0, 0, 1, 3
+                       };
+                       int i, N = (flags[dir] & 1) ? 3 : 2;
+                       gboolean rev = (flags[dir] & 2) != 0;
+
+                       /* FIXME: Unicolor? */
+                       gsf_xml_out_start_element (xml, "a:gradFill");
+                       gsf_xml_out_start_element (xml, "a:gsLst");
+                       for (i = 0; i < N; i++) {
+                               gboolean fore = rev ^ (i == 1);
+                               unsigned pos = (i == 0)
+                                       ? 0
+                                       : (i == N - 1 ? 100 * 1000 : 50 * 1000);
+                               gsf_xml_out_start_element (xml, "a:gs");
+                               gsf_xml_out_add_uint (xml, "pos", pos);
+                               xlsx_write_rgbarea (xml,
+                                                   fore
+                                                   ? style->fill.pattern.fore
+                                                   : style->fill.pattern.back);
+                               gsf_xml_out_end_element (xml); /* "a:gs" */
+                       }
+                       gsf_xml_out_end_element (xml); /* "a:gsLst" */
+                       gsf_xml_out_start_element (xml, "a:lin");
+                       gsf_xml_out_add_uint (xml, "ang", 60000 * angles[dir]);
+                       gsf_xml_out_end_element (xml);
+                       gsf_xml_out_end_element (xml); /* "a:gradFill" */
                        break;
                }
+               }
        }
 
        if ((style->interesting_fields & (GO_STYLE_LINE | GO_STYLE_OUTLINE)) &&


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