goffice r2225 - in trunk: . goffice/graph goffice/gtk goffice/utils
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2225 - in trunk: . goffice/graph goffice/gtk goffice/utils
- Date: Sun, 14 Sep 2008 14:03:39 +0000 (UTC)
Author: jbrefort
Date: Sun Sep 14 14:03:39 2008
New Revision: 2225
URL: http://svn.gnome.org/viewvc/goffice?rev=2225&view=rev
Log:
2008-09-14 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-graph.c: (gog_graph_set_property): [Coverity 187]
* goffice/graph/gog-grid-line.c: (gog_grid_line_xy_render): [Coverity 52]
* goffice/graph/gog-guru.c: (populate_graph_item_list): [Coverity 20]
* goffice/graph/gog-renderer.c: (gog_renderer_export_image): [Coverity 40]
* goffice/gtk/go-format-sel.c: (fmt_dialog_enable_widgets): [Coverity 18]
* goffice/gtk/go-image-sel.c: (ok_button_clicked_cb): [Coverity 19]
* goffice/utils/datetime.c: (datetime_weeknum): [Coverity 27]
* goffice/utils/go-pattern.c: (go_pattern_get_svg_path): [Coverity 17]
Modified:
trunk/ChangeLog
trunk/goffice/graph/gog-graph.c
trunk/goffice/graph/gog-grid-line.c
trunk/goffice/graph/gog-guru.c
trunk/goffice/graph/gog-renderer.c
trunk/goffice/gtk/go-format-sel.c
trunk/goffice/gtk/go-image-sel.c
trunk/goffice/utils/datetime.c
trunk/goffice/utils/go-pattern.c
Modified: trunk/goffice/graph/gog-graph.c
==============================================================================
--- trunk/goffice/graph/gog-graph.c (original)
+++ trunk/goffice/graph/gog-graph.c Sun Sep 14 14:03:39 2008
@@ -89,17 +89,11 @@
g_value_get_double (value));
break;
case GRAPH_PROP_DOCUMENT: {
- GObject *obj = g_value_get_object (value);
- if ((GODoc *) obj == graph->doc)
+ GObject *object = g_value_get_object (value);
+ if ((GODoc *) object == graph->doc)
break;
-/* if (graph->doc) {
- g_object_unref (graph->doc);
- graph->doc = NULL;
- }
- if (IS_GO_DOC (obj))
- graph->doc = (GODoc *) g_object_ref (obj);*/
if (IS_GO_DOC (obj)) {
- graph->doc = (GODoc *) obj;
+ graph->doc = (GODoc *) object;
gog_object_document_changed (GOG_OBJECT (graph), graph->doc);
}
break;
Modified: trunk/goffice/graph/gog-grid-line.c
==============================================================================
--- trunk/goffice/graph/gog-grid-line.c (original)
+++ trunk/goffice/graph/gog-grid-line.c Sun Sep 14 14:03:39 2008
@@ -160,19 +160,7 @@
switch (axis_type) {
case GOG_AXIS_X:
map = gog_axis_map_new (axis, plot_area->x, plot_area->w);
- break;
- case GOG_AXIS_Y:
- map = gog_axis_map_new (axis, plot_area->y +plot_area->h, -plot_area->h);
- break;
- default:
- return;
- }
-
- path = go_path_new ();
- go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
-
- switch (axis_type) {
- case GOG_AXIS_X:
+ path = go_path_new ();
if (stripes) {
rect.y = plot_area->y;
rect.h = plot_area->h;
@@ -206,8 +194,12 @@
}
gog_renderer_stroke_shape (view->renderer, path);
}
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
break;
case GOG_AXIS_Y:
+ map = gog_axis_map_new (axis, plot_area->y +plot_area->h, -plot_area->h);
+ path = go_path_new ();
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
if (stripes) {
rect.x = plot_area->x;
rect.w = plot_area->w;
@@ -244,7 +236,7 @@
}
break;
default:
- break;
+ return;
}
go_path_free (path);
Modified: trunk/goffice/graph/gog-guru.c
==============================================================================
--- trunk/goffice/graph/gog-guru.c (original)
+++ trunk/goffice/graph/gog-guru.c Sun Sep 14 14:03:39 2008
@@ -752,13 +752,12 @@
if (insert) {
GogObject *gparent = gog_object_get_parent (obj);
gint i = g_slist_index (gparent->children, obj);
- if (i > 0) {
- GtkTreeIter sibling;
- gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (s->prop_model),
- &sibling, parent, i-1);
- gtk_tree_store_insert_after (s->prop_model, &iter,
- parent, &sibling);
- } else
+ GtkTreeIter sibling;
+ if (i > 0 && gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (s->prop_model),
+ &sibling, parent, i-1))
+ gtk_tree_store_insert_after (s->prop_model, &iter,
+ parent, &sibling);
+ else
gtk_tree_store_prepend (s->prop_model, &iter, parent);
} else
gtk_tree_store_append (s->prop_model, &iter, parent);
Modified: trunk/goffice/graph/gog-renderer.c
==============================================================================
--- trunk/goffice/graph/gog-renderer.c (original)
+++ trunk/goffice/graph/gog-renderer.c Sun Sep 14 14:03:39 2008
@@ -1271,72 +1271,63 @@
switch (format) {
case GO_IMAGE_FORMAT_EPS:
- case GO_IMAGE_FORMAT_PDF:
- case GO_IMAGE_FORMAT_PS:
- case GO_IMAGE_FORMAT_SVG:
- rend->scale = 1.0;
- switch (format) {
- case GO_IMAGE_FORMAT_PDF:
- rend->marker_as_surface = FALSE;
-#ifdef CAIRO_HAS_PDF_SURFACE
- surface = cairo_pdf_surface_create_for_stream
- (_cairo_write_func,
- output, width_in_pts, height_in_pts);
+ rend->marker_as_surface = FALSE;
+#ifdef HAVE_CAIRO_PS_SURFACE_SET_EPS
+ surface = cairo_ps_surface_create_for_stream
+ (_cairo_write_func,
+ output, width_in_pts, height_in_pts);
+ cairo_ps_surface_set_eps (surface, TRUE);
#ifdef HAVE_CAIRO_SURFACE_SET_FALLBACK_RESOLUTION
- cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
+ cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
#endif
- break;
+ goto do_export_vectorial;
#else
- g_warning ("[GogRendererCairo::export_image] cairo PDF backend missing");
- return FALSE;
+ g_warning ("[GogRendererCairo::export_image] cairo EPS backend missing");
+ return FALSE;
#endif
- case GO_IMAGE_FORMAT_PS:
- rend->marker_as_surface = FALSE;
-#ifdef CAIRO_HAS_PS_SURFACE
- surface = cairo_ps_surface_create_for_stream
- (_cairo_write_func,
- output, width_in_pts, height_in_pts);
+ case GO_IMAGE_FORMAT_PDF:
+ rend->marker_as_surface = FALSE;
+#ifdef CAIRO_HAS_PDF_SURFACE
+ surface = cairo_pdf_surface_create_for_stream
+ (_cairo_write_func,
+ output, width_in_pts, height_in_pts);
#ifdef HAVE_CAIRO_SURFACE_SET_FALLBACK_RESOLUTION
- cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
+ cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
#endif
- break;
+ goto do_export_vectorial;
#else
- g_warning ("[GogRendererCairo::export_image] cairo PS backend missing");
- return FALSE;
+ g_warning ("[GogRendererCairo::export_image] cairo PDF backend missing");
+ return FALSE;
#endif
- case GO_IMAGE_FORMAT_SVG:
- rend->marker_as_surface = TRUE;
-#ifdef CAIRO_HAS_SVG_SURFACE
- surface = cairo_svg_surface_create_for_stream
- (_cairo_write_func,
- output, width_in_pts, height_in_pts);
+ case GO_IMAGE_FORMAT_PS:
+ rend->marker_as_surface = FALSE;
+#ifdef CAIRO_HAS_PS_SURFACE
+ surface = cairo_ps_surface_create_for_stream
+ (_cairo_write_func,
+ output, width_in_pts, height_in_pts);
#ifdef HAVE_CAIRO_SURFACE_SET_FALLBACK_RESOLUTION
- cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
+ cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
#endif
- break;
+ goto do_export_vectorial;
#else
- g_warning ("[GogRendererCairo::export_image] cairo SVG backend missing");
- return FALSE;
+ g_warning ("[GogRendererCairo::export_image] cairo PS backend missing");
+ return FALSE;
#endif
- case GO_IMAGE_FORMAT_EPS:
- rend->marker_as_surface = FALSE;
-#ifdef HAVE_CAIRO_PS_SURFACE_SET_EPS
- surface = cairo_ps_surface_create_for_stream
- (_cairo_write_func,
- output, width_in_pts, height_in_pts);
- cairo_ps_surface_set_eps (surface, TRUE);
+ case GO_IMAGE_FORMAT_SVG:
+ rend->marker_as_surface = TRUE;
+#ifdef CAIRO_HAS_SVG_SURFACE
+ surface = cairo_svg_surface_create_for_stream
+ (_cairo_write_func,
+ output, width_in_pts, height_in_pts);
#ifdef HAVE_CAIRO_SURFACE_SET_FALLBACK_RESOLUTION
- cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
+ cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);
#endif
- break;
#else
- g_warning ("[GogRendererCairo::export_image] cairo EPS backend missing");
- return FALSE;
+ g_warning ("[GogRendererCairo::export_image] cairo SVG backend missing");
+ return FALSE;
#endif
- default:
- break;
- }
-
+do_export_vectorial:
+ rend->scale = 1.0;
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
status = gog_renderer_render_to_cairo (rend, cairo, width_in_pts, height_in_pts);
Modified: trunk/goffice/gtk/go-format-sel.c
==============================================================================
--- trunk/goffice/gtk/go-format-sel.c (original)
+++ trunk/goffice/gtk/go-format-sel.c Sun Sep 14 14:03:39 2008
@@ -744,9 +744,10 @@
format_entry_set_text (gfs, tmp);
g_free (tmp);
} else if (select.stamp == 0)
- gtk_tree_model_get_iter_first (
+ if (!gtk_tree_model_get_iter_first (
GTK_TREE_MODEL (gfs->format.formats.model),
- &select);
+ &select))
+ break;
if (select.stamp != 0) {
GtkTreePath *path = gtk_tree_model_get_path (
Modified: trunk/goffice/gtk/go-image-sel.c
==============================================================================
--- trunk/goffice/gtk/go-image-sel.c (original)
+++ trunk/goffice/gtk/go-image-sel.c Sun Sep 14 14:03:39 2008
@@ -140,11 +140,12 @@
GtkTreePath *path = l->data;
GtkTreeIter iter;
char *name;
- gtk_tree_model_get_iter (GTK_TREE_MODEL (state->model), &iter, path);
- gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter, 1, &name, -1);
- if (name) {
- *(state->result) = go_doc_get_image (state->doc, name);
- g_free (name);
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (state->model), &iter, path)) {
+ gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter, 1, &name, -1);
+ if (name) {
+ *(state->result) = go_doc_get_image (state->doc, name);
+ g_free (name);
+ }
}
g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
g_list_free (l);
Modified: trunk/goffice/utils/datetime.c
==============================================================================
--- trunk/goffice/utils/datetime.c (original)
+++ trunk/goffice/utils/datetime.c Sun Sep 14 14:03:39 2008
@@ -209,7 +209,7 @@
int
datetime_weeknum (GDate const *date, int method)
{
- int res;
+ int res = -1;
g_return_val_if_fail (g_date_valid (date), -1);
g_return_val_if_fail (method == WEEKNUM_METHOD_SUNDAY ||
@@ -224,7 +224,6 @@
res = g_date_get_monday_week_of_year (date); break;
case WEEKNUM_METHOD_ISO:
res = g_date_get_iso8601_week_of_year (date); break;
- default: res = -1;
}
return res;
Modified: trunk/goffice/utils/go-pattern.c
==============================================================================
--- trunk/goffice/utils/go-pattern.c (original)
+++ trunk/goffice/utils/go-pattern.c Sun Sep 14 14:03:39 2008
@@ -175,13 +175,16 @@
ptr->name &&
!strcmp ((char *)ptr->name, "pattern"))
{
+ double value;
name = xmlGetProp (ptr, CC2XML ("name"));
if (name != NULL) {
if (strcmp ((char *)name, go_patterns [pattern->pattern].str) == 0) {
- if (width != NULL)
- xml_node_get_double (ptr, "width", width);
- if (height != NULL)
- xml_node_get_double (ptr, "height", height);
+ if (width != NULL &&
+ xml_node_get_double (ptr, "width", &value))
+ *width = value;
+ if (height != NULL &&
+ xml_node_get_double (ptr, "height", &value))
+ *height = value;
svg_path = xmlGetProp (ptr, CC2XML ("d"));
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]