[gnumeric] improve handling of unknown plots



commit 7fc3286e479185fce39cb66289ce5dd548f3f9b2
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun Aug 22 12:53:16 2010 -0600

    improve handling of unknown plots
    
    2010-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_plot_area): handle OO_PLOT_UNKNOWN:
    	(oo_chart): set type to OO_PLOT_UNKNOWN on unknown charts and raise a warning
    	(oo_warning): make sure we are showing the first error

 plugins/openoffice/ChangeLog         |    6 ++++++
 plugins/openoffice/openoffice-read.c |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index d7ca625..35a1b0f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
 2010-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (oo_plot_area): handle OO_PLOT_UNKNOWN:
+	(oo_chart): set type to OO_PLOT_UNKNOWN on unknown charts and raise a warning
+	(oo_warning): make sure we are showing the first error
+
+2010-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (oo_plot_series): Also read gnm:label-cell-expression
 	* openoffice-write.c (odf_update_progress): new
 	(odf_write_content): call odf_update_progress
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 6e0a0a8..40c9118 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -326,6 +326,9 @@ oo_warning (GsfXMLIn *xin, char const *fmt, ...)
 	char *msg;
 	va_list args;
 
+	if (state->context->warning_occurred)
+		return;
+
 	va_start (args, fmt);
 	msg = g_strdup_vprintf (fmt, args);
 	va_end (args);
@@ -4451,6 +4454,9 @@ oo_plot_area (GsfXMLIn *xin, xmlChar const **attrs)
 	case OO_PLOT_SCATTER_COLOUR: type = "GogXYColorPlot";	break;
 	case OO_PLOT_XL_SURFACE: type = "XLSurfacePlot";	break;
 	case OO_PLOT_BOX: type = "GogBoxPlot";	break;
+	case OO_PLOT_UNKNOWN: type = "GogLinePlot";
+		/* It is simpler to create a plot than to check that we don't have one */
+		 break;
 	default: return;
 	}
 
@@ -4697,11 +4703,12 @@ oo_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		{ "gnm:xyz-surface", 	OO_PLOT_XYZ_SURFACE },
 		{ "gnm:scatter-color", 	OO_PLOT_SCATTER_COLOUR },
 		{ "gnm:box", 	        OO_PLOT_BOX },
+		{ "gnm:none", 	        OO_PLOT_UNKNOWN },
 		{ NULL,	0 },
 	};
 	OOParseState *state = (OOParseState *)xin->user_state;
 	int tmp;
-	OOPlotType type = OO_PLOT_SCATTER; /* arbitrary default */
+	OOPlotType type = OO_PLOT_UNKNOWN;
 	OOChartStyle	*style = NULL;
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
@@ -4723,6 +4730,10 @@ oo_chart (GsfXMLIn *xin, xmlChar const **attrs)
 	if (NULL != style)
 		state->chart.src_in_rows = style->src_in_rows;
 
+	if (type == OO_PLOT_UNKNOWN)
+		oo_warning (xin , _("Encountered an unknown chart type, "
+				    "trying to create a line plot."));
+
 	/* if (NULL != style) we also need to save the style for later use in oo_plot_area */
 
 }



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