[gnumeric] Import/export spinbuttons & sliders from and to ODF files.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Import/export spinbuttons & sliders from and to ODF files.
- Date: Fri, 10 Sep 2010 06:39:30 +0000 (UTC)
commit bd992f3993c30fe1718548aa4cf92c653de81d2c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Sep 10 00:35:56 2010 -0600
Import/export spinbuttons & sliders from and to ODF files.
2010-09-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_draw_control_start): handle spinbuttons and sliders
(oo_control_free): free new implementation field
(odf_form_control): handle spinbuttons and sliders
(odf_form_value_range): ditto
* openoffice-write.c
NEWS | 5 +--
plugins/openoffice/ChangeLog | 8 +++++++
plugins/openoffice/openoffice-read.c | 34 +++++++++++++++++++++++++++++---
plugins/openoffice/openoffice-write.c | 16 +++++++++++++-
4 files changed, 54 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 89d902f..b8c9ea5 100644
--- a/NEWS
+++ b/NEWS
@@ -4,9 +4,8 @@ Andreas:
* Fix image-fill, pattern and gradient export. [#628762]
* Read tab colors from OOo config in ODF files.
* Improve some ODF chart import/export.
- * Import/export scrollbars, checkboxes and radio buttons from and
- to ODF files.
-\
+ * Import/export various form controls from and to ODF files.
+
--------------------------------------------------------------------------
Gnumeric 1.10.10
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ff905a7..e6ff56e 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,11 @@
+2010-09-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (od_draw_control_start): handle spinbuttons and sliders
+ (oo_control_free): free new implementation field
+ (odf_form_control): handle spinbuttons and sliders
+ (odf_form_value_range): ditto
+ * openoffice-write.c
+
2010-09-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_draw_control_start): use gnm:value-type
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d98ee79..0b8c0e1 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -189,6 +189,7 @@ typedef struct {
char *value_type;
char *linked_cell;
char *label;
+ char *implementation;
} OOControl;
typedef struct {
@@ -4672,7 +4673,9 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
OOControl *oc = g_hash_table_lookup (state->controls, name);
if (oc != NULL) {
SheetObject *so = NULL;
- if (oc->t == sheet_widget_scrollbar_get_type ()) {
+ if (oc->t == sheet_widget_scrollbar_get_type () ||
+ oc->t == sheet_widget_spinbutton_get_type () ||
+ oc->t == sheet_widget_slider_get_type ()) {
GtkAdjustment *adj;
int min_real = (oc->min < oc->max) ? oc->min : oc->max;
int max_real = (oc->min < oc->max) ? oc->max : oc->min;
@@ -4755,7 +4758,9 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
GnmExprTop const *texpr
= gnm_expr_top_new_constant (v);
if (texpr != NULL) {
- if (oc->t == sheet_widget_scrollbar_get_type ())
+ if (oc->t == sheet_widget_scrollbar_get_type () ||
+ oc->t == sheet_widget_spinbutton_get_type () ||
+ oc->t == sheet_widget_slider_get_type ())
sheet_widget_adjustment_set_link
(so, texpr);
else if (oc->t == sheet_widget_checkbox_get_type ())
@@ -6048,6 +6053,7 @@ oo_control_free (OOControl *ctrl)
g_free (ctrl->value_type);
g_free (ctrl->label);
g_free (ctrl->linked_cell);
+ g_free (ctrl->implementation);
g_free (ctrl);
}
@@ -6148,10 +6154,29 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
OO_NS_FORM, "label")) {
g_free (oc->label);
oc->label = g_strdup (CXML2C (attrs[1]));
+ } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+ OO_NS_FORM, "control-implementation")) {
+ g_free (oc->implementation);
+ oc->implementation = g_strdup (CXML2C (attrs[1]));
}
if (name != NULL) {
- oc->t = t;
+ if (oc->implementation != NULL &&
+ t == sheet_widget_slider_get_type ()) {
+ if (0 == strcmp (oc->implementation, "gnm:scrollbar"))
+ oc->t = sheet_widget_scrollbar_get_type ();
+ else if (0 == strcmp (oc->implementation,
+ "gnm:spinbutton"))
+ oc->t = sheet_widget_spinbutton_get_type ();
+ else if (0 == strcmp (oc->implementation,
+ "gnm:slider"))
+ oc->t = sheet_widget_slider_get_type ();
+ else if (0 == strcmp (oc->implementation,
+ "ooo:com.sun.star.form."
+ "component.ScrollBar"))
+ oc->t = sheet_widget_scrollbar_get_type ();
+ } else
+ oc->t = t;
g_hash_table_replace (state->controls, name, oc);
} else
oo_control_free (oc);
@@ -6161,7 +6186,8 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
static void
odf_form_value_range (GsfXMLIn *xin, xmlChar const **attrs)
{
- odf_form_control (xin, attrs, sheet_widget_scrollbar_get_type ());
+
+ odf_form_control (xin, attrs, sheet_widget_slider_get_type ());
}
static void
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index d816af8..4a056d1 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3104,7 +3104,8 @@ odf_write_sheet_control_linked_cell (GnmOOExport *state, GnmExprTop const *texpr
}
static void
-odf_write_sheet_control_scrollbar (GnmOOExport *state, SheetObject *so)
+odf_write_sheet_control_scrollbar (GnmOOExport *state, SheetObject *so,
+ char const *implementation)
{
char const *id = odf_write_sheet_controls_get_id (state, so);
GtkAdjustment *adj = sheet_widget_adjustment_get_adjustment (so);
@@ -3113,6 +3114,10 @@ odf_write_sheet_control_scrollbar (GnmOOExport *state, SheetObject *so)
gsf_xml_out_start_element (state->xml, FORM "value-range");
gsf_xml_out_add_cstr (state->xml, XML "id", id);
gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+ if (implementation != NULL)
+ gsf_xml_out_add_cstr (state->xml,
+ FORM "control-implementation",
+ implementation);
gsf_xml_out_add_cstr (state->xml, FORM "orientation",
sheet_widget_adjustment_get_horizontal (so) ?
"horizontal" : "vertical");
@@ -3243,7 +3248,14 @@ odf_write_sheet_controls (GnmOOExport *state)
SheetObject *so = l->data;
if (GNM_IS_SOW_SCROLLBAR (so))
- odf_write_sheet_control_scrollbar (state, so);
+ odf_write_sheet_control_scrollbar
+ (state, so, GNMSTYLE "scrollbar");
+ else if (GNM_IS_SOW_SLIDER (so))
+ odf_write_sheet_control_scrollbar
+ (state, so, GNMSTYLE "slider");
+ else if (GNM_IS_SOW_SPINBUTTON (so))
+ odf_write_sheet_control_scrollbar
+ (state, so, GNMSTYLE "spinbutton");
else if (GNM_IS_SOW_CHECKBOX (so))
odf_write_sheet_control_checkbox (state, so);
else if (GNM_IS_SOW_RADIO_BUTTON (so))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]