[gnumeric] Fix ODF import/export of unlinked radio buttons.



commit e99aa9b141f02e6d4d8ad4dbe035ca6ffe98cf7c
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Apr 8 21:47:53 2015 -0600

    Fix ODF import/export of unlinked radio buttons.
    
    2015-04-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_complete_control_setup): setup value for
        radio buttons
        (odf_form_control): read form:current-selected
        * openoffice-write.c (odf_write_sheet_control_checkbox): write
        form:current-selected

 NEWS                                  |    2 +-
 plugins/openoffice/ChangeLog          |    8 ++++++++
 plugins/openoffice/openoffice-read.c  |   10 ++++++++--
 plugins/openoffice/openoffice-write.c |    6 ++++--
 4 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index a32bb5b..7e55cc9 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,7 @@ Andreas:
        * Fix ODF export of styles for additional axes. [#746621]
        * Simplify export of SEC and SECH to ODF. [#747211]
        * Harden ODF import against fuzzed files. [#747447][#747448]
-       * Fix ODF import/export of unlinked checkboxes.
+       * Fix ODF import/export of unlinked checkboxes and radio buttons.
 
 Jean:
        * Fix signal handling while running Python. [#744638]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 583a402..5c8876c 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,6 +1,14 @@
 2015-04-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (odf_complete_control_setup): setup value for
+       radio buttons
+       (odf_form_control): read form:current-selected
+       * openoffice-write.c (odf_write_sheet_control_checkbox): write
+       form:current-selected
+
+2015-04-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (odf_complete_control_setup): setup value for
        checkboxes
        (oo_control_free): free current_state
        (odf_form_control): read form:current-state
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index ee5ae4c..e923ca5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3062,9 +3062,11 @@ odf_complete_control_setup (OOParseState *state, object_offset_t const *ob_off)
        if (oc == NULL)
                return;
 
-       if (oc->t == sheet_widget_checkbox_get_type () && oc->current_state != NULL)
+       if ((oc->t == sheet_widget_checkbox_get_type () ||
+            oc->t == sheet_widget_radio_button_get_type ()) && oc->current_state != NULL)
                g_object_set (G_OBJECT (so), "active", 
-                             strcmp (oc->current_state, "checked") == 0, NULL);
+                             strcmp (oc->current_state, "checked") == 0 || 
+                             strcmp (oc->current_state, "true") == 0, NULL);
        if (oc->linked_cell) {
                GnmParsePos pp;
                GnmRangeRef ref;
@@ -10749,6 +10751,10 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
                        g_free (oc->current_state);
                        oc->current_state =  g_strdup (CXML2C (attrs[1]));
                } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+                                            OO_NS_FORM, "current-selected")) {
+                       g_free (oc->current_state);
+                       oc->current_state =  g_strdup (CXML2C (attrs[1]));
+               } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
                                             OO_NS_FORM, "label")) {
                        g_free (oc->label);
                        oc->label =  g_strdup (CXML2C (attrs[1]));
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 61a6f37..5069362 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4061,7 +4061,7 @@ odf_write_sheet_control_checkbox (GnmOOExport *state, SheetObject *so)
 {
        GnmExprTop const *texpr = sheet_widget_checkbox_get_link (so);
        char *label = NULL;
-       gboolean active = NULL;
+       gboolean active = FALSE;
 
        g_object_get (G_OBJECT (so), "text", &label, "active", &active, NULL);
 
@@ -4136,12 +4136,14 @@ odf_write_sheet_control_radio_button (GnmOOExport *state, SheetObject *so)
        GnmExprTop const *texpr = sheet_widget_radio_button_get_link (so);
        GnmValue const *val = sheet_widget_radio_button_get_value (so);
        char *label = NULL;
+       gboolean active = FALSE;
 
-       g_object_get (G_OBJECT (so), "text", &label, NULL);
+       g_object_get (G_OBJECT (so), "text", &label, "active", &active, NULL);
 
        odf_sheet_control_start_element (state, so, FORM "radio");
 
        gsf_xml_out_add_cstr (state->xml, FORM "label", label);
+       odf_add_bool (state->xml, FORM "current-selected", active);
 
        if (val != NULL) {
                switch (val->v_any.type) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]