[goffice] Don't crash when loading an xls file with an EMF picture. [#688047]
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Don't crash when loading an xls file with an EMF picture. [#688047]
- Date: Sat, 10 Nov 2012 19:37:33 +0000 (UTC)
commit 4842e2c1aa34fee974e3d181eb475244518d6833
Author: Jean Brefort <jean brefort normalesup org>
Date: Sat Nov 10 20:36:59 2012 +0100
Don't crash when loading an xls file with an EMF picture. [#688047]
ChangeLog | 10 ++++
NEWS | 1 +
docs/reference/goffice-0.10-sections.txt | 2 +
goffice/graph/gog-axis-color-map.c | 2 +-
goffice/graph/gog-theme.c | 76 ++++++++++++++++++++++++++++++
goffice/graph/gog-theme.h | 2 +
goffice/utils/go-emf.c | 1 +
7 files changed, 93 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1bd26aa..5967f6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-11-10 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-axis-color-map.c:
+ * goffice/graph/gog-theme.c (gog_theme_set_name),
+ (gog_theme_set_description), (gog_theme_dup), (gog_theme_edit): prepare for
+ theme edition.
+ * goffice/graph/gog-theme.h: ditto.
+ * goffice/utils/go-emf.c (go_emf_parse): do not crash when loading an .xls
+ file with an embedded EMF. [#688047]
+
2012-11-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (go_format_output_scientific_number_element_to_odf):
diff --git a/NEWS b/NEWS
index 44b8826..66c0242 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Jean:
* Improve padding between axis ticks and labels. [#686473]
* Enhance graph guru behavior when an object is deleted. [#687102]
* Allow colors selection for contour and map plots. [#657908]
+ * Don't crash when loading an xls file with an EMF picture. [#688047]
Morten:
* Namespace cleanup. [#686501]
diff --git a/docs/reference/goffice-0.10-sections.txt b/docs/reference/goffice-0.10-sections.txt
index d6be7b6..810ec51 100644
--- a/docs/reference/goffice-0.10-sections.txt
+++ b/docs/reference/goffice-0.10-sections.txt
@@ -3405,6 +3405,8 @@ gog_styled_object_get_type
<FILE>gog-theme</FILE>
<TITLE>Theming</TITLE>
GogTheme
+gog_theme_dup
+gog_theme_edit
gog_theme_fillin_style
gog_theme_get_color_map
gog_theme_get_description
diff --git a/goffice/graph/gog-axis-color-map.c b/goffice/graph/gog-axis-color-map.c
index 0dcb79f..8e6eb95 100644
--- a/goffice/graph/gog-axis-color-map.c
+++ b/goffice/graph/gog-axis-color-map.c
@@ -577,7 +577,7 @@ gog_axis_color_map_set_name (GogAxisColorMap *map, char const *name)
* @map: a #GogAxisColorMap
*
* Duplicates the color map.
- * Returns: (transfer none): the new color map/
+ * Returns: (transfer full): the new color map.
**/
GogAxisColorMap *
gog_axis_color_map_dup (GogAxisColorMap const *map)
diff --git a/goffice/graph/gog-theme.c b/goffice/graph/gog-theme.c
index b77cb53..69c8d0a 100644
--- a/goffice/graph/gog-theme.c
+++ b/goffice/graph/gog-theme.c
@@ -1655,3 +1655,79 @@ gog_theme_get_color_map (GogTheme const *theme, gboolean discrete)
return (theme->cm)? theme->cm: _gog_axis_color_map_get_default ();
return NULL;
}
+
+/*****************
+ * Theme edition *
+ *****************/
+
+static void
+gog_theme_set_name (GogTheme *theme, char const *name)
+{
+ g_free (theme->name);
+ g_hash_table_remove_all (theme->names);
+ theme->name = g_strdup (name);
+ g_hash_table_insert (theme->names, g_strdup ("C"), g_strdup (name));
+}
+static void
+gog_theme_set_description (GogTheme *theme, char const *desc)
+{
+ g_free (theme->description);
+ g_hash_table_remove_all (theme->descs);
+ theme->description = g_strdup (desc);
+ g_hash_table_insert (theme->descs, g_strdup ("C"), g_strdup (desc));
+}
+
+/**
+ * gog_theme_dup:
+ * @theme: a #GogTheme
+ *
+ * Duplicates @theme with a new Id.
+ * Returns: (transfer full): the new theme.
+ **/
+GogTheme*
+gog_theme_dup (GogTheme *theme)
+{
+ GogTheme *new_theme = g_object_new (GOG_TYPE_THEME,
+ "resource-type", GO_RESOURCE_RW,
+ NULL);
+ char *desc, *name;
+
+ new_theme->id = go_uuid ();
+ gog_theme_build_uri (new_theme);
+ gog_theme_set_name (new_theme, "New theme");
+ name = g_hash_table_lookup (theme->names, "C");
+ desc = g_strdup_printf ("New theme base on %s", name);
+ gog_theme_set_description (new_theme, desc);
+ g_free (desc);
+ /* duplicate the styles */
+ /* duplicate the color maps */
+ if (theme->cm) {
+ new_theme->cm = gog_axis_color_map_dup (theme->cm);
+ g_object_set (G_OBJECT (new_theme->cm),
+ "resource-type", GO_RESOURCE_CHILD,
+ NULL);
+ }
+ if (theme->dcm &&
+ gog_axis_color_map_get_resource_type (theme->dcm) == GO_RESOURCE_CHILD) {
+ new_theme->dcm = gog_axis_color_map_dup (theme->dcm);
+ g_object_set (G_OBJECT (new_theme->dcm),
+ "resource-type", GO_RESOURCE_CHILD,
+ NULL);
+ }
+ return new_theme;
+}
+
+/**
+ * gog_theme_edit:
+ * @theme: the #GogTheme to edit or %NULL to create a new one.
+ *
+ * Displays a dialog box to edit the theme. This can be done only for
+ * locally installed themes that are writeable.
+ * Returns: (transfer none): The edited theme or %NULL if the edition has
+ * been cancelled.
+ **/
+GogTheme *
+gog_theme_edit (GogTheme *theme)
+{
+ return NULL;
+}
diff --git a/goffice/graph/gog-theme.h b/goffice/graph/gog-theme.h
index 7db765a..6c9b0f8 100644
--- a/goffice/graph/gog-theme.h
+++ b/goffice/graph/gog-theme.h
@@ -43,6 +43,8 @@ GogAxisColorMap const *gog_theme_get_color_map (GogTheme const *theme, gboolean
GogTheme *gog_theme_registry_lookup (char const *name);
GSList *gog_theme_registry_get_theme_names (void);
void gog_theme_save_to_home_dir (GogTheme *theme);
+GogTheme *gog_theme_edit (GogTheme *theme);
+GogTheme *gog_theme_dup (GogTheme *theme);
/* private */
void _gog_themes_init (void);
diff --git a/goffice/utils/go-emf.c b/goffice/utils/go-emf.c
index 2ae0f5e..2ed8806 100644
--- a/goffice/utils/go-emf.c
+++ b/goffice/utils/go-emf.c
@@ -4439,6 +4439,7 @@ go_emf_parse (GOEmf *emf, GsfInput *input, GError **error)
break;
state.length = rsize;
state.data = gsf_input_read (input, rsize, NULL);
+ state.canvas = emf->canvas;
go_emf_header (&state);
image->width = (state.mmbounds.right - state.mmbounds.left) / 2540. * 72.;
image->height = (state.mmbounds.bottom - state.mmbounds.top) / 2540. * 72.;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]