[gnumeric] xlsx: first go at exporting markers.



commit 30df0d804018a61b54cc078ad8d64f3387fd7673
Author: Morten Welinder <terra gnome org>
Date:   Fri Jan 16 22:02:34 2015 -0500

    xlsx: first go at exporting markers.
    
    It looks like the four different triangle directions can be handled
    with shape properties that rotate the marker.  This needs to be
    investigated.

 NEWS                               |    2 +-
 plugins/excel/ChangeLog            |    1 +
 plugins/excel/xlsx-read-drawing.c  |    1 +
 plugins/excel/xlsx-write-drawing.c |   38 +++++++++++++++++++++++++++++++++++-
 4 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 8ccc339..8967076 100644
--- a/NEWS
+++ b/NEWS
@@ -26,7 +26,7 @@ Morten:
        * Fix sheet-filter problem with errors.  [#742601]
        * Improve error handling for .gnumeric a bit.
        * Improve xlsx graph import: line colour.
-       * Improve xlsx graph export: line style; bar/col direction.
+       * Improve xlsx graph export: line style; bar/col direction; marker shapes.
 
 Thomas Kluyver:
        * Fix import of extended floats from wk4 files.  [#739679]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index ffba84e..54255cb 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,6 +1,7 @@
 2015-01-16  Morten Welinder  <terra gnome org>
 
        * xlsx-write-drawing.c (xlsx_write_go_style): Export line style.
+       (xlsx_write_go_style): Have a first go at exporting marker shapes.
 
        * xlsx-read-drawing.c (xlsx_style_line_start): Also point to the
        right auto_color location so we don't end up ignoring the colors
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 145f3ad..6a66c52 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -1490,6 +1490,7 @@ xlsx_chart_marker_symbol (GsfXMLIn *xin, xmlChar const **attrs)
                { "star",       GO_MARKER_ASTERISK },           /* CHECK ME */
                { "triangle",   GO_MARKER_TRIANGLE_UP },        /* FIXME */
                { "x",          GO_MARKER_X },
+               { "auto",       GO_MARKER_MAX },
                { NULL, 0 }
        };
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index d95ece6..8a75179 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -132,6 +132,7 @@ static void
 xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
 {
        gsf_xml_out_start_element (xml, "c:spPr");
+
        if ((style->interesting_fields & (GO_STYLE_LINE | GO_STYLE_OUTLINE)) &&
            style->line.dash_type != GO_LINE_NONE) {/* TODO: add more tests for transparent line */
                static const char * const dashes[] = {
@@ -167,6 +168,7 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
 
                gsf_xml_out_end_element (xml);
        }
+
        if ((style->interesting_fields & GO_STYLE_FILL) &&
            style->fill.type != GO_STYLE_FILL_NONE) {/* TODO add tests for transparent backgrounds */
                switch (style->fill.type) {
@@ -196,8 +198,42 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
                        break;
                }
        }
-       gsf_xml_out_end_element (xml);
+
+       gsf_xml_out_end_element (xml);  /* "c:spPr" */
+
        if (style->interesting_fields & GO_STYLE_MARKER) {
+               static const char *const markers[] = {
+                       NULL,         /* GO_MARKER_NONE */
+                       "square",     /* GO_MARKER_SQUARE */
+                       "diamond",    /* GO_MARKER_DIAMOND */
+                       "triangle",   /* GO_MARKER_TRIANGLE_DOWN */   /* FIXME: rotation */
+                       "triangle",   /* GO_MARKER_TRIANGLE_UP */     /* FIXME: rotation */
+                       "triangle",   /* GO_MARKER_TRIANGLE_RIGHT */  /* FIXME: rotation */
+                       "triangle",   /* GO_MARKER_TRIANGLE_LEFT */   /* FIXME: rotation */
+                       "circle",     /* GO_MARKER_CIRCLE */
+                       "x",          /* GO_MARKER_X */
+                       "plus",       /* GO_MARKER_CROSS */
+                       "star",       /* GO_MARKER_ASTERISK */
+                       NULL,         /* GO_MARKER_BAR */
+                       NULL,         /* GO_MARKER_HALF_BAR */
+                       NULL,         /* GO_MARKER_BUTTERFLY */
+                       NULL,         /* GO_MARKER_HOURGLASS */
+                       NULL          /* GO_MARKER_LEFT_HALF_BAR */
+               };
+
+               gsf_xml_out_start_element (xml, "c:marker");
+
+               gsf_xml_out_start_element (xml, "c:symbol");
+               if (style->marker.auto_shape)
+                       gsf_xml_out_add_cstr_unchecked (xml, "val", "auto");
+               else {
+                       GOMarkerShape s = go_marker_get_shape (style->marker.mark);
+                       if (s < G_N_ELEMENTS (markers) && markers[s])
+                               gsf_xml_out_add_cstr_unchecked (xml, "val", markers[s]);
+               }               
+               gsf_xml_out_end_element (xml);
+
+               gsf_xml_out_end_element (xml);
        }
 }
 


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