[gnumeric] OO import: add progress display.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] OO import: add progress display.
- Date: Sun, 10 May 2009 10:07:12 -0400 (EDT)
commit 44ee0953c7e9dfc94c6f4b53e2941adf1a55397a
Author: Morten Welinder <terra gnome org>
Date: Sun May 10 10:06:54 2009 -0400
OO import: add progress display.
---
NEWS | 1 +
plugins/openoffice/ChangeLog | 4 +++
plugins/openoffice/openoffice-read.c | 41 +++++++++++++++++++++++++++++-----
3 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index 74f748e..5959853 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ Morten:
* Plug leak in HTML paste.
* Respect the sheet size prefs for new blank workbooks.
* Cache large ranges, possibly sorted.
+ * Add progress display for OO import.
--------------------------------------------------------------------------
Gnumeric 1.9.7
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 2e65cf5..16dc9ad 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-10 Morten Welinder <terra gnome org>
+
+ * openoffice-read.c (openoffice_file_open): Add progress display.
+
2009-05-081 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_write_table_style): use "table-properties"
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 64dd15b..5050bc7 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -223,8 +223,23 @@ typedef struct {
struct {
GnmPageBreaks *h, *v;
} page_breaks;
+
+ gsf_off_t last_progress_update;
} OOParseState;
+static void
+maybe_update_progress (GsfXMLIn *xin)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+ GsfInput *input = gsf_xml_in_get_input (xin);
+ gsf_off_t pos = gsf_input_tell (input);
+
+ if (pos >= state->last_progress_update + 10000) {
+ value_io_progress_update (state->context, pos);
+ state->last_progress_update = pos;
+ }
+}
+
static GsfXMLInNode const * get_dtd (void);
static void oo_chart_style_free (OOChartStyle *pointer);
@@ -584,6 +599,8 @@ oo_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
GnmRange r;
int max_cols, max_rows;
+ maybe_update_progress (xin);
+
if (NULL != state->page_breaks.h) {
print_info_set_breaks (state->pos.sheet->print_info,
state->page_breaks.h);
@@ -674,6 +691,8 @@ oo_col_start (GsfXMLIn *xin, xmlChar const **attrs)
int i, repeat_count = 1;
gboolean hidden = FALSE;
+ maybe_update_progress (xin);
+
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "default-cell-style-name"))
style = g_hash_table_lookup (state->styles.cell, attrs[1]);
@@ -730,6 +749,8 @@ oo_row_start (GsfXMLIn *xin, xmlChar const **attrs)
gboolean hidden = FALSE;
int max_rows = gnm_sheet_get_max_rows (state->pos.sheet);
+ maybe_update_progress (xin);
+
state->pos.eval.col = 0;
if (state->pos.eval.row >= max_rows) {
@@ -910,6 +931,8 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
int max_cols = gnm_sheet_get_max_cols (state->pos.sheet);
int max_rows = gnm_sheet_get_max_rows (state->pos.sheet);
+ maybe_update_progress (xin);
+
state->col_inc = 1;
state->content_is_error = FALSE;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
@@ -2938,7 +2961,7 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
WorkbookView *wb_view, GsfInput *input)
{
GsfXMLInDoc *doc;
- GsfInput *content = NULL;
+ GsfInput *contents = NULL;
GsfInput *styles = NULL;
GsfDocMetaData *meta_data;
GsfInfile *zip;
@@ -2966,8 +2989,8 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
return;
}
- content = gsf_infile_child_by_name (zip, "content.xml");
- if (content == NULL) {
+ contents = gsf_infile_child_by_name (zip, "content.xml");
+ if (contents == NULL) {
go_cmd_context_error_import (GO_CMD_CONTEXT (io_context),
_("No stream named content.xml found."));
g_object_unref (zip);
@@ -2978,7 +3001,7 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
if (styles == NULL) {
go_cmd_context_error_import (GO_CMD_CONTEXT (io_context),
_("No stream named styles.xml found."));
- g_object_unref (content);
+ g_object_unref (contents);
g_object_unref (zip);
return;
}
@@ -3018,6 +3041,10 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
state.accum_fmt = NULL;
state.filter = NULL;
state.page_breaks.h = state.page_breaks.v = NULL;
+ state.last_progress_update = 0;
+
+ io_progress_message (state.context, _("Reading file..."));
+ value_io_progress_set (state.context, gsf_input_size (contents), 0);
if (state.ver == OOO_VER_OPENDOC) {
GsfInput *meta_file = gsf_infile_child_by_name (zip, "meta.xml");
@@ -3045,7 +3072,7 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
doc = gsf_xml_in_doc_new (
(state.ver == OOO_VER_1) ? ooo1_content_dtd : opendoc_content_dtd,
gsf_ooo_ns);
- if (gsf_xml_in_doc_parse (doc, content, &state)) {
+ if (gsf_xml_in_doc_parse (doc, contents, &state)) {
GsfInput *settings;
/* get the sheet in the right order (in case something was
@@ -3086,6 +3113,8 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
gnumeric_io_error_string (io_context, _("XML document not well formed!"));
gsf_xml_in_doc_free (doc);
+ io_progress_unset (state.context);
+
if (state.default_style_cell)
gnm_style_unref (state.default_style_cell);
g_hash_table_destroy (state.styles.sheet);
@@ -3093,7 +3122,7 @@ openoffice_file_open (GOFileOpener const *fo, IOContext *io_context,
g_hash_table_destroy (state.styles.cell);
g_hash_table_destroy (state.chart.graph_styles);
g_hash_table_destroy (state.formats);
- g_object_unref (content);
+ g_object_unref (contents);
g_object_unref (zip);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]