[gnumeric] Fix ODF import/export of unlinked checkboxes.



commit 84d560ad96c34f9102d27d616ffe1cefd0b6262e
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Apr 8 08:42:54 2015 -0600

    Fix ODF import/export of unlinked checkboxes.
    
    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
        * openoffice-write.c (odf_write_sheet_control_checkbox): write
        form:current-state

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    9 +++++++++
 plugins/openoffice/openoffice-read.c  |    9 +++++++++
 plugins/openoffice/openoffice-write.c |    4 +++-
 4 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 03f65a4..a32bb5b 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +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.
 
 Jean:
        * Fix signal handling while running Python. [#744638]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index e27e37a..583a402 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,12 @@
+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
+       * openoffice-write.c (odf_write_sheet_control_checkbox): write
+       form:current-state
+
 2015-04-07  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (od_draw_frame_start): ensure that the base address
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 22456ec..ee5ae4c 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -194,6 +194,7 @@ typedef struct {
        int page_step;
        char *value;
        char *value_type;
+       char *current_state;
        char *linked_cell;
        char *label;
        char *implementation;
@@ -3061,6 +3062,9 @@ 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)
+               g_object_set (G_OBJECT (so), "active", 
+                             strcmp (oc->current_state, "checked") == 0, NULL);
        if (oc->linked_cell) {
                GnmParsePos pp;
                GnmRangeRef ref;
@@ -9969,6 +9973,7 @@ oo_control_free (OOControl *ctrl)
        g_free (ctrl->value);
        g_free (ctrl->value_type);
        g_free (ctrl->label);
+       g_free (ctrl->current_state);
        g_free (ctrl->linked_cell);
        g_free (ctrl->implementation);
        g_free (ctrl->source_cell_range);
@@ -10740,6 +10745,10 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
                        g_free (oc->linked_cell);
                        oc->linked_cell =  g_strdup (CXML2C (attrs[1]));
                } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+                                            OO_NS_FORM, "current-state")) {
+                       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 d2735a3..61a6f37 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4061,12 +4061,14 @@ odf_write_sheet_control_checkbox (GnmOOExport *state, SheetObject *so)
 {
        GnmExprTop const *texpr = sheet_widget_checkbox_get_link (so);
        char *label = NULL;
+       gboolean active = NULL;
 
-       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 "checkbox");
 
        gsf_xml_out_add_cstr (state->xml, FORM "label", label);
+       gsf_xml_out_add_cstr (state->xml, FORM "current-state", active ? "checked" : "unchecked");
 
        odf_write_sheet_control_linked_cell (state, texpr);
 


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