[gnumeric] xlsx: more fiddling with markers and auto flags.



commit 16bdad87f97e6350fa840e1892b51d13b460656b
Author: Morten Welinder <terra gnome org>
Date:   Sat Jan 17 12:49:36 2015 -0500

    xlsx: more fiddling with markers and auto flags.

 plugins/excel/xlsx-read-drawing.c  |   26 +++++++++++++++-----------
 plugins/excel/xlsx-read.c          |    1 -
 plugins/excel/xlsx-write-drawing.c |   22 ++++++++++++++--------
 3 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index b6abae6..b64ec12 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -1238,10 +1238,15 @@ xlsx_style_line_start (GsfXMLIn *xin, xmlChar const **attrs)
        state->sp_type |= GO_STYLE_LINE;
        if (!state->cur_style)
                state->cur_style = (GOStyle *) gog_style_new ();
-       
-       state->cur_style->line.auto_width = (w < 0);
-       if (!state->cur_style->line.auto_width)
+
+       if (w == 0) {
+               /* Special meaning of zero width  */
+               state->cur_style->line.auto_dash = FALSE;
+               state->cur_style->line.dash_type = GO_LINE_NONE;
+       } else if (w > 0) {
+               state->cur_style->line.auto_width = FALSE;
                state->cur_style->line.width = w / 12700.;
+       }
        state->gocolor = &state->cur_style->line.color;
        state->auto_color = &state->cur_style->line.auto_color;
 }
@@ -1478,9 +1483,8 @@ xlsx_draw_line_dash (GsfXMLIn *xin, xmlChar const **attrs)
 static void
 xlsx_chart_marker_start (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
 {
-       XLSXReadState   *state = (XLSXReadState *)xin->user_state;
+       XLSXReadState *state = (XLSXReadState *)xin->user_state;
        state->marker = go_marker_new ();
-       state->marker_symbol = GO_MARKER_MAX;
 }
 
 static void
@@ -1502,8 +1506,12 @@ xlsx_chart_marker_symbol (GsfXMLIn *xin, xmlChar const **attrs)
        };
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
        int symbol;
-       if (NULL != state->marker && simple_enum (xin, attrs, symbols, &symbol))
-               state->marker_symbol = symbol;
+       if (NULL != state->marker && simple_enum (xin, attrs, symbols, &symbol)) {
+               if (symbol < GO_MARKER_MAX) {
+                       go_marker_set_shape (state->marker, symbol);
+                       state->cur_style->marker.auto_shape = FALSE;
+               }
+       }
 }
 
 static void
@@ -1522,10 +1530,6 @@ xlsx_chart_marker_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
        if (NULL != state->cur_obj && GOG_IS_STYLED_OBJECT (state->cur_obj)) {
-               if (state->marker_symbol != GO_MARKER_MAX) {
-                       state->cur_style->marker.auto_shape = FALSE;
-                       go_marker_set_shape (state->marker, state->marker_symbol);
-               }
                go_style_set_marker (state->cur_style, state->marker);
                state->marker = NULL;
                state->gocolor = NULL;
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index d321e75..4fb8cb6 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -211,7 +211,6 @@ typedef struct {
        GOColor           color;
        gpointer          color_data;
        GOMarker         *marker;
-       GOMarkerShape     marker_symbol;
        GogObject        *cur_obj;
        GSList           *obj_stack;
        GSList           *style_stack;
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index b53ec2c..21af776 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -134,7 +134,7 @@ 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 */
+           !style->line.auto_dash) {/* TODO: add more tests for transparent line */
                static const char * const dashes[] = {
                        NULL,            /* GO_LINE_NONE */
                        "solid",         /* GO_LINE_SOLID */
@@ -149,10 +149,15 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
                        "dashDot",       /* GO_LINE_DASH_DOT */
                        "lgDashDot",     /* GO_LINE_DASH_DOT_DOT */
                };
+               gboolean is_none = (style->line.dash_type == GO_LINE_NONE);
 
                gsf_xml_out_start_element (xml, "a:ln");
-               if (!style->line.auto_width && style->line.width > 0)
+               if (is_none) {
+                       /* Special meaning of zero width  */
+                       gsf_xml_out_add_int (xml, "w", 0);
+               } else if (!style->line.auto_width && style->line.width > 0)
                        gsf_xml_out_add_int (xml, "w", style->line.width * 12700);
+
                if (!style->line.auto_color) {
                        gsf_xml_out_start_element (xml, "a:solidFill");
                        xlsx_write_rgbarea (xml, style->line.color);
@@ -215,11 +220,11 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
                        "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 */
+                       "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 */
                };
                gboolean need_spPr;
                GOMarkerShape s = style->marker.auto_shape
@@ -236,7 +241,8 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
                          : "auto"));
                gsf_xml_out_end_element (xml);
 
-               if (!style->marker.auto_shape) {
+               /* We don't have an auto_size flag */
+               if (TRUE) {
                        gsf_xml_out_start_element (xml, "c:size");
                        gsf_xml_out_add_int (xml, "val", go_marker_get_size (style->marker.mark));
                        gsf_xml_out_end_element (xml);


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