[gnumeric] Provide progress feedback for xlsx import. [#634803]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Provide progress feedback for xlsx import. [#634803]
- Date: Thu, 18 Aug 2011 08:46:59 +0000 (UTC)
commit a4fed108fdca2eee865b773b175cd83860271332
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Aug 18 02:46:08 2011 -0600
Provide progress feedback for xlsx import. [#634803]
2011-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-read-docprops.c (xlsx_read_docprops_*): handle progress reports
* xlsx-read.c (maybe_update_progress): new
(start_update_progress): new
(end_update_progress): new
(xlsx_CT_Row): handle progress reports
(xlsx_CT_RowsCols_end): handle progress reports
(xlsx_sheet_begin): handle progress reports
(xlsx_comment_end): ditto
(xlsx_wb_end): ditto
(xlsx_file_open): ditto
NEWS | 1 +
plugins/excel/ChangeLog | 13 ++++++
plugins/excel/xlsx-read-docprops.c | 15 +++++++-
plugins/excel/xlsx-read.c | 74 +++++++++++++++++++++++++++++++++--
4 files changed, 97 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index ef8bb4e..e651a2a 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
* Fully read scientific format from ODF.
* Provide xls file opener permitting encoding specification. [#535473]
* Fix writing of scatter style in xlsx export. [#656799]
+ * Provide progress feedback for xlsx import. [#634803]
Jean:
* Make things build against gtk+-3.0.
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index e0266b0..e9c3013 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,16 @@
+2011-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * xlsx-read-docprops.c (xlsx_read_docprops_*): handle progress reports
+ * xlsx-read.c (maybe_update_progress): new
+ (start_update_progress): new
+ (end_update_progress): new
+ (xlsx_CT_Row): handle progress reports
+ (xlsx_CT_RowsCols_end): handle progress reports
+ (xlsx_sheet_begin): handle progress reports
+ (xlsx_comment_end): ditto
+ (xlsx_wb_end): ditto
+ (xlsx_file_open): ditto
+
2011-08-17 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-read-drawing.c (xlsx_scatter_style): also read incorrect "markers"
diff --git a/plugins/excel/xlsx-read-docprops.c b/plugins/excel/xlsx-read-docprops.c
index 49c5011..eb0a3a7 100644
--- a/plugins/excel/xlsx-read-docprops.c
+++ b/plugins/excel/xlsx-read-docprops.c
@@ -63,6 +63,8 @@ xlsx_read_core_keys (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
g_strdup (xin->node->user_data.v_str), val);
}
g_object_unref (keywords);
+
+ maybe_update_progress (xin);
}
static void
@@ -126,6 +128,7 @@ xlsx_read_property_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
XLSXReadState *state = (XLSXReadState *)xin->user_state;
g_free (state->meta_prop_name);
state->meta_prop_name = NULL;
+ maybe_update_progress (xin);
}
static void
@@ -147,6 +150,8 @@ xlsx_read_custom_property_type (GsfXMLIn *xin, GType g_type)
state->meta_prop_name = NULL;
} else
g_free (res);
+
+ maybe_update_progress (xin);
}
static void
@@ -249,8 +254,10 @@ xlsx_read_docprops_core (XLSXReadState *state)
"core-properties", NULL);
if (in == NULL) return;
- xlsx_parse_stream (state, in, xlsx_docprops_core_dtd);
+ start_update_progress (state, in, _("Reading core properties..."), 0.9, 0.94);
+ xlsx_parse_stream (state, in, xlsx_docprops_core_dtd);
+ end_update_progress (state);
}
static void
@@ -264,7 +271,10 @@ xlsx_read_docprops_extended (XLSXReadState *state)
"extended-properties", NULL);
if (in == NULL) return;
+
+ start_update_progress (state, in, _("Reading extended properties..."), 0.94, 0.97);
xlsx_parse_stream (state, in, xlsx_docprops_extended_dtd);
+ end_update_progress (state);
}
static void
@@ -278,7 +288,10 @@ xlsx_read_docprops_custom (XLSXReadState *state)
"custom-properties", NULL);
if (in == NULL) return;
+
+ start_update_progress (state, in, _("Reading custom properties..."), 0.97, 1.);
xlsx_parse_stream (state, in, xlsx_docprops_custom_dtd);
+ end_update_progress (state);
}
static void
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 6b06517..cf94b7d 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -285,6 +285,31 @@ static GsfXMLInNS const xlsx_ns[] = {
{ NULL }
};
+static void
+maybe_update_progress (GsfXMLIn *xin)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ GsfInput *input = gsf_xml_in_get_input (xin);
+ gsf_off_t pos = gsf_input_tell (input);
+
+ go_io_value_progress_update (state->context, pos);
+}
+
+static void
+start_update_progress (XLSXReadState *state, GsfInput *xin,
+ char const *message, double min, double max)
+{
+ go_io_progress_range_push (state->context, min, max);
+ go_io_value_progress_set (state->context, gsf_input_size (xin), 10000);
+ go_io_progress_message (state->context, message);
+}
+
+static void
+end_update_progress (XLSXReadState *state)
+{
+ go_io_progress_range_pop (state->context);
+}
+
static gboolean
xlsx_parse_stream (XLSXReadState *state, GsfInput *in, GsfXMLInNode const *dtd)
{
@@ -1020,7 +1045,7 @@ apply_tint (GOColor orig, double tint)
int g = GO_COLOR_UINT_G (orig);
int b = GO_COLOR_UINT_B (orig);
int a = GO_COLOR_UINT_A (orig);
- int maxC = b, minC = b, delta, sum, h, l, s, m1, m2;
+ int maxC = b, minC = b, delta, sum, h = 0, l, s, m1, m2;
if (fabs (tint) < .005)
return orig;
@@ -1363,6 +1388,8 @@ xlsx_CT_Row (GsfXMLIn *xin, xmlChar const **attrs)
sheet_style_set_range (state->sheet, &r, style);
}
}
+
+ maybe_update_progress (xin);
}
static void
@@ -1378,6 +1405,8 @@ xlsx_CT_RowsCols_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
state->pending_rowcol_style);
state->pending_rowcol_style = NULL;
+
+ maybe_update_progress (xin);
}
static void
@@ -2805,6 +2834,8 @@ xlsx_sheet_begin (GsfXMLIn *xin, xmlChar const **attrs)
Sheet *sheet;
int viz = (int)GNM_SHEET_VISIBILITY_VISIBLE;
+ maybe_update_progress (xin);
+
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (0 == strcmp (attrs[0], "name"))
name = attrs[1];
@@ -3174,6 +3205,7 @@ xlsx_comment_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
sheet_object_set_sheet (SHEET_OBJECT (state->comment), state->sheet);
state->comment = NULL;
+ maybe_update_progress (xin);
}
static void
@@ -3252,9 +3284,13 @@ xlsx_wb_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
GsfInput *sin, *cin;
GError *err = NULL;
+ end_update_progress (state);
+
/* Load sheets after setting up the workbooks to give us time to create
* all of them and parse names */
for (i = 0 ; i < n ; i++, state->sheet = NULL) {
+ char *message;
+
if (NULL == (state->sheet = workbook_sheet_by_index (state->wb, i)))
continue;
if (NULL == (part_id = g_object_get_data (G_OBJECT (state->sheet), "_XLSX_RelID"))) {
@@ -3283,9 +3319,19 @@ xlsx_wb_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
cin = gsf_open_pkg_open_rel_by_type (sin,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", NULL);
+ message = g_strdup_printf (_("Reading sheet '%s'..."), state->sheet->name_unquoted);
+ start_update_progress (state, sin, message,
+ 0.3 + i*0.6/n, 0.3 + i*0.6/n + 0.5/n);
+ g_free (message);
xlsx_parse_stream (state, sin, xlsx_sheet_dtd);
- if (cin != NULL)
+ end_update_progress (state);
+
+ if (cin != NULL) {
+ start_update_progress (state, cin, _("Reading comments..."),
+ 0.3 + i*0.6/n + 0.5/n, 0.3 + i*0.6/n + 0.6/n);
xlsx_parse_stream (state, cin, xlsx_comments_dtd);
+ end_update_progress (state);
+ }
/* Flag a respan here in case nothing else does */
sheet_flag_recompute_spans (state->sheet);
@@ -4271,19 +4317,37 @@ xlsx_file_open (GOFileOpener const *fo, GOIOContext *context,
in = gsf_open_pkg_open_rel_by_type (wb_part,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", NULL);
- xlsx_parse_stream (&state, in, xlsx_shared_strings_dtd);
+ if (in != NULL) {
+ start_update_progress (&state, in, _("Reading shared strings..."),
+ 0., 0.05);
+ xlsx_parse_stream (&state, in, xlsx_shared_strings_dtd);
+ end_update_progress (&state);
+ }
in = gsf_open_pkg_open_rel_by_type (wb_part,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", NULL);
- xlsx_parse_stream (&state, in, xlsx_theme_dtd);
+ if (in != NULL) {
+ start_update_progress (&state, in, _("Reading theme..."),
+ 0.05, 0.1);
+ xlsx_parse_stream (&state, in, xlsx_theme_dtd);
+ end_update_progress (&state);
+ }
in = gsf_open_pkg_open_rel_by_type (wb_part,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", NULL);
- xlsx_parse_stream (&state, in, xlsx_styles_dtd);
+ if (in != NULL) {
+ start_update_progress (&state, in, _("Reading styles..."), 0.1, 0.2);
+ xlsx_parse_stream (&state, in, xlsx_styles_dtd);
+ end_update_progress (&state);
+ }
+ start_update_progress (&state, in, _("Reading workbook..."),
+ 0.2, 0.3);
xlsx_parse_stream (&state, wb_part, xlsx_workbook_dtd);
+ /* end_update_progress (&state); moved into xlsx_wb_end */
xlsx_read_docprops (&state);
+
} else
go_cmd_context_error_import (GO_CMD_CONTEXT (context),
_("No workbook stream found."));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]