Got the ODS reader model (sort of) working.
[pspp] / src / data / ods-reader.c
index 51ee5ac39ace8994901deed27ef1e236ef56591d..7079027f3d4d926354935f81c7a545e529245f8d 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 
 #include "libpspp/message.h"
 #include "libpspp/misc.h"
+#include "libpspp/assertion.h"
 
 #include "data/data-in.h"
 
@@ -33,7 +34,8 @@
 #if !ODF_READ_SUPPORT
 
 struct casereader *
-ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
+ods_open_reader (const struct spreadsheet_read_options *opts, 
+                struct dictionary **dict)
 {
   msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "OpenDocument");
 
@@ -75,6 +77,21 @@ static const struct casereader_class ods_file_casereader_class =
     NULL,
   };
 
+struct sheet_detail
+{
+  /* The name of the sheet (utf8 encoding) */
+  char *name;
+
+  int start_col;
+  int stop_col;
+  int start_row;
+  int stop_row;
+
+  int maxcol;
+  int maxrow;
+};
+
+
 enum reader_state
   {
     STATE_INIT = 0,        /* Initial state */
@@ -87,6 +104,8 @@ enum reader_state
 
 struct ods_reader
 {
+  struct spreadsheet spreadsheet;
+
   xmlTextReaderPtr xtr;
 
   enum reader_state state;
@@ -95,6 +114,8 @@ struct ods_reader
   int col;
   int node_type;
   int sheet_index;
+  int max_col;
+  int min_col;
 
   const xmlChar *target_sheet;
   int target_sheet_index;
@@ -104,6 +125,9 @@ struct ods_reader
   int stop_row;
   int stop_col;
 
+  struct sheet_detail *sheets;
+  int n_allocated_sheets;
+
   struct caseproto *proto;
   struct dictionary *dict;
   struct ccase *first_case;
@@ -111,11 +135,57 @@ struct ods_reader
   bool read_names;
 
   struct string ods_errs;
-  int span;
 };
 
+
 static void process_node (struct ods_reader *r);
 
+
+const char *
+ods_get_sheet_name (struct spreadsheet *s, int n)
+{
+  int ret;
+  struct ods_reader *or = (struct ods_reader *) s;
+  
+  assert (n < s->n_sheets);
+
+  while ( 
+        (or->n_allocated_sheets <= n)
+        && 
+        (1 == (ret = xmlTextReaderRead (or->xtr)))
+         )
+    {
+      process_node (or);
+    }
+
+  return or->sheets[n].name;
+}
+
+char *
+ods_get_sheet_range (struct spreadsheet *s, int n)
+{
+  int ret;
+  struct ods_reader *or = (struct ods_reader *) s;
+  
+  assert (n < s->n_sheets);
+
+  while ( 
+        (or->n_allocated_sheets <= n || or->sheets[n].stop_col == -1)
+        && 
+        (1 == (ret = xmlTextReaderRead (or->xtr)))
+         )
+    {
+      process_node (or);
+    }
+
+  return create_cell_ref (
+                         or->sheets[n].start_col,
+                         or->sheets[n].start_row,
+                         or->sheets[n].stop_col,
+                         or->sheets[n].stop_row);
+}
+
+
 static void
 ods_file_casereader_destroy (struct casereader *reader UNUSED, void *r_)
 {
@@ -127,7 +197,7 @@ ods_file_casereader_destroy (struct casereader *reader UNUSED, void *r_)
     xmlFreeTextReader (r->xtr);
 
   if ( ! ds_is_empty (&r->ods_errs))
-    msg (ME, ds_cstr (&r->ods_errs));
+    msg (ME, "%s", ds_cstr (&r->ods_errs));
 
   ds_destroy (&r->ods_errs);
 
@@ -146,111 +216,151 @@ process_node (struct ods_reader *r)
   if (name == NULL)
     name = xmlStrdup (_xml ("--"));
 
+
   r->node_type = xmlTextReaderNodeType (r->xtr);
 
-  switch ( r->state)
+  switch (r->state)
     {
     case STATE_INIT:
       if (0 == xmlStrcasecmp (name, _xml("office:spreadsheet")) &&
          XML_READER_TYPE_ELEMENT  == r->node_type)
        {
+         printf ("%s:%d Start of Workbook %d: Rows %d\n", __FILE__, __LINE__,
+                 r->sheet_index,  r->row);
+
          r->state = STATE_SPREADSHEET;
        }
       break;
     case STATE_SPREADSHEET:
-      if (0 == xmlStrcasecmp (name, _xml("table:table")))
+      if (0 == xmlStrcasecmp (name, _xml("table:table"))
+         && 
+         (XML_READER_TYPE_ELEMENT == r->node_type))
        {
-         if (XML_READER_TYPE_ELEMENT == r->node_type)
+         xmlChar *value = xmlTextReaderGetAttribute (r->xtr, _xml ("table:name"));
+         r->sheets = xrealloc (r->sheets, sizeof (*r->sheets) * ++r->n_allocated_sheets);
+         r->sheets[r->n_allocated_sheets - 1].start_col = -1;
+         r->sheets[r->n_allocated_sheets - 1].stop_col = -1;
+         r->sheets[r->n_allocated_sheets - 1].start_row = -1;
+         r->sheets[r->n_allocated_sheets - 1].stop_row = -1;
+         r->sheets[r->n_allocated_sheets - 1].name = value;
+         r->col = -1;
+         r->row = -1;
+         r->max_col = -1;
+         r->min_col = INT_MAX;
+         ++r->sheet_index;
+
+         printf ("%s:%d Start of SHEET %d: Rows %d\n", __FILE__, __LINE__,
+                 r->sheet_index,  r->row);
+
+         if ( r->target_sheet != NULL)
            {
-             r->col = -1;
-             r->row = -1;
-             ++r->sheet_index;
-             if ( r->target_sheet != NULL)
-               {
-                 xmlChar *value = xmlTextReaderGetAttribute (r->xtr, _xml ("table:name"));
-                 if ( 0 == xmlStrcmp (value, r->target_sheet))
-                   {
-                     r->sheet_found = true;
-                     r->state = STATE_TABLE;
-                   }
-                 free (value);
-               }
-             else if (r->target_sheet_index == r->sheet_index)
+             if ( 0 == xmlStrcmp (value, r->target_sheet))
                {
                  r->sheet_found = true;
-                 r->state = STATE_TABLE;
                }
-             else if ( r->target_sheet_index == -1)
-               r->state = STATE_TABLE;
            }
+         else if (r->target_sheet_index == r->sheet_index)
+           {
+             r->sheet_found = true;
+           }
+         r->state = STATE_TABLE;
        }
-      else if (XML_READER_TYPE_END_ELEMENT  == r->node_type
-                  && r->sheet_found)
+      else if (0 == xmlStrcasecmp (name, _xml("office:spreadsheet")) &&
+              XML_READER_TYPE_ELEMENT  == r->node_type)
        {
          r->state = STATE_INIT;
+         printf ("%s:%d End of Workbook %d: Rows %d Cols %d\n", __FILE__, __LINE__,
+                 r->sheet_index,  r->row, r->col);
        }
-       break;
+      break;
     case STATE_TABLE:
-      if (0 == xmlStrcasecmp (name, _xml("table:table-row")) )
+      if (0 == xmlStrcasecmp (name, _xml("table:table-row")) && 
+         (XML_READER_TYPE_ELEMENT  == r->node_type))
        {
-         if ( XML_READER_TYPE_ELEMENT  == r->node_type)
-           {
-             if (! xmlTextReaderIsEmptyElement (r->xtr))
-               {
-                 r->state = STATE_ROW;
-               }
-             r->row++;
-             r->span = 1;
-           }
+         xmlChar *value =
+           xmlTextReaderGetAttribute (r->xtr,
+                                      _xml ("table:number-rows-repeated"));
+         
+         int row_span = value ? _xmlchar_to_int (value) : 1;
+
+         printf ("%s:%d  Start of Row %d Span %d\n", __FILE__, __LINE__,  r->row, row_span);
+         r->row += row_span;
+         r->col = -1;
+         
+         if (! xmlTextReaderIsEmptyElement (r->xtr))
+           r->state = STATE_ROW;
        }
-      else if (XML_READER_TYPE_END_ELEMENT  == r->node_type)
+      else if (0 == xmlStrcasecmp (name, _xml("table:table")) && 
+              (XML_READER_TYPE_END_ELEMENT  == r->node_type))
        {
+         printf ("%s:%d End of SHEET %d %d,%d\n", __FILE__, __LINE__,  r->sheet_index,  r->row, r->col);
+         r->sheets[r->sheet_index].stop_row = r->row;
+         r->sheets[r->sheet_index].stop_col = r->max_col - 1;
+         r->sheets[r->sheet_index].start_col = r->min_col;
          r->state = STATE_SPREADSHEET;
+
        }
       break;
     case STATE_ROW:
-      if (0 == xmlStrcasecmp (name, _xml ("table:table-cell")))
+      if ( (0 == xmlStrcasecmp (name, _xml ("table:table-cell")))
+          && 
+          (XML_READER_TYPE_ELEMENT  == r->node_type))
        {
-         if ( XML_READER_TYPE_ELEMENT  == r->node_type)
-           {
-             xmlChar *value =
-               xmlTextReaderGetAttribute (r->xtr,
-                                          _xml ("table:number-columns-repeated"));
-             r->col += r->span;
-             r->span = value ? _xmlchar_to_int (value) : 1;
-             free (value);
-             if (! xmlTextReaderIsEmptyElement (r->xtr))
-               {
-                 r->state = STATE_CELL;
-               }
-           }
+         xmlChar *value =
+           xmlTextReaderGetAttribute (r->xtr,
+                                      _xml ("table:number-columns-repeated"));
+         
+         int col_span = value ? _xmlchar_to_int (value) : 0;
+
+         r->col += col_span;
+         r->col ++;
+
+         if (r->min_col > r->col)
+           r->min_col = r->col;
+
+         printf ("%s:%d  Start of Cell %d, %d\n", __FILE__, __LINE__,    r->row, r->col);
+         if (! xmlTextReaderIsEmptyElement (r->xtr))
+           r->state = STATE_CELL;
        }
-      else if (XML_READER_TYPE_END_ELEMENT  == r->node_type)
+      else if ( (0 == xmlStrcasecmp (name, _xml ("table:table-row")))
+               &&
+               (XML_READER_TYPE_END_ELEMENT  == r->node_type))
        {
-         r->state = STATE_TABLE;
-         r->col = -1;
          /* Set the span back to the default */
-         r->span = 1;
+         printf ("%s:%d  End of Cell:  %d, %d\n", __FILE__, __LINE__, r->row, r->col);
+         if ( r->max_col < r->col)
+           r->max_col = r->col;
+         r->state = STATE_TABLE;
        }
       break;
     case STATE_CELL:
-      if (0 == xmlStrcasecmp (name, _xml("text:p")))
+      if ( (0 == xmlStrcasecmp (name, _xml("text:p")))
+           &&
+          ( XML_READER_TYPE_ELEMENT  == r->node_type))
        {
-         if ( XML_READER_TYPE_ELEMENT  == r->node_type)
-           {
-             r->state = STATE_CELL_CONTENT;
-           }
+         //      printf ("%s:%d  Start of Cell Contents %d\n", __FILE__, __LINE__,    r->row);
+         if (! xmlTextReaderIsEmptyElement (r->xtr))
+           r->state = STATE_CELL_CONTENT;
        }
-      else if (XML_READER_TYPE_END_ELEMENT  == r->node_type)
+      else if
+       ( (0 == xmlStrcasecmp (name, _xml("table:table-cell")))
+         &&
+         (XML_READER_TYPE_END_ELEMENT  == r->node_type)
+         )
        {
+         //  printf ("%s:%d End of Cell contents: Rows %d\n", __FILE__, __LINE__, r->row);
          r->state = STATE_ROW;
        }
       break;
     case STATE_CELL_CONTENT:
-      if (XML_READER_TYPE_TEXT != r->node_type)
-       r->state = STATE_CELL;
+      if (r->sheets[r->sheet_index].start_row == -1)
+       r->sheets[r->sheet_index].start_row = r->row;
+      //      printf ("%s:%d Cell contents: Rows %d\n", __FILE__, __LINE__, r->row);
+      /* if (XML_READER_TYPE_TEXT != r->node_type) */
+      r->state = STATE_CELL;
       break;
     default:
+      NOT_REACHED ();
       break;
     };
 
@@ -315,78 +425,157 @@ convert_xml_to_value (struct ccase *c, const struct variable *var,
     value_copy_str_rpad (v, var_get_width (var), xmv->text, ' ');
   else
     {
+      const char *text ;
       const struct fmt_spec *fmt = var_get_write_format (var);
       enum fmt_category fc  = fmt_get_category (fmt->type);
 
       assert ( fc != FMT_CAT_STRING);
 
-      const char *text = xmv->value ? CHAR_CAST (const char *, xmv->value):
-       CHAR_CAST (const char *, xmv->text);
+      text =
+        xmv->value ? CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text);
 
-      data_in (ss_cstr (text), "UTF-8",
-              fmt->type,
-              v,
-              var_get_width (var),
-              "UTF-8");
+      free (data_in (ss_cstr (text), "UTF-8",
+                     fmt->type,
+                     v,
+                     var_get_width (var),
+                     "UTF-8"));
     }
 }
 
 
-struct casereader *
-ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
+/* Try to find out how many sheets there are in the "workbook" */
+static int
+get_sheet_count (struct zip_reader *zreader)
 {
-  int ret = 0;
-  xmlChar *type = NULL;
-  unsigned long int vstart = 0;
-  casenumber n_cases = CASENUMBER_MAX;
-  int i;
-  struct var_spec *var_spec = NULL;
-  int n_var_specs = 0;
+  xmlTextReaderPtr mxtr;
+  struct zip_member *meta = NULL;
+  meta = zip_member_open (zreader, "meta.xml");
 
-  struct ods_reader *r = xzalloc (sizeof *r);
+  if ( meta == NULL)
+    return -1;
+
+  mxtr = xmlReaderForIO ((xmlInputReadCallback) zip_member_read,
+                        (xmlInputCloseCallback) zip_member_finish,
+                        meta,   NULL, NULL, 0);
+
+  while (1 == xmlTextReaderRead (mxtr))
+    {
+      xmlChar *name = xmlTextReaderName (mxtr);
+      if ( 0 == xmlStrcmp (name, _xml("meta:document-statistic")))
+       {
+         xmlChar *attr = xmlTextReaderGetAttribute (mxtr, _xml ("meta:table-count"));
+           
+         if ( attr != NULL)
+           {
+             int s = _xmlchar_to_int (attr);
+             return s;
+           }
+       }
+    }
+  return -1;
+}
+
+static void
+ods_error_handler (void *ctx, const char *mesg,
+                       UNUSED xmlParserSeverities sev, xmlTextReaderLocatorPtr loc)
+{
+  struct ods_reader *r = ctx;
+       
+  msg (MW, _("There was a problem whilst reading the %s file `%s' (near line %d): `%s'"),
+       "ODF",
+       r->spreadsheet.file_name,
+       xmlTextReaderLocatorLineNumber (loc),
+       mesg);
+}
 
-  r->read_names = gri->read_names;
-  ds_init_empty (&r->ods_errs);
 
-  struct zip_reader *zreader = zip_reader_create (gri->file_name, &r->ods_errs);
+struct spreadsheet *
+ods_probe (const char *filename, bool report_errors)
+{
+  struct ods_reader *r;
+  struct string errs;
+  xmlTextReaderPtr xtr ;
+  int sheet_count;
   struct zip_member *content = NULL;
 
-  if ( NULL == zreader)
-    {
-      msg (ME, _("Error opening `%s' for reading as a OpenDocument spreadsheet file: %s."),
-           gri->file_name, ds_cstr (&r->ods_errs));
+  struct zip_reader *zreader = NULL;
 
-      goto error;
-    }
+  ds_init_empty (&errs);
+
+  zreader = zip_reader_create (filename, &errs);
+
+  if (zreader == NULL)
+    return NULL;
 
   content = zip_member_open (zreader, "content.xml");
-  if ( NULL == content)
-    {
-      msg (ME, _("Could not extract OpenDocument spreadsheet from file `%s': %s."),
-           gri->file_name, ds_cstr (&r->ods_errs));
 
-      goto error;
-    }
+  if ( content == NULL)
+    goto error;
 
   zip_member_ref (content);
 
-  r->xtr = xmlReaderForIO ((xmlInputReadCallback) zip_member_read,
-                          (xmlInputCloseCallback) zip_member_finish,
-                          content,   NULL, NULL, XML_PARSE_RECOVER);
+  sheet_count = get_sheet_count (zreader);
 
-  if ( r->xtr == NULL)
-    {
-      goto error;
-    }
+  xtr = xmlReaderForIO ((xmlInputReadCallback) zip_member_read,
+                       (xmlInputCloseCallback) zip_member_finish,
+                       content,   NULL, NULL,
+                       report_errors ? 0 : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING) );
+
+  if ( xtr == NULL)
+    goto error;
+
+  r = xzalloc (sizeof *r);
+  r->xtr = xtr;
+  r->spreadsheet.type = SPREADSHEET_ODS;
+  r->spreadsheet.n_sheets = sheet_count;
+  r->n_allocated_sheets = 0;
+  r->sheet_index = -1;
+  r->sheets = NULL;
+
+  if (report_errors) 
+    xmlTextReaderSetErrorHandler (xtr, ods_error_handler, r);
+
+
+  ds_destroy (&errs);
+
+  printf ("%s:%d\n", __FILE__, __LINE__);
+
+  r->spreadsheet.file_name = filename;
+  return &r->spreadsheet;
+
+ error:
+  zip_reader_destroy (zreader);
+  ds_destroy (&errs);
+  return NULL;
+}
+
+struct casereader *
+ods_make_reader (struct spreadsheet *spreadsheet, 
+                const struct spreadsheet_read_options *opts)
+{
+  intf ret = 0;
+  xmlChar *type = NULL;
+  unsigned long int vstart = 0;
+  casenumber n_cases = CASENUMBER_MAX;
+  int i;
+  struct var_spec *var_spec = NULL;
+  int n_var_specs = 0;
+
+  struct ods_reader *r = (struct ods_reader *) spreadsheet;
+  xmlChar *val_string = NULL;
 
-  if ( gri->cell_range )
+  assert (r);
+  r->read_names = opts->read_names;
+  ds_init_empty (&r->ods_errs);
+
+  if ( opts->cell_range )
     {
-      if ( ! convert_cell_ref (gri->cell_range,
+      if ( ! convert_cell_ref (opts->cell_range,
                               &r->start_col, &r->start_row,
                               &r->stop_col, &r->stop_row))
        {
          msg (SE, _("Invalid cell range `%s'"),
-              gri->cell_range);
+              opts->cell_range);
          goto error;
        }
     }
@@ -399,8 +588,8 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
     }
 
   r->state = STATE_INIT;
-  r->target_sheet = BAD_CAST gri->sheet_name;
-  r->target_sheet_index = gri->sheet_index;
+  r->target_sheet = BAD_CAST opts->sheet_name;
+  r->target_sheet_index = opts->sheet_index;
   r->row = r->col = -1;
   r->sheet_index = 0;
 
@@ -408,8 +597,10 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
   /* If CELLRANGE was given, then we know how many variables should be read */
   if ( r->stop_col != -1 )
     {
+      assert (var_spec == NULL);
       n_var_specs =  r->stop_col - r->start_col + 1;
       var_spec = xrealloc (var_spec, sizeof (*var_spec) * n_var_specs);
+      memset (var_spec, '\0', sizeof (*var_spec) * n_var_specs);
     }
 
 
@@ -425,11 +616,11 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
   if (ret < 1)
     {
       msg (MW, _("Selected sheet or range of spreadsheet `%s' is empty."),
-           gri->file_name);
+           spreadsheet->file_name);
       goto error;
     }
 
-  if ( gri->read_names)
+  if ( opts->read_names)
     {
       while (1 == (ret = xmlTextReaderRead (r->xtr)))
        {
@@ -457,7 +648,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
                  var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1));
 
                  /* xrealloc (unlike realloc) doesn't initialise its memory to 0 */
-                 memset (var_spec + n_var_specs * sizeof (*var_spec),
+                 memset (var_spec + n_var_specs,
                          0, 
                          (n_var_specs - idx + 1) * sizeof (*var_spec));
                  n_var_specs = idx + 1;
@@ -473,13 +664,12 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
        }
     }
 
-  xmlChar *val_string = NULL;
   /* Read in the first row of data */
   while (1 == xmlTextReaderRead (r->xtr))
     {
       int idx;
       process_node (r);
-      if ( r->row >= r->start_row + 1 + gri->read_names)
+      if ( r->row >= r->start_row + 1 + opts->read_names)
        break;
 
       if ( r->col < r->start_col)
@@ -509,7 +699,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
     }
 
   /* Create the dictionary and populate it */
-  *dict = r->dict = dict_create (
+  r->spreadsheet.dict = r->dict = dict_create (
     CHAR_CAST (const char *, xmlTextReaderConstEncoding (r->xtr)));
 
   for (i = 0 ; i < n_var_specs ; ++i )
@@ -517,7 +707,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
       struct fmt_spec fmt;
       struct variable *var = NULL;
       char *name = dict_make_unique_var_name (r->dict, var_spec[i].name, &vstart);
-      int width  = xmv_to_width (&var_spec[i].firstval, gri->asw);
+      int width  = xmv_to_width (&var_spec[i].firstval, opts->asw);
       dict_create_var (r->dict, name, width);
       free (name);
 
@@ -541,7 +731,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
   if ( n_var_specs ==  0 )
     {
       msg (MW, _("Selected sheet or range of spreadsheet `%s' is empty."),
-           gri->file_name);
+           spreadsheet->file_name);
       goto error;
     }
 
@@ -556,7 +746,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
       convert_xml_to_value (r->first_case, var,  &var_spec[i].firstval);
     }
 
-  zip_reader_destroy (zreader);
+  //  zip_reader_destroy (zreader);
 
   for ( i = 0 ; i < n_var_specs ; ++i )
     {
@@ -576,7 +766,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
 
  error:
   
-  zip_reader_destroy (zreader);
+  // zip_reader_destroy (zreader);
 
   for ( i = 0 ; i < n_var_specs ; ++i )
     {
@@ -588,6 +778,11 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
 
   free (var_spec);
 
+  dict_destroy (r->spreadsheet.dict);
+  r->spreadsheet.dict = NULL;
+  ods_file_casereader_destroy (NULL, r);
+
+
   return NULL;
 }
 
@@ -611,7 +806,6 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
       return r->first_case;
     }
 
-
   if ( r->state > STATE_INIT)
     {
       c = case_create (r->proto);
@@ -651,6 +845,7 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
          xmv->value = val_string;
          val_string = NULL;
 
+         /*
          for (col = 0; col < r->span ; ++col)
            {
              const int idx = r->col + col - r->start_col;
@@ -659,6 +854,7 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
 
              convert_xml_to_value (c, var, xmv);
            }
+         */
          free (xmv->text);
          free (xmv->value);
          free (xmv);