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)))
{
AT_CLEANUP
+
+dnl Check for a bug where certain gnumeric files failed an assertion
+AT_SETUP([GET DATA /TYPE=GNM assert-fail])
+AT_DATA([read.sps],[dnl
+GET DATA
+ /TYPE=GNM
+ /FILE='crash.gnumeric'
+ .
+list.
+])
+
+
+AT_DATA([crash.gnumeric],[dnl
+<?xml version="1.0" encoding="UTF-8"?>
+<gnm:Workbook xmlns:gnm="http://www.gnumeric.org/v10.dtd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gnumeric.org/v9.xsd">
+ <office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.1">
+ </office:document-meta>
+ <gnm:SheetNameIndex>
+ <gnm:SheetName gnm:Cols="256" gnm:Rows="65536">Sheet1</gnm:SheetName>
+ </gnm:SheetNameIndex>
+ <gnm:Sheets>
+ <gnm:Sheet DisplayFormulas="0" HideZero="0" HideGrid="0" HideColHeader="0" HideRowHeader="0" DisplayOutlines="1" OutlineSymbolsBelow="1" OutlineSymbolsRight="1" Visibility="GNM_SHEET_VISIBILITY_VISIBLE" GridColor="0:0:0">
+ <gnm:Name>Sheet1</gnm:Name>
+ <gnm:MaxCol>2</gnm:MaxCol>
+ <gnm:MaxRow>4</gnm:MaxRow>
+ <gnm:Styles>
+ <gnm:StyleRegion startCol="0" startRow="0" endCol="255" endRow="65535">
+ <gnm:Style HAlign="1" VAlign="2" WrapText="0" ShrinkToFit="0" Rotation="0" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="General">
+ </gnm:Style>
+ </gnm:StyleRegion>
+ </gnm:Styles>
+ <gnm:Cells>
+ <gnm:Cell Row="1" Col="1" ValueType="60">one</gnm:Cell>
+ <gnm:Cell Row="1" Col="2" ValueType="60">two</gnm:Cell>
+ <gnm:Cell Row="2" Col="1" ValueType="40">1</gnm:Cell>
+ <gnm:Cell Row="2" Col="2" ValueType="40">2</gnm:Cell>
+ <gnm:Cell Row="3" Col="1" ValueType="40">1</gnm:Cell>
+ <gnm:Cell Row="3" Col="2" ValueType="40">2</gnm:Cell>
+ <gnm:Cell Row="4" Col="1" ValueType="40">1</gnm:Cell>
+ <gnm:Cell Row="4" Col="2" ValueType="40">2</gnm:Cell>
+ </gnm:Cells>
+ </gnm:Sheet>
+ </gnm:Sheets>
+</gnm:Workbook>
+])
+
+AT_CHECK([pspp -O format=csv read.sps], [0], [ignore])
+
+
+AT_CLEANUP
+
+
+
AT_BANNER([GET DATA Spreadsheet /TYPE=ODS])
CHECK_SPREADSHEET_READER([ODS])