[gnumeric] Fix import of LibreOffice created xlsx files using shared formulas. [#642850]



commit 73fb0d7449383f40d98d5e15e8894d6589f888c7
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Feb 21 21:45:14 2011 -0700

    Fix import of LibreOffice created xlsx files using shared formulas. [#642850]
    
    2011-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* xlsx-read.c (xlsx_chart_dtd): add c:crossesAt
    	(xlsx_cell_expr_begin): don't ignore shared expressions with
    	duplicate id

 NEWS                      |    2 ++
 plugins/excel/ChangeLog   |    6 ++++++
 plugins/excel/xlsx-read.c |   14 +++++++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index c940a17..0530eb7 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Andreas:
 	* Allow function tooltips to be closed temporarily [#641355]
 	* Import & export list validation from and to ODF files. [#640701]
 	* Minor histogram improvements.
+	* Fix import of LibreOffice created xlsx files using shared formulas. 
+	  [#642850]
 
 Jean:
 	* Fix cursor position inside a cell edited in a zoomed sheet. [#641709]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 36e6393..cc77e7c 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2011-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* xlsx-read.c (xlsx_chart_dtd): add c:crossesAt
+	(xlsx_cell_expr_begin): don't ignore shared expressions with 
+	duplicate id
+
 2011-02-02  Morten Welinder <terra gnome org>
 
 	* Release 1.10.13
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 3befdf0..3da96b3 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -1750,6 +1750,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
       GSF_XML_IN_NODE (PLOTAREA, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL),	/* 2nd Def */
       GSF_XML_IN_NODE_FULL (PLOTAREA, CAT_AXIS, XL_NS_CHART, "catAx", GSF_XML_NO_CONTENT, FALSE, TRUE,
 			    &xlsx_axis_start, &xlsx_axis_end, XLSX_AXIS_CAT),
+        GSF_XML_IN_NODE (CAT_AXIS, AXIS_CROSSES_AT, XL_NS_CHART, "crossesAt", GSF_XML_NO_CONTENT, NULL, NULL),
         GSF_XML_IN_NODE (CAT_AXIS, AXIS_AXID, XL_NS_CHART, "axId", GSF_XML_NO_CONTENT, &xlsx_axis_id, NULL),
         GSF_XML_IN_NODE (CAT_AXIS, AXIS_DELETE, XL_NS_CHART, "delete", GSF_XML_NO_CONTENT, &xlsx_axis_delete, NULL),
         GSF_XML_IN_NODE (CAT_AXIS, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
@@ -1830,6 +1831,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
 
       GSF_XML_IN_NODE_FULL (PLOTAREA, VAL_AXIS, XL_NS_CHART, "valAx", GSF_XML_NO_CONTENT, FALSE, TRUE,
 			    &xlsx_axis_start, &xlsx_axis_end, XLSX_AXIS_VAL),
+        GSF_XML_IN_NODE (VAL_AXIS, AXIS_CROSSES_AT, XL_NS_CHART, "crossesAt", GSF_XML_NO_CONTENT, NULL, NULL),	        /* 2nd Def */
         GSF_XML_IN_NODE (VAL_AXIS, AXIS_AXID, XL_NS_CHART, "axId", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
         GSF_XML_IN_NODE (VAL_AXIS, AXIS_DELETE, XL_NS_CHART, "delete", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
         GSF_XML_IN_NODE (VAL_AXIS, TITLE, XL_NS_CHART, "title", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
@@ -2577,22 +2579,28 @@ static void
 xlsx_cell_expr_begin (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	XLSXReadState *state = (XLSXReadState *)xin->user_state;
-	gboolean has_range = FALSE, is_array = FALSE;
+	gboolean has_range = FALSE, is_array = FALSE, is_shared = FALSE;
 	GnmRange range;
 	xmlChar const *shared_id = NULL;
 
+	/* See https://bugzilla.gnome.org/show_bug.cgi?id=642850 */
+	/* for some of the issues surrounding shared formulas.   */
+
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (0 == strcmp (attrs[0], "t")) {
 			if (0 == strcmp (attrs[1], "array"))
 				is_array = TRUE;
+			else if (0 == strcmp (attrs[1], "shared"))
+				is_shared = TRUE;
 		} else if (0 == strcmp (attrs[0], "si"))
 			shared_id = attrs[1];
 		else if (attr_range (xin, attrs, "ref", &range))
 			has_range = TRUE;
 
 	state->shared_id = NULL;
-	if (NULL != shared_id) {
-		state->texpr = g_hash_table_lookup (state->shared_exprs, shared_id);
+	if (is_shared &&  NULL != shared_id) {
+		if (!has_range)
+			state->texpr = g_hash_table_lookup (state->shared_exprs, shared_id);
 		if (NULL != state->texpr)
 			gnm_expr_top_ref (state->texpr);
 		else



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