[gnumeric] xlsx: export per-point marker style when needed.



commit e2c7abf6c15b2dd10bdecd8d5c93f44166791ae8
Author: Morten Welinder <terra gnome org>
Date:   Tue Feb 24 09:49:44 2015 -0500

    xlsx: export per-point marker style when needed.
    
    Also add test for that.

 plugins/excel/xlsx-read-drawing.c  |   10 +--
 plugins/excel/xlsx-write-drawing.c |  178 +++++++++++++++++++++---------------
 samples/graph-tests.gnumeric       |  Bin 9426 -> 10531 bytes
 3 files changed, 106 insertions(+), 82 deletions(-)
---
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index c932d70..42cb374 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -2099,15 +2099,6 @@ xlsx_chart_pop (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        xlsx_chart_pop_obj ((XLSXReadState *)xin->user_state);
 }
 
-#if 0
-/* this adds a NULL object so that the style is not polluted by unsupported things */
-static void
-xlsx_chart_start_dummy (GsfXMLIn *xin, xmlChar const **attrs)
-{
-       xlsx_chart_push_obj ((XLSXReadState *)xin->user_state, NULL);
-}
-#endif
-
 static void
 xlsx_chart_layout_manual (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
@@ -2560,6 +2551,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
            GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_PERCENT, XL_NS_CHART, "showPercent", GSF_XML_NO_CONTENT, 
NULL, NULL),
 
           GSF_XML_IN_NODE (SERIES, SERIES_PT, XL_NS_CHART,     "dPt", GSF_XML_NO_CONTENT, 
&xlsx_chart_pt_start, &xlsx_chart_pt_end),
+            GSF_XML_IN_NODE (SERIES_PT, BUBBLE3D, XL_NS_CHART, "bubble3D", GSF_XML_NO_CONTENT, NULL, NULL),
             GSF_XML_IN_NODE (SERIES_PT, PT_IDX, XL_NS_CHART,   "idx", GSF_XML_NO_CONTENT, 
&xlsx_chart_pt_index, NULL),
             GSF_XML_IN_NODE (SERIES_PT, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL),
             GSF_XML_IN_NODE (SERIES_PT, PT_SEP, XL_NS_CHART,   "explosion", GSF_XML_NO_CONTENT, 
&xlsx_chart_pt_sep, NULL),
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index ac148d3..8eb1277 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -209,6 +209,87 @@ xlsx_style_context_init (XLSXStyleContext *sctx, XLSXWriteState *state)
 }
 
 static void
+xlsx_write_go_style_marker (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext *sctx)
+{
+       static const char *const markers[] = {
+               "none",       /* GO_MARKER_NONE */
+               "square",     /* GO_MARKER_SQUARE */
+               "diamond",    /* GO_MARKER_DIAMOND */
+               "triangle",   /* GO_MARKER_TRIANGLE_DOWN */
+               "triangle",   /* GO_MARKER_TRIANGLE_UP */
+               "triangle",   /* GO_MARKER_TRIANGLE_RIGHT */
+               "triangle",   /* GO_MARKER_TRIANGLE_LEFT */
+               "circle",     /* GO_MARKER_CIRCLE */
+               "x",          /* GO_MARKER_X */
+               "plus",       /* GO_MARKER_CROSS */
+               "star",       /* GO_MARKER_ASTERISK */
+               "dash",       /* GO_MARKER_BAR */
+               "dot",        /* GO_MARKER_HALF_BAR */
+               "diamond",    /* GO_MARKER_BUTTERFLY */       /* FIXME: dubious */
+               "diamond",    /* GO_MARKER_HOURGLASS */       /* FIXME: dubious */
+               "dot"         /* GO_MARKER_LEFT_HALF_BAR */
+       };
+       static gint8 nqturns[] = { 0, 0, 0, 2, 0, +1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+       static gint8 flipH[] =   { 0, 0, 0, 0, 0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
+       gboolean need_spPr;
+       GOMarkerShape s;
+
+       if ((style->interesting_fields & GO_STYLE_MARKER) == 0)
+               return;
+
+       s = style->marker.auto_shape
+               ? (sctx->def_has_markers ? GO_MARKER_MAX : GO_MARKER_NONE)
+               : go_marker_get_shape (style->marker.mark);
+
+       gsf_xml_out_start_element (xml, "c:marker");
+
+       xlsx_write_chart_cstr_unchecked
+               (xml, "c:symbol",
+                (s < G_N_ELEMENTS (markers) && markers[s]
+                 ? markers[s]
+                 : "auto"));
+
+       /* We don't have an auto_size flag */
+       if (TRUE) {
+               int def = 5, s = go_marker_get_size (style->marker.mark);
+               xlsx_write_chart_int (xml, "c:size", def, s);
+       }
+
+       need_spPr = (!style->marker.auto_fill_color ||
+                    !style->marker.auto_outline_color);
+       if (need_spPr) {
+               gsf_xml_out_start_element (xml, "c:spPr");
+
+               if (nqturns[s] || flipH[s]) {
+                       gsf_xml_out_start_element (xml, "a:xfrm");
+                       if (nqturns[s])
+                               gsf_xml_out_add_int (xml, "rot", nqturns[s] * (90 * 60000));
+                       if (flipH[s])
+                               gsf_xml_out_add_int (xml, "flipH", flipH[s]);
+                       gsf_xml_out_end_element (xml);
+               }
+
+               if (!style->marker.auto_fill_color) {
+                       gsf_xml_out_start_element (xml, "a:solidFill");
+                       xlsx_write_rgbarea (xml, go_marker_get_fill_color (style->marker.mark));
+                       gsf_xml_out_end_element (xml);
+               }
+
+               if (!style->marker.auto_outline_color) {
+                       gsf_xml_out_start_element (xml, "a:ln");
+                       gsf_xml_out_start_element (xml, "a:solidFill");
+                       xlsx_write_rgbarea (xml, go_marker_get_outline_color (style->marker.mark));
+                       gsf_xml_out_end_element (xml);
+                       gsf_xml_out_end_element (xml);
+               }
+
+               gsf_xml_out_end_element (xml);
+       }
+
+       gsf_xml_out_end_element (xml);
+}
+
+static void
 xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext *sctx)
 {
        gboolean has_font_color = ((style->interesting_fields & GO_STYLE_FONT) &&
@@ -498,79 +579,7 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
                gsf_xml_out_end_element (xml);  /* "c:txPr" */
        }
 
-       if (style->interesting_fields & GO_STYLE_MARKER) {
-               static const char *const markers[] = {
-                       "none",       /* GO_MARKER_NONE */
-                       "square",     /* GO_MARKER_SQUARE */
-                       "diamond",    /* GO_MARKER_DIAMOND */
-                       "triangle",   /* GO_MARKER_TRIANGLE_DOWN */
-                       "triangle",   /* GO_MARKER_TRIANGLE_UP */
-                       "triangle",   /* GO_MARKER_TRIANGLE_RIGHT */
-                       "triangle",   /* GO_MARKER_TRIANGLE_LEFT */
-                       "circle",     /* GO_MARKER_CIRCLE */
-                       "x",          /* GO_MARKER_X */
-                       "plus",       /* GO_MARKER_CROSS */
-                       "star",       /* GO_MARKER_ASTERISK */
-                       "dash",       /* GO_MARKER_BAR */
-                       "dot",        /* GO_MARKER_HALF_BAR */
-                       "diamond",    /* GO_MARKER_BUTTERFLY */       /* FIXME: dubious */
-                       "diamond",    /* GO_MARKER_HOURGLASS */       /* FIXME: dubious */
-                       "dot"         /* GO_MARKER_LEFT_HALF_BAR */
-               };
-               static gint8 nqturns[] = { 0, 0, 0, 2, 0, +1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-               static gint8 flipH[] =   { 0, 0, 0, 0, 0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
-               gboolean need_spPr;
-               GOMarkerShape s = style->marker.auto_shape
-                       ? (sctx->def_has_markers ? GO_MARKER_MAX : GO_MARKER_NONE)
-                       : go_marker_get_shape (style->marker.mark);
-
-               gsf_xml_out_start_element (xml, "c:marker");
-
-               xlsx_write_chart_cstr_unchecked
-                       (xml, "c:symbol",
-                        (s < G_N_ELEMENTS (markers) && markers[s]
-                         ? markers[s]
-                         : "auto"));
-
-               /* We don't have an auto_size flag */
-               if (TRUE) {
-                       int def = 5, s = go_marker_get_size (style->marker.mark);
-                       xlsx_write_chart_int (xml, "c:size", def, s);
-               }
-
-               need_spPr = (!style->marker.auto_fill_color ||
-                            !style->marker.auto_outline_color);
-               if (need_spPr) {
-                       gsf_xml_out_start_element (xml, "c:spPr");
-
-                       if (nqturns[s] || flipH[s]) {
-                               gsf_xml_out_start_element (xml, "a:xfrm");
-                               if (nqturns[s])
-                                       gsf_xml_out_add_int (xml, "rot", nqturns[s] * (90 * 60000));
-                               if (flipH[s])
-                                       gsf_xml_out_add_int (xml, "flipH", flipH[s]);
-                               gsf_xml_out_end_element (xml);
-                       }
-
-                       if (!style->marker.auto_fill_color) {
-                               gsf_xml_out_start_element (xml, "a:solidFill");
-                               xlsx_write_rgbarea (xml, go_marker_get_fill_color (style->marker.mark));
-                               gsf_xml_out_end_element (xml);
-                       }
-
-                       if (!style->marker.auto_outline_color) {
-                               gsf_xml_out_start_element (xml, "a:ln");
-                               gsf_xml_out_start_element (xml, "a:solidFill");
-                               xlsx_write_rgbarea (xml, go_marker_get_outline_color (style->marker.mark));
-                               gsf_xml_out_end_element (xml);
-                               gsf_xml_out_end_element (xml);
-                       }
-
-                       gsf_xml_out_end_element (xml);
-               }
-
-               gsf_xml_out_end_element (xml);
-       }
+       xlsx_write_go_style_marker (xml, style, sctx);
 }
 
 static void
@@ -909,6 +918,29 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
                        xlsx_write_chart_uint (xml, "c:invertIfNegative", 1, 0);
 
                children = gog_object_get_children (GOG_OBJECT (ser), NULL);
+
+               for (l = children; l; l = l->next) {
+                       GogObject *pt = l->data;
+                       unsigned idx;
+                       GOStyle *style;
+                       XLSXStyleContext sctx;
+
+                       if (!GOG_IS_SERIES_ELEMENT (pt))
+                               continue;
+
+                       gsf_xml_out_start_element (xml, "c:dPt");
+
+                       g_object_get (pt, "index", &idx, NULL);
+                       xlsx_write_chart_uint (xml, "c:idx", 0, idx);
+
+                       xlsx_style_context_init (&sctx, state);
+                       sctx.def_has_markers = TRUE;
+                       style = go_styled_object_get_style (GO_STYLED_OBJECT (pt));
+                       xlsx_write_go_style_marker (xml, style, &sctx);
+
+                       gsf_xml_out_end_element (xml); /* </c:dPt> */
+               }
+
                for (l = children; l; l = l->next) {
                        GogObject *trend = l->data;
                        const char *trend_type_name = G_OBJECT_TYPE_NAME (trend);
diff --git a/samples/graph-tests.gnumeric b/samples/graph-tests.gnumeric
index 1804e82..0e5af1c 100644
Binary files a/samples/graph-tests.gnumeric and b/samples/graph-tests.gnumeric differ


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