}
+static void
+gnumeric_error_handler (void *ctx, const char *mesg,
+ UNUSED xmlParserSeverities sev, xmlTextReaderLocatorPtr loc)
+{
+ struct gnumeric_reader *r = ctx;
+
+ msg (MW, _("There was a problem whilst reading the Gnumeric file `%s' (near line %d): `%s'"),
+ r->spreadsheet.file_name,
+ xmlTextReaderLocatorLineNumber (loc),
+ mesg);
+}
+
static struct gnumeric_reader *
-gnumeric_reopen (struct gnumeric_reader *r, const char *filename)
+gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_errors)
{
int ret;
if (NULL == gz)
return NULL;
+
xtr = xmlReaderForIO ((xmlInputReadCallback) gzread,
- (xmlInputCloseCallback) gzclose, gz,
- NULL, NULL, 0);
+ (xmlInputCloseCallback) gzclose, gz,
+ NULL, NULL,
+ show_errors ? 0 : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING) );
if (xtr == NULL)
{
r->spreadsheet.n_sheets = -1;
r->spreadsheet.file_name = filename;
}
+
+ if (show_errors)
+ xmlTextReaderSetErrorHandler (xtr, gnumeric_error_handler, r);
r->target_sheet = NULL;
r->target_sheet_index = -1;
struct spreadsheet *
-gnumeric_probe (const char *filename)
+gnumeric_probe (const char *filename, bool report_errors)
{
- struct gnumeric_reader *r = gnumeric_reopen (NULL, filename);
+ struct gnumeric_reader *r = gnumeric_reopen (NULL, filename, report_errors);
return &r->spreadsheet;
}
r = (struct gnumeric_reader *) (spreadsheet);
if (r->row != -1)
- r = gnumeric_reopen (r, NULL);
+ r = gnumeric_reopen (r, NULL, true);
if ( opts->cell_range )
{
struct spreadsheet_read_info;
struct spreadsheet_read_options;
-struct spreadsheet *gnumeric_probe (const char *filename);
+struct spreadsheet *gnumeric_probe (const char *filename, bool report_errors);
const char * gnumeric_get_sheet_name (struct spreadsheet *s, int n);
return -1;
}
-struct spreadsheet *ods_probe (const char *filename)
+struct spreadsheet *ods_probe (const char *filename, bool report_errors)
{
struct ods_reader *r;
struct string errs;
struct spreadsheet_read_options;
-struct spreadsheet *ods_probe (const char *filename);
+struct spreadsheet *ods_probe (const char *filename, bool report_errors);
struct casereader * ods_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_info *gri,
{
struct spreadsheet *ss = NULL;
- ss = gnumeric_probe (filename);
+ ss = gnumeric_probe (filename, true);
return ss;
}
if ( 0 == strncasecmp (tok, "GNM", 3))
{
- struct spreadsheet *spreadsheet = gnumeric_probe (filename);
+ struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
reader = gnumeric_make_reader (spreadsheet, &sri, &opts);
dict = spreadsheet->dict;
}
else if (0 == strncasecmp (tok, "ODS", 3))
{
- struct spreadsheet *spreadsheet = ods_probe (filename);
+ struct spreadsheet *spreadsheet = ods_probe (filename, true);
reader = ods_make_reader (spreadsheet, &sri, &opts);
dict = spreadsheet->dict;
}
else
gtk_widget_grab_focus (assistant->forward);
-
-
-
#if 0
gtk_widget_show (ia->asst.reset_button);
if (page == ia->formats->page)
gtk_widget_show (ia->asst.paste_button);
else
gtk_widget_hide (ia->asst.paste_button);
-
#endif
}
printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet);
if (ia->spreadsheet == NULL)
- ia->spreadsheet = gnumeric_probe (file->file_name);
+ ia->spreadsheet = gnumeric_probe (file->file_name, false);
printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet);
if (ia->spreadsheet == NULL)
- ia->spreadsheet = ods_probe (file->file_name);
+ ia->spreadsheet = ods_probe (file->file_name, false);
printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet);
if ( argc < 2)
g_error ("Usage: prog file\n");
- sp = gnumeric_probe (argv[1]);
+ sp = gnumeric_probe (argv[1], true);
if (sp == NULL)
{