enum reader_state state;
int row;
int col;
+ int min_col;
int node_type;
int sheet_index;
if (0 == xmlStrcasecmp (name, _xml("gnm:Cells")) &&
XML_READER_TYPE_ELEMENT == r->node_type)
{
+ r->min_col = INT_MAX;
if (! xmlTextReaderIsEmptyElement (r->xtr))
r->state = STATE_CELLS_START;
}
r->col = _xmlchar_to_int (attr);
free (attr);
+ if (r->col < r->min_col)
+ r->min_col = r->col;
+
attr = xmlTextReaderGetAttribute (r->xtr, _xml ("Row"));
r->row = _xmlchar_to_int (attr);
free (attr);
}
else
{
- r->start_col = 0;
+ r->start_col = -1;
r->start_row = 0;
r->stop_col = -1;
r->stop_row = -1;
if ( idx >= n_var_specs )
{
+ int i;
+ var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1));
+ for (i = n_var_specs; i <= idx; ++i)
+ {
+ var_spec [i].name = NULL;
+ var_spec [i].width = -1;
+ var_spec [i].first_value = NULL;
+ }
n_var_specs = idx + 1 ;
- var_spec = xrealloc (var_spec, sizeof (*var_spec) * n_var_specs);
- var_spec [idx].name = NULL;
- var_spec [idx].width = -1;
- var_spec [idx].first_value = NULL;
}
if ( r->node_type == XML_READER_TYPE_TEXT )
{
char *name;
+ if ( (var_spec[i].name == NULL) && (var_spec[i].first_value == NULL))
+ continue;
+
/* Probably no data exists for this variable, so allocate a
default width */
if ( var_spec[i].width == -1 )
r->first_case = case_create (r->proto);
case_set_missing (r->first_case);
+ int x = 0;
for ( i = 0 ; i < n_var_specs ; ++i )
{
- const struct variable *var = dict_get_var (r->dict, i);
+ if ( (var_spec[i].name == NULL) && (var_spec[i].first_value == NULL))
+ continue;
+
+ const struct variable *var = dict_get_var (r->dict, x++);
convert_xml_string_to_value (r->first_case, var,
var_spec[i].first_value);
c = case_create (r->proto);
case_set_missing (c);
+ if (r->start_col == -1)
+ r->start_col = r->min_col;
+
while ((r->state == STATE_CELL || r->state == STATE_CELLS_START )
&& r->row == current_row && (ret = xmlTextReaderRead (r->xtr)))
{