[gnumeric] Fix loading of charts from MS generated ODF files. [#588107]



commit b77258bb86b3a634ca8da0593449874318f361d5
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Jul 8 17:03:26 2009 -0600

    Fix loading of charts from MS generated ODF files. [#588107]
    
    2009-07-08 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (opendoc_content_dtd): add
    	  style:tab-stops to style:paragraph-properties
    	(od_draw_object): handle both "Object 1/" and
    	  "./Object 1".

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    7 +++++++
 plugins/openoffice/openoffice-read.c |   21 ++++++++++++++++-----
 3 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2edc131..710601e 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Andreas:
 	* Show existence of conditional styles in format dialog.
 	* Add an initialy hidden long format toolbar.
 	* Fix std error for intercept in non-affine case of LINEST. [#550933]
+	* Fix loading of charts from MS generated ODF files. [#588107]
 
 Morten:
 	* Make SUMIF/COUNTIF and the D* functions understand pattern. [#586215]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 84ab290..c272000 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2009-07-08 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (opendoc_content_dtd): add 
+	  style:tab-stops to style:paragraph-properties
+	(od_draw_object): handle both "Object 1/" and 
+	  "./Object 1".
+
+2009-07-08 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (opendoc_content_dtd): add svg:desc
 	  to draw:frame and remove unneeded duplication
 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 57fb460..cadf0fd 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3061,7 +3061,9 @@ static void
 od_draw_object (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
-	gchar const *name = NULL;
+	gchar const *name_start = NULL;
+	gchar * name;
+	gint name_len;
 	GsfInput	*content = NULL;
 	SheetObject *sog = sheet_object_graph_new (NULL);
 
@@ -3071,14 +3073,21 @@ od_draw_object (GsfXMLIn *xin, xmlChar const **attrs)
 	g_object_unref (sog);
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
-		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_XLINK, "href") &&
-		    strncmp (CXML2C (attrs[1]), "./", 2) == 0) {
-			name = CXML2C (attrs[1]) + 2;
+		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_XLINK, "href")) {
+			name_start = CXML2C (attrs[1]);
+			if (strncmp (CXML2C (attrs[1]), "./", 2) == 0)
+				name_start += 2;
+			if (strncmp (CXML2C (attrs[1]), "/", 1) == 0)
+				name_start = NULL;
 			break;
 		}
 
-	if (!name)
+	if (!name_start)
 		return;
+	name_len = strlen (name_start);
+	if (*(name_start + name_len - 1) == '/') /* OOo does not append a / */
+		name_len--;
+	name = g_strndup (name_start, name_len);
 
 #ifdef OO_DEBUG_OBJS
 	g_print ("START %s\n", name);
@@ -3095,6 +3104,7 @@ od_draw_object (GsfXMLIn *xin, xmlChar const **attrs)
 #ifdef OO_DEBUG_OBJS
 	g_print ("END %s\n", name);
 #endif
+	g_free (name);
 
 	if (state->cur_style_type == OO_STYLE_CHART)
 		state->cur_style_type = OO_STYLE_UNKNOWN;
@@ -3775,6 +3785,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
 	      GSF_XML_IN_NODE (STYLE, TEXT_PROPS, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &oo_style_prop, NULL),
 	      GSF_XML_IN_NODE (STYLE, TABLE_PROPS, OO_NS_STYLE, "table-properties", GSF_XML_NO_CONTENT, &oo_style_prop, NULL),
 	      GSF_XML_IN_NODE (STYLE, PARAGRAPH_PROPS, OO_NS_STYLE, "paragraph-properties", GSF_XML_NO_CONTENT, &oo_style_prop, NULL),
+	        GSF_XML_IN_NODE (PARAGRAPH_PROPS, PARA_TABS, OO_NS_STYLE,  "tab-stops", GSF_XML_NO_CONTENT, NULL, NULL),
 	      GSF_XML_IN_NODE (STYLE, GRAPHIC_PROPS, OO_NS_STYLE, "graphic-properties", GSF_XML_NO_CONTENT, &oo_style_prop, NULL),
 	      GSF_XML_IN_NODE (STYLE, STYLE_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &oo_style_map, NULL),
 	    GSF_XML_IN_NODE (OFFICE_STYLES, NUMBER_STYLE, OO_NS_NUMBER, "number-style", GSF_XML_NO_CONTENT, &odf_number_style, &odf_number_style_end),



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