[gnumeric] xlsx: import sheet state (visibility)



commit bb31ac42ffca41880c7a0834b40a3a356441998e
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 3 15:58:02 2011 -0500

    xlsx: import sheet state (visibility)

 NEWS                      |    1 +
 plugins/excel/ChangeLog   |    1 +
 plugins/excel/xlsx-read.c |   18 +++++++++++++++++-
 3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 11d187e..e0c7930 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Morten:
 	* Fix xml reading of constraints.  [Redhat #680572]
 	* Fix lpsolve/glpk writing of affine part.
 	* Fix xlsx import crash.  [#643808]
+	* Import sheet visibility from xlsx.  [#643815]
 
 Stanley Pinchak:
 	* Improve "dif" output.
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index c1ec2ee..78d9abd 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -2,6 +2,7 @@
 
 	* xlsx-read.c (xlsx_chart_text): Avoid criticals in the absense of
 	chart text.
+	(xlsx_sheet_begin): Import sheet state.  Fixes #643815.
 
 2011-02-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index e766556..8787b8e 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -71,6 +71,8 @@
 
 /*****************************************************************************/
 
+#define CXML2C(s) ((char const *)(s))
+
 typedef enum {
 	XLXS_TYPE_NUM,
 	XLXS_TYPE_SST_STR,	/* 0 based index into sst */
@@ -4213,11 +4215,24 @@ xlsx_sheet_begin (GsfXMLIn *xin, xmlChar const **attrs)
 	char const *name = NULL;
 	char const *part_id = NULL;
 	Sheet *sheet;
+	GnmSheetVisibility viz = GNM_SHEET_VISIBILITY_VISIBLE;
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (0 == strcmp (attrs[0], "name"))
 			name = attrs[1];
-		else if (gsf_xml_in_namecmp (xin, attrs[0], XL_NS_DOC_REL, "id"))
+		else if (0 == strcmp (attrs[0], "state")) {
+			const char *s = CXML2C (attrs[1]);
+			if (strcmp (s, "visible") == 0)
+				viz = GNM_SHEET_VISIBILITY_VISIBLE;
+			else if (strcmp (s, "hidden") == 0)
+				viz = GNM_SHEET_VISIBILITY_HIDDEN;
+			else if (strcmp (s, "veryHidden") == 0)
+				viz = GNM_SHEET_VISIBILITY_VERY_HIDDEN;
+			else
+				xlsx_warning (xin,
+					      _("Unrecognized sheet state %s"),
+					      s);
+		} else if (gsf_xml_in_namecmp (xin, attrs[0], XL_NS_DOC_REL, "id"))
 			part_id = attrs[1];
 
 	if (NULL == name) {
@@ -4230,6 +4245,7 @@ xlsx_sheet_begin (GsfXMLIn *xin, xmlChar const **attrs)
 		sheet = sheet_new (state->wb, name, XLSX_MaxCol, XLSX_MaxRow);
 		workbook_sheet_attach (state->wb, sheet);
 	}
+	g_object_set (sheet, "visibility", viz, NULL);
 
 	g_object_set_data_full (G_OBJECT (sheet), "_XLSX_RelID", g_strdup (part_id),
 		(GDestroyNotify) g_free);



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