[gnumeric] xlsx: roundtrip marker triangles other than up.



commit 4ec369200ba40786e0bd99b2826850ee9e970fcf
Author: Morten Welinder <terra gnome org>
Date:   Fri Jan 23 19:35:51 2015 -0500

    xlsx: roundtrip marker triangles other than up.
    
    We use rotation for this.  It's in the spec, but I doubt any other
    xlsx consumer can read it.

 plugins/excel/ChangeLog            |    4 +++
 plugins/excel/xlsx-read-drawing.c  |   41 ++++++++++++++++++++++++++++++-----
 plugins/excel/xlsx-write-drawing.c |    7 ++++++
 3 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index b4e98ce..d177c14 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,6 +1,10 @@
 2015-01-23  Morten Welinder  <terra gnome org>
 
+       * xlsx-write-drawing.c (xlsx_write_go_style_full): Use rotation to
+       handle marker triangles other than up.
+
        * xlsx-read-drawing.c (xlsx_rpr_latin): Read typeface from xlsx charts.
+       (xlsx_sppr_xfrm): Rotate marker shapes.
 
 2015-01-23  Morten Welinder <terra gnome org>
 
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 83dce71..51f0e4c 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -1693,11 +1693,10 @@ static void
 xlsx_chart_marker_size (GsfXMLIn *xin, xmlChar const **attrs)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
-       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
-               int sz;
-               if (simple_int (xin, attrs, &sz))
-                       go_marker_set_size (state->marker, sz);
-       }
+       int sz;
+
+       if (simple_int (xin, attrs, &sz))
+               go_marker_set_size (state->marker, sz);
 }
 
 static void
@@ -1714,6 +1713,36 @@ xlsx_chart_marker_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 }
 
 static void
+xlsx_sppr_xfrm (GsfXMLIn *xin, xmlChar const **attrs)
+{
+       XLSXReadState *state = (XLSXReadState *)xin->user_state;
+       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
+               int rot;
+               if (attr_int (xin, attrs, "rot", &rot)) {
+                       rot = rot % (360 * 60000);
+                       if (rot < 0) rot += 360 * 60000;
+
+                       if (state->marker && go_marker_get_shape (state->marker) == GO_MARKER_TRIANGLE_UP) {
+                               switch ((rot + 45 * 60000) / (90 * 60000)) {
+                               case 1:
+                                       go_marker_set_shape (state->marker, GO_MARKER_TRIANGLE_RIGHT);
+                                       break;
+                               case 2:
+                                       go_marker_set_shape (state->marker, GO_MARKER_TRIANGLE_DOWN);
+                                       break;
+                               case 3:
+                                       go_marker_set_shape (state->marker, GO_MARKER_TRIANGLE_LEFT);
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+       }
+}
+
+
+static void
 xlsx_plot_area (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
@@ -1810,7 +1839,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
   GSF_XML_IN_NODE (CHART_SPACE, DATE1904, XL_NS_CHART, "date1904", GSF_XML_NO_CONTENT, NULL, NULL),
   GSF_XML_IN_NODE (CHART_SPACE, ROUNDEDCORNERS, XL_NS_CHART, "roundedCorners", GSF_XML_NO_CONTENT, NULL, 
NULL),
   GSF_XML_IN_NODE (CHART_SPACE, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL),
-    GSF_XML_IN_NODE (SHAPE_PR, SP_XFRM, XL_NS_DRAW, "xfrm", GSF_XML_NO_CONTENT, NULL, NULL),
+    GSF_XML_IN_NODE (SHAPE_PR, SP_XFRM, XL_NS_DRAW, "xfrm", GSF_XML_NO_CONTENT, &xlsx_sppr_xfrm, NULL),
       GSF_XML_IN_NODE (SP_XFRM, SP_XFRM_OFF, XL_NS_DRAW, "off", GSF_XML_NO_CONTENT, NULL, NULL),
       GSF_XML_IN_NODE (SP_XFRM, SP_XFRM_EXT, XL_NS_DRAW, "ext", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (SHAPE_PR, SP_PR_PRST_GEOM, XL_NS_DRAW, "prstGeom", GSF_XML_NO_CONTENT, NULL, NULL),
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index 297473a..5577a04 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -229,6 +229,7 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style,
                        "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 };
                gboolean need_spPr;
                GOMarkerShape s = style->marker.auto_shape
                        ? (def_has_markers ? GO_MARKER_MAX : GO_MARKER_NONE)
@@ -253,6 +254,12 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style,
                if (need_spPr) {
                        gsf_xml_out_start_element (xml, "c:spPr");
 
+                       if (nqturns[s]) {
+                               gsf_xml_out_start_element (xml, "a:xfrm");
+                               gsf_xml_out_add_int (xml, "rot", nqturns[s] * (90 * 60000));
+                               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));


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