[gnumeric] Excel: fix problem with object export.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Excel: fix problem with object export.
- Date: Thu, 1 Oct 2009 14:01:30 +0000 (UTC)
commit 547e2c6cc045fafe240d02195b376e86999fd585
Author: Morten Welinder <terra gnome org>
Date: Thu Oct 1 10:01:01 2009 -0400
Excel: fix problem with object export.
NEWS | 1 +
plugins/excel/ChangeLog | 5 ++++
plugins/excel/ms-escher.c | 10 +++++---
plugins/excel/ms-excel-write.c | 49 +++++++++++++++++++++++++++++++++------
samples/excel/objs.xls | Bin 221696 -> 221696 bytes
src/gnm-so-filled.c | 6 ++--
6 files changed, 56 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 65ec85c..952dd1c 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ Morten:
* Fix printing of coloured sheet objects.
* Fix printing of lines and arrows.
* Fix sheet object/clipboard related critical on exit. [#596509]
+ * Fix Excel-crashing export problem with objects. [#596886]
--------------------------------------------------------------------------
Gnumeric 1.9.13
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index c96fbc8..fbc886d 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-01 Morten Welinder <terra gnome org>
+
+ * ms-excel-write.c (excel_sheet_new): Exclude GNM_SO_FILLED_TYPE
+ objects with no text as we do not export them right. [#596886]
+
2009-09-20 Morten Welinder <terra gnome org>
* Release 1.9.13
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index 33d211d..ff3a962 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -2044,11 +2044,13 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
g_free ((void *)data);
/*
- * Lets double check that the data we just read makes sense.
- * If problems arise in the next tests it probably indicates that
- * the PRECEDING record length was invalid. Check that it included the header */
+ * Let's double check that the data we just read makes sense.
+ * If problems arise in the next tests it probably indicates
+ * that the PRECEDING record length was invalid. Check that
+ * it included the header.
+ */
if ((h.fbt & (~0x1ff)) != 0xf000) {
- printf ("EXCEL : Invalid fbt = 0x%x\n", h.fbt);
+ g_warning ("Invalid fbt = 0x%x\n", h.fbt);
ms_escher_header_release (&h);
return TRUE;
}
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 429f949..9fa7446 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4174,7 +4174,8 @@ excel_write_ClientTextbox (ExcelWriteState *ewb, SheetObject *so)
GSF_LE_SET_GUINT16 (buf, 0x212); /* end */
g_object_get (G_OBJECT (so), "text", &label, NULL);
if (!label) {
- g_warning ("Not sure why label is NULL here.");
+ g_warning ("Not sure why label is NULL here for %s at %p.",
+ g_type_name (G_OBJECT_TYPE (so)), so);
label = g_strdup ("");
}
char_len = excel_strlen (label, NULL);
@@ -5003,7 +5004,7 @@ excel_sheet_new (ExcelWriteState *ewb, Sheet *sheet,
gnm_sheet_get_max_cols (sheet));
ExcelWriteSheet *esheet = g_new0 (ExcelWriteSheet, 1);
GnmRange extent;
- GSList *objs, *img;
+ GSList *objs, *l;
g_return_val_if_fail (sheet, NULL);
g_return_val_if_fail (ewb, NULL);
@@ -5042,25 +5043,57 @@ excel_sheet_new (ExcelWriteState *ewb, Sheet *sheet,
esheet->blips = NULL;
objs = sheet_objects_get (sheet, NULL, SHEET_OBJECT_IMAGE_TYPE);
- for (img = objs ; img != NULL ; img = img->next) {
- SheetObjectImage *soi = SHEET_OBJECT_IMAGE (img->data);
+ for (l = objs ; l; l = l->next) {
+ SheetObjectImage *soi = SHEET_OBJECT_IMAGE (l->data);
BlipInf *bi = blipinf_new (soi);
/* Images we can't export have a NULL BlipInf */
- if (NULL!= bi)
+ if (!bi)
+ continue;
+
esheet->blips = g_slist_prepend (esheet->blips, bi);
}
esheet->blips = g_slist_reverse (esheet->blips);
esheet->num_objs += g_slist_length (esheet->blips);
g_slist_free (objs);
+ /* ---------------------------------------- */
+
/* Text boxes & comments */
+ esheet->textboxes = NULL;
objs = sheet_objects_get (sheet, NULL, CELL_COMMENT_TYPE);
- esheet->textboxes = g_slist_concat (objs,
- sheet_objects_get (sheet, NULL, GNM_SO_FILLED_TYPE));
- esheet->comments = NULL; /* gets populated with obj_ids later */
+ for (l = objs; l; l = l->next) {
+ GnmComment *obj = l->data;
+ esheet->textboxes = g_slist_prepend (esheet->textboxes, obj);
+ }
+ g_slist_free (objs);
+
+ objs = sheet_objects_get (sheet, NULL, GNM_SO_FILLED_TYPE);
+ for (l = objs; l; l = l->next) {
+ SheetObject *obj = l->data;
+ char *label = NULL;
+
+ g_object_get (G_OBJECT (obj), "text", &label, NULL);
+ if (!label) {
+ g_printerr ("Dropping object of type %s\n",
+ g_type_name (G_OBJECT_TYPE (obj)));
+ continue;
+ }
+ g_free (label);
+
+ esheet->textboxes = g_slist_prepend (esheet->textboxes, obj);
+ }
+ g_slist_free (objs);
+
+ esheet->textboxes = g_slist_reverse (esheet->textboxes);
esheet->num_objs += g_slist_length (esheet->textboxes);
+ /* ---------------------------------------- */
+
+ esheet->comments = NULL; /* gets populated with obj_ids later */
+
+ /* ---------------------------------------- */
+
/* And the autofilters (only 1 per sheet in XL) */
if (sheet->filters != NULL) {
GnmFilter const *filter = sheet->filters->data;
diff --git a/samples/excel/objs.xls b/samples/excel/objs.xls
index e2f7507..b98377c 100644
Binary files a/samples/excel/objs.xls and b/samples/excel/objs.xls differ
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index 8fc84b6..178db56 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -511,12 +511,12 @@ gnm_so_filled_class_init (GObjectClass *gobject_class)
g_object_class_install_property (gobject_class, SOF_PROP_IS_OVAL,
g_param_spec_boolean ("is-oval", NULL, NULL, FALSE,
GSF_PARAM_STATIC | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (gobject_class, SOF_PROP_MARKUP,
- g_param_spec_boxed ("markup", NULL, NULL, PANGO_TYPE_ATTR_LIST,
- GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, SOF_PROP_TEXT,
g_param_spec_string ("text", NULL, NULL, NULL,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, SOF_PROP_MARKUP,
+ g_param_spec_boxed ("markup", NULL, NULL, PANGO_TYPE_ATTR_LIST,
+ GSF_PARAM_STATIC | G_PARAM_READWRITE));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]