[gnumeric] xlsx: fix roundtrip of sheet object print flag.



commit f84e2eedd7e0759fdc0df912e56dc78647750b30
Author: Morten Welinder <terra gnome org>
Date:   Tue May 5 22:50:06 2020 -0400

    xlsx: fix roundtrip of sheet object print flag.

 NEWS                               |  1 +
 plugins/excel/ChangeLog            |  6 ++++++
 plugins/excel/xlsx-read-drawing.c  | 17 ++++++++++++++++-
 plugins/excel/xlsx-write-drawing.c |  7 ++++++-
 4 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 8c3549309..b6604cc76 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ Morten:
        * Handle export options for ssconvert --export-graphs.
        * Fix deps crash.  [#480]
        * Fix chart name roundtrip through XLSX.  [#478]
+       * Fix sheet object print flag roundtrip through XLSX.  [#486]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.46
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 86c4e21ab..a430e4728 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-05  Morten Welinder  <terra gnome org>
+
+       * xlsx-read-drawing.c (xlsx_draw_clientdata): Read sheet object
+       print flag.
+       * xlsx-write-drawing.c (xlsx_write_drawing_objects): Write it.
+
 2020-05-03  Morten Welinder  <terra gnome org>
 
        * xlsx-read-drawing.c (xlsx_drawing_twoCellAnchor_end): Set sheet
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index f75114d26..586e62027 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -517,6 +517,21 @@ xlsx_draw_color_scrgb (GsfXMLIn *xin, xmlChar const **attrs)
        color_set_helper (state);
 }
 
+static void
+xlsx_draw_clientdata (GsfXMLIn *xin, xmlChar const **attrs)
+{
+       XLSXReadState *state = (XLSXReadState *)xin->user_state;
+       gboolean print = TRUE;
+
+       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
+               if (attr_bool (xin, attrs, "fPrintsWithSheet", &print)) {
+                       /* Nothing more */
+               }
+       }
+
+       sheet_object_set_print_flag (state->so, &print);
+}
+
 static GsfXMLInNode const xlsx_chart_drawing_dtd[] =
 {
 GSF_XML_IN_NODE_FULL (START, START, -1, NULL, GSF_XML_NO_CONTENT, FALSE, TRUE, NULL, NULL, 0),
@@ -3605,7 +3620,7 @@ GSF_XML_IN_NODE_FULL (START, DRAWING, XL_NS_SS_DRAW, "wsDr", GSF_XML_NO_CONTENT,
       GSF_XML_IN_NODE (GRAPHIC_FRAME, TWO_CELL_XFRM, XL_NS_SS_DRAW, "xfrm", GSF_XML_NO_CONTENT, 
&xlsx_sppr_xfrm, NULL),
         GSF_XML_IN_NODE (TWO_CELL_XFRM, XFRM_OFF, XL_NS_DRAW, "off", GSF_XML_NO_CONTENT, NULL, NULL),
         GSF_XML_IN_NODE (TWO_CELL_XFRM, XFRM_EXT, XL_NS_DRAW, "ext", GSF_XML_NO_CONTENT, NULL, NULL),
-    GSF_XML_IN_NODE (TWO_CELL, CLIENT_DATA, XL_NS_SS_DRAW, "clientData", GSF_XML_NO_CONTENT, NULL, NULL),
+    GSF_XML_IN_NODE (TWO_CELL, CLIENT_DATA, XL_NS_SS_DRAW, "clientData", GSF_XML_NO_CONTENT, 
&xlsx_draw_clientdata, NULL),
     GSF_XML_IN_NODE (TWO_CELL, CONTENT_PART, XL_NS_SS_DRAW, "contentPart", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (TWO_CELL, CXN_SP, XL_NS_SS_DRAW, "cxnSp", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (TWO_CELL, PICTURE, XL_NS_SS_DRAW, "pic", GSF_XML_NO_CONTENT, &xlsx_drawing_picture, 
NULL),
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index a8d492e11..f063f9fa2 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -1679,7 +1679,12 @@ xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
                        g_free (sctx.start_arrow);
                        g_free (sctx.end_arrow);
                }
-               gsf_xml_out_simple_element (xml, "xdr:clientData", NULL);
+
+               gsf_xml_out_start_element (xml, "xdr:clientData");
+               if (!sheet_object_get_print_flag (so))
+                       xlsx_add_bool (xml, "fPrintsWithSheet", FALSE);
+               gsf_xml_out_end_element (xml); /* </xdr:clientData> */
+
                gsf_xml_out_end_element (xml); /* </xdr:twoCellAnchor> */
        }
        g_slist_free (rIds);


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