[gnumeric] Persist selection and edit positions through ODF files. [#657506]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Persist selection and edit positions through ODF files. [#657506]
- Date: Tue, 30 Aug 2011 00:14:21 +0000 (UTC)
commit e4408252bedee53e94bba712121dd42be2a3b3df
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Aug 29 18:13:42 2011 -0600
Persist selection and edit positions through ODF files. [#657506]
2011-08-29 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_attr_range): new
(odf_selection_range): new
(odf_selection): new
(odf_selection_end): new
(opendoc_content_dtd): connect the above
* openoffice-write.c (odf_add_range): use gnm name space
(odf_write_content): ditto
NEWS | 4 +--
plugins/openoffice/ChangeLog | 10 +++++
plugins/openoffice/openoffice-read.c | 64 +++++++++++++++++++++++++++++++++
plugins/openoffice/openoffice-write.c | 12 +++---
4 files changed, 81 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 78935e6..abb0fc2 100644
--- a/NEWS
+++ b/NEWS
@@ -14,9 +14,7 @@ Andreas:
* Fix saving of newlines to xls. [#356711]
* Enable markup selection in scientific format selector.
* 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.
+ * Persist selection and edit positions through ODF files. [#657506]
Jean:
* Make things build against gtk+-3.0.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index a85bb70..0bc2d72 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,15 @@
2011-08-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (odf_attr_range): new
+ (odf_selection_range): new
+ (odf_selection): new
+ (odf_selection_end): new
+ (opendoc_content_dtd): connect the above
+ * openoffice-write.c (odf_add_range): use gnm name space
+ (odf_write_content): ditto
+
+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
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 8d2236c..0a0a2f6 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1061,6 +1061,29 @@ oo_attr_angle (GsfXMLIn *xin, xmlChar const * const *attrs,
return oo_parse_angle (xin, attrs[1], name, deg);
}
+static gboolean
+odf_attr_range (GsfXMLIn *xin, xmlChar const * const *attrs, Sheet *sheet, GnmRange *res)
+{
+ int flags = 0;
+
+ g_return_val_if_fail (attrs != NULL, FALSE);
+
+ for (; attrs[0] && attrs[1] ; attrs += 2)
+ if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT, "start-col", &res->start.col, 0, gnm_sheet_get_last_col(sheet)))
+ flags |= 0x1;
+ else if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT, "start-row", &res->start.row, 0, gnm_sheet_get_last_row(sheet)))
+ flags |= 0x2;
+ else if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT, "end-col", &res->end.col, 0, gnm_sheet_get_last_col(sheet)))
+ flags |= 0x4;
+ else if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT, "end-row", &res->end.row, 0, gnm_sheet_get_last_row(sheet)))
+ flags |= 0x8;
+ else
+ return FALSE;
+
+ return flags == 0xf;
+}
+
+
typedef struct {
char const * const name;
int val;
@@ -8337,6 +8360,45 @@ odf_control_property (GsfXMLIn *xin, xmlChar const **attrs)
state->cur_control->label = g_strdup (value);
}
+static void
+odf_selection_range (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+ GnmRange r;
+ if (odf_attr_range (xin, attrs, state->pos.sheet, &r))
+ sv_selection_add_range (sheet_get_view (state->pos.sheet, state->wb_view), &r);
+}
+
+static void
+odf_selection (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+ Sheet *sheet = state->pos.sheet;
+ int col = -1, row = -1;
+
+ sv_selection_reset (sheet_get_view (sheet, state->wb_view));
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (oo_attr_int_range
+ (xin, attrs, OO_GNUM_NS_EXT, "cursor-col", &col,
+ 0, gnm_sheet_get_last_col(sheet))) {
+ } else if (oo_attr_int_range
+ (xin, attrs, OO_GNUM_NS_EXT, "cursor-row", &row,
+ 0, gnm_sheet_get_last_row(sheet))) {};
+
+ state->pos.eval.col = col;
+ state->pos.eval.row = row;
+}
+
+static void
+odf_selection_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+
+ sv_set_edit_pos (sheet_get_view (state->pos.sheet, state->wb_view), &state->pos.eval);
+}
+
+
/****************************************************************************/
/******************************** settings.xml ******************************/
@@ -9100,6 +9162,8 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_OOO_COORDINATE_REGION, OO_NS_CHART_OOO, "coordinate-region", GSF_XML_NO_CONTENT, NULL, NULL),
#endif
GSF_XML_IN_NODE (SPREADSHEET, TABLE, OO_NS_TABLE, "table", GSF_XML_NO_CONTENT, &oo_table_start, &oo_table_end),
+ GSF_XML_IN_NODE (TABLE, SHEET_SELECTIONS, OO_GNUM_NS_EXT, "selections", GSF_XML_NO_CONTENT, &odf_selection, &odf_selection_end),
+ GSF_XML_IN_NODE (SHEET_SELECTIONS, SELECTION, OO_GNUM_NS_EXT, "selection", GSF_XML_NO_CONTENT, &odf_selection_range, NULL),
GSF_XML_IN_NODE (TABLE, TABLE_SOURCE, OO_NS_TABLE, "table-source", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TABLE, FORMS, OO_NS_OFFICE, "forms", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (FORMS, FORM, OO_NS_FORM, "form", GSF_XML_NO_CONTENT, NULL, NULL),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index aecb77b..ce2b4e9 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -250,10 +250,10 @@ 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);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "start-col", r->start.col);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "start-row", r->start.row);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "end-col", r->end.col);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "end-row", r->end.row);
}
static void
@@ -4454,8 +4454,8 @@ odf_write_content (GnmOOExport *state, GsfOutput *child)
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);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "cursor-col", sv->edit_pos_real.col);
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "cursor-row", sv->edit_pos_real.row);
/* Insert the selections in REVERSE order */
copy = g_slist_copy (sv->selections);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]