[gnumeric] Read/write active sheet from/to Gnumeric confs in ODF files. Write edit position foreign elements in
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Read/write active sheet from/to Gnumeric confs in ODF files. Write edit position foreign elements in
- Date: Mon, 29 Aug 2011 23:32:20 +0000 (UTC)
commit e8088aa87b9312380e31a4853cb67e0518e38840
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Aug 29 17:31:35 2011 -0600
Read/write active sheet from/to Gnumeric confs in ODF files. Write edit position foreign elements in ODF files.
2011-08-29 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_apply_gnm_config): new
(openoffice_file_open): connect odf_apply_gnm_config
* openoffice-write.c (odf_add_range): new
(odf_write_content): also write selection
(odf_write_gnm_settings): write acive sheet info
(odf_write_ooo_settings): do not hardcode sheet name
NEWS | 4 ++-
plugins/openoffice/ChangeLog | 9 ++++++
plugins/openoffice/openoffice-read.c | 19 ++++++++++++
plugins/openoffice/openoffice-write.c | 51 +++++++++++++++++++++++++++++---
4 files changed, 77 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index 199f8a7..78935e6 100644
--- a/NEWS
+++ b/NEWS
@@ -13,8 +13,10 @@ Andreas:
* Add HPFILTER function calculating the Hodrick Prescott Filter.
* Fix saving of newlines to xls. [#356711]
* Enable markup selection in scientific format selector.
- * Be compatible wihthe changed LibreOffice ODF documents with tab colours.
+ * Be compatible wih the changed LibreOffice ODF documents with tab colours.
* Read/write edit position and active sheet from/to LibreOffice confs in ODF files.
+ * Read/write active sheet from/to Gnumeric confs in ODF files.
+ * Write edit position foreign elements in ODF files.
Jean:
* Make things build against gtk+-3.0.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f3650e9..a85bb70 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
2011-08-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (odf_apply_gnm_config): new
+ (openoffice_file_open): connect odf_apply_gnm_config
+ * openoffice-write.c (odf_add_range): new
+ (odf_write_content): also write selection
+ (odf_write_gnm_settings): write acive sheet info
+ (odf_write_ooo_settings): do not hardcode sheet name
+
+2011-08-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-write.c (odf_write_ooo_settings): write edit positions and
active sheet
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index edfc8c6..8d2236c 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -8539,6 +8539,24 @@ odf_has_gnm_foreign (OOParseState *state)
}
static void
+odf_apply_gnm_config (OOParseState *state)
+{
+ GValue *val;
+ if ((state->settings.settings != NULL) &&
+ NULL != (val = g_hash_table_lookup (state->settings.settings, "gnm:settings")) &&
+ G_VALUE_HOLDS(val,G_TYPE_HASH_TABLE)) {
+ GHashTable *hash = g_value_get_boxed (val);
+ val = g_hash_table_lookup (hash, "gnm:active-sheet");
+ if (val != NULL && G_VALUE_HOLDS(val, G_TYPE_STRING)) {
+ const gchar *name = g_value_get_string (val);
+ Sheet *sheet = workbook_sheet_by_name (state->pos.wb, name);
+ if (sheet != NULL)
+ wb_view_sheet_focus (state->wb_view, sheet);
+ }
+ }
+}
+
+static void
odf_apply_ooo_table_config (char const *key, GValue *val, OOParseState *state)
{
if (G_VALUE_HOLDS(val,G_TYPE_HASH_TABLE)) {
@@ -10234,6 +10252,7 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
: "Gnumeric_OpenCalc:odf";
} else
filesaver = "Gnumeric_OpenCalc:odf";
+ odf_apply_gnm_config (&state);
workbook_set_saveinfo (state.pos.wb, GO_FILE_FL_AUTO,
go_file_saver_for_id
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 6fa9478..aecb77b 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -246,6 +246,17 @@ odf_write_mimetype (G_GNUC_UNUSED GnmOOExport *state, GsfOutput *child)
/*****************************************************************************/
static void
+odf_add_range (GnmOOExport *state, GnmRange const *r)
+{
+ g_return_if_fail (range_is_sane (r));
+
+ gsf_xml_out_add_int (state->xml, "start-col", r->start.col);
+ gsf_xml_out_add_int (state->xml, "start-row", r->start.row);
+ gsf_xml_out_add_int (state->xml, "end-col", r->end.col);
+ gsf_xml_out_add_int (state->xml, "end-row", r->end.row);
+}
+
+static void
odf_add_font_weight (GnmOOExport *state, int weight)
{
weight = ((weight+50)/100)*100;
@@ -4438,6 +4449,28 @@ odf_write_content (GnmOOExport *state, GsfOutput *child)
(GHFunc)&odf_write_named_expression, state);
gsf_xml_out_end_element (state->xml); /* </table:named-expressions> */
}
+ if (state->with_extension) {
+ GSList *ptr, *copy;
+ SheetView const *sv = sheet_get_view (sheet, state->wbv);
+ if (sv) {
+ gsf_xml_out_start_element (state->xml, GNMSTYLE "selections");
+ gsf_xml_out_add_int (state->xml, "cursor-col", sv->edit_pos_real.col);
+ gsf_xml_out_add_int (state->xml, "cursor-row", sv->edit_pos_real.row);
+
+ /* Insert the selections in REVERSE order */
+ copy = g_slist_copy (sv->selections);
+ ptr = g_slist_reverse (copy);
+ for (; ptr != NULL ; ptr = ptr->next) {
+ GnmRange const *r = ptr->data;
+ gsf_xml_out_start_element (state->xml, GNMSTYLE "selection");
+ odf_add_range (state, r);
+ gsf_xml_out_end_element (state->xml); /* </gnm:selection> */
+ }
+ g_slist_free (copy);
+
+ gsf_xml_out_end_element (state->xml); /* </gnm:selections> */
+ }
+ }
gsf_xml_out_end_element (state->xml); /* </table:table> */
has_autofilters |= (sheet->filters != NULL);
@@ -5394,8 +5427,15 @@ odf_write_gnm_settings (GnmOOExport *state)
gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", GNMSTYLE "has_foreign");
gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "type", "boolean");
odf_add_bool (state->xml, NULL, state->with_extension);
+ gsf_xml_out_end_element (state->xml); /* </config:config-item> */
+ gsf_xml_out_start_element (state->xml, CONFIG "config-item");
+ gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", GNMSTYLE "active-sheet");
+ gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "type", "string");
+ gsf_xml_out_add_cstr (state->xml, NULL,
+ (wb_view_cur_sheet (state->wbv))->name_unquoted);
gsf_xml_out_end_element (state->xml); /* </config:config-item> */
+
gsf_xml_out_end_element (state->xml); /* </config:config-item-set> */
}
@@ -5457,11 +5497,12 @@ odf_write_ooo_settings (GnmOOExport *state)
gsf_xml_out_end_element (state->xml); /* </config:config-item-map-named> */
- gsf_xml_out_start_element (state->xml, CONFIG "config-item");
- gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", "ActiveTable");
- gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "type", "string");
- gsf_xml_out_add_cstr_unchecked (state->xml, NULL, "Sheet2");
- gsf_xml_out_end_element (state->xml); /* </config:config-item> */
+ gsf_xml_out_start_element (state->xml, CONFIG "config-item");
+ gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", "ActiveTable");
+ gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "type", "string");
+ gsf_xml_out_add_cstr (state->xml, NULL,
+ (wb_view_cur_sheet (state->wbv))->name_unquoted);
+ gsf_xml_out_end_element (state->xml); /* </config:config-item> */
gsf_xml_out_end_element (state->xml); /* </config:config-item-map-entry> */
gsf_xml_out_end_element (state->xml); /* </config:config-item-map-indexed> */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]