Commit 5a22e1df authored by Jon Kåre Hellan's avatar Jon Kåre Hellan
Browse files

Checked error reporting in plugins.

In plugins/dif:

        * dif.c	(dif_write_workbook): Improve reporting.

In plugins/ff-csv

	* csv-io.c (csv_write_workbook): Ditto.

In plugins/ff-stf

	* dialog-stf.c (dialog_stf): Return -1 on cancel, 0 otherwise.

In plugins/html

	* roff.c (write_wb_roff): Check missing style.
	(html_write_wb_roff_ps, html_write_wb_roff_dvi,
	html_write_wb_roff_pdf, html_write_wb_roff): Check popen result.
	(write_wb_roff): Add command context.

	* epsf.c (epsf_write_wb): Call gnumeric_error_save on
	failure.

	* html.c (html_write_wb_html32, html_write_wb_html40): Ditto.

	* latex.c (html_write_wb_latex, html_write_wb_latex2e)): Call
	gnumeric_error_save on failure. Dont't panic on missing style.

In plugins/lotus-123

	* lotus.c (read_workbook): Add CommandContext.

In plugins/oleo

	* oleo.c (oleo_read): Really return 0 on success.

In plugins/text

	* text-io.c (text_write_workbook): Call gnumeric_error_save on
	failure.

In plugins/xbase

	* boot.c: Ditto.
parent 489fa515
2000-01-31 Jon K Hellan <hellan@acm.org>
* dif.c (dif_write_workbook): Improve reporting.
2000-01-31 Jon K Hellan <hellan@acm.org> 2000-01-31 Jon K Hellan <hellan@acm.org>
* dif.c (dif_write_workbook): Call gnumeric_error_save on failure. * dif.c (dif_write_workbook): Call gnumeric_error_save on failure.
......
...@@ -379,8 +379,8 @@ dif_write_workbook (CommandContext *context, ...@@ -379,8 +379,8 @@ dif_write_workbook (CommandContext *context,
char *workstring; char *workstring;
if (!f) { if (!f) {
rc = -1; gnumeric_error_save (context, g_strerror (errno));
goto out; return -1;
} }
/* /*
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* csv-io.c (csv_write_workbook): Improve reporting.
2000-01-31 Jon K Hellan <hellan@acm.org> 2000-01-31 Jon K Hellan <hellan@acm.org>
* csv-io.c (csv_write_workbook): Call gnumeric_error_save on * csv-io.c (csv_write_workbook): Call gnumeric_error_save on
......
...@@ -254,8 +254,8 @@ csv_write_workbook (CommandContext *context, Workbook *wb, ...@@ -254,8 +254,8 @@ csv_write_workbook (CommandContext *context, Workbook *wb,
FILE *f = fopen (filename, "w"); FILE *f = fopen (filename, "w");
if (!f) { if (!f) {
rc = -1; gnumeric_error_save (context, g_strerror (errno));
goto out; return -1;
} }
setvbuf (f, NULL, _IOFBF, PAGE_SIZE); setvbuf (f, NULL, _IOFBF, PAGE_SIZE);
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* dialog-stf.c (dialog_stf): Return -1 on cancel, 0 otherwise.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
Megacommit. Megacommit.
......
...@@ -365,7 +365,10 @@ dialog_stf (CommandContext *context, FileSource_t *src) ...@@ -365,7 +365,10 @@ dialog_stf (CommandContext *context, FileSource_t *src)
gtk_widget_destroy (GTK_WIDGET (pagedata.window)); gtk_widget_destroy (GTK_WIDGET (pagedata.window));
gtk_object_unref (GTK_OBJECT (gui)); gtk_object_unref (GTK_OBJECT (gui));
return -1; if (pagedata.canceled)
return -1;
else
return 0;
} }
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* roff.c (write_wb_roff): Check missing style.
(html_write_wb_roff_ps, html_write_wb_roff_dvi,
html_write_wb_roff_pdf, html_write_wb_roff): Check popen result.
(write_wb_roff): Add command context.
* epsf.c (epsf_write_wb): Call gnumeric_error_save on
failure.
* html.c (html_write_wb_html32, html_write_wb_html40): Ditto.
* latex.c (html_write_wb_latex, html_write_wb_latex2e)): Call
gnumeric_error_save on failure. Dont't panic on missing style.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
Megacommit. Megacommit.
......
...@@ -69,7 +69,7 @@ html_init (void) ...@@ -69,7 +69,7 @@ html_init (void)
desc = _("HTML 4.0 file format (*.html)"); desc = _("HTML 4.0 file format (*.html)");
file_format_register_save (".html", desc, html_write_wb_html40); file_format_register_save (".html", desc, html_write_wb_html40);
desc = _("HTML file made by gnumeric"); desc = _("HTML file made by gnumeric");
/* Q: what does the '100' mean? */ /* Register file format with priority 100 */
file_format_register_open (100, desc, NULL, html_read); file_format_register_open (100, desc, NULL, html_read);
desc = _("LaTeX file format (*.tex)"); desc = _("LaTeX file format (*.tex)");
......
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <errno.h>
#include <gnome.h> #include <gnome.h>
#include "config.h" #include "config.h"
#include "epsf.h" #include "epsf.h"
#include "ps.h" #include "ps.h"
#include "font.h" #include "font.h"
#include "command-context.h"
#define CELL_DIM(cell,p) \ #define CELL_DIM(cell,p) \
(cell->p->units + cell->p->margin_a_pt + cell->p->margin_b_pt) (cell->p->units + cell->p->margin_a_pt + cell->p->margin_b_pt)
...@@ -136,8 +138,10 @@ epsf_write_wb (CommandContext *context, Workbook *wb, const char *filename) ...@@ -136,8 +138,10 @@ epsf_write_wb (CommandContext *context, Workbook *wb, const char *filename)
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
sheet = wb->current_sheet; sheet = wb->current_sheet;
if (sheet) { if (sheet) {
......
...@@ -198,8 +198,10 @@ html_write_wb_html32 (CommandContext *context, Workbook *wb, ...@@ -198,8 +198,10 @@ html_write_wb_html32 (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 3.2/EN\">\n"); fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 3.2/EN\">\n");
fprintf (fp, "<HTML>\n"); fprintf (fp, "<HTML>\n");
...@@ -257,8 +259,10 @@ html_write_wb_html40 (CommandContext *context, Workbook *wb, ...@@ -257,8 +259,10 @@ html_write_wb_html40 (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 4.0/EN\">\n"); fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 4.0/EN\">\n");
fprintf (fp, "<HTML>\n"); fprintf (fp, "<HTML>\n");
......
...@@ -198,8 +198,10 @@ html_write_wb_html32 (CommandContext *context, Workbook *wb, ...@@ -198,8 +198,10 @@ html_write_wb_html32 (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 3.2/EN\">\n"); fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 3.2/EN\">\n");
fprintf (fp, "<HTML>\n"); fprintf (fp, "<HTML>\n");
...@@ -257,8 +259,10 @@ html_write_wb_html40 (CommandContext *context, Workbook *wb, ...@@ -257,8 +259,10 @@ html_write_wb_html40 (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 4.0/EN\">\n"); fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//W3C/DTD HTML 4.0/EN\">\n");
fprintf (fp, "<HTML>\n"); fprintf (fp, "<HTML>\n");
......
...@@ -19,10 +19,12 @@ ...@@ -19,10 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <errno.h>
#include <gnome.h> #include <gnome.h>
#include "config.h" #include "config.h"
#include "latex.h" #include "latex.h"
#include "font.h" #include "font.h"
#include "command-context.h"
/* /*
* escape special characters * escape special characters
...@@ -79,8 +81,10 @@ html_write_wb_latex (CommandContext *context, Workbook *wb, ...@@ -79,8 +81,10 @@ html_write_wb_latex (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "\\documentstyle[umlaut,a4]{article}\n"); fprintf (fp, "\\documentstyle[umlaut,a4]{article}\n");
fprintf (fp, "\\oddsidemargin -0.54cm\n\\textwidth 17cm\n"); fprintf (fp, "\\oddsidemargin -0.54cm\n\\textwidth 17cm\n");
...@@ -106,7 +110,9 @@ html_write_wb_latex (CommandContext *context, Workbook *wb, ...@@ -106,7 +110,9 @@ html_write_wb_latex (CommandContext *context, Workbook *wb,
fprintf (fp, "\t\n"); fprintf (fp, "\t\n");
} else { } else {
MStyle *mstyle = cell_get_mstyle (cell); MStyle *mstyle = cell_get_mstyle (cell);
g_return_val_if_fail (mstyle != NULL, 0);
if (!mstyle)
break;
if (col != 0) if (col != 0)
fprintf (fp, "\t&"); fprintf (fp, "\t&");
...@@ -169,8 +175,10 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb, ...@@ -169,8 +175,10 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
if (!fp) if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1; return -1;
}
fprintf (fp, "\\documentclass[11pt]{article}\n"); fprintf (fp, "\\documentclass[11pt]{article}\n");
fprintf (fp, "\t\\usepackage{umlaut}\n"); fprintf (fp, "\t\\usepackage{umlaut}\n");
...@@ -198,7 +206,8 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb, ...@@ -198,7 +206,8 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb,
fprintf (fp, "\t\n"); fprintf (fp, "\t\n");
} else { } else {
MStyle *mstyle = cell_get_mstyle (cell); MStyle *mstyle = cell_get_mstyle (cell);
g_return_val_if_fail (mstyle != NULL, 0); if (!mstyle)
break;
if (col != 0) if (col != 0)
fprintf (fp, "\t&"); fprintf (fp, "\t&");
else else
......
...@@ -19,10 +19,12 @@ ...@@ -19,10 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <errno.h>
#include <gnome.h> #include <gnome.h>
#include "config.h" #include "config.h"
#include "roff.h" #include "roff.h"
#include "font.h" #include "font.h"
#include "command-context.h"
/* /*
...@@ -64,7 +66,7 @@ roff_fprintf (FILE *fp, const char *s) ...@@ -64,7 +66,7 @@ roff_fprintf (FILE *fp, const char *s)
* write every sheet of the workbook to a roff file * write every sheet of the workbook to a roff file
*/ */
static int static int
write_wb_roff (Workbook *wb, FILE *fp) write_wb_roff (CommandContext *context, Workbook *wb, FILE *fp)
{ {
GList *sheet_list; GList *sheet_list;
Sheet *sheet; Sheet *sheet;
...@@ -95,6 +97,8 @@ write_wb_roff (Workbook *wb, FILE *fp) ...@@ -95,6 +97,8 @@ write_wb_roff (Workbook *wb, FILE *fp)
fprintf (fp, "l"); fprintf (fp, "l");
} else { } else {
MStyle *mstyle = cell_get_mstyle (cell); MStyle *mstyle = cell_get_mstyle (cell);
if (!mstyle)
break;
if (mstyle_get_align_h (mstyle) & HALIGN_RIGHT) if (mstyle_get_align_h (mstyle) & HALIGN_RIGHT)
fprintf (fp, "r"); fprintf (fp, "r");
else if (mstyle_get_align_h (mstyle) & HALIGN_CENTER) else if (mstyle_get_align_h (mstyle) & HALIGN_CENTER)
...@@ -177,12 +181,20 @@ html_write_wb_roff_ps (CommandContext *context, Workbook *wb, ...@@ -177,12 +181,20 @@ html_write_wb_roff_ps (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
cmd = g_malloc (strlen (filename) + 64); cmd = g_malloc (strlen (filename) + 64);
if (!cmd) if (!cmd)
return -1; return -1; /* Don't try to report this, we would
* have to allocate memory to do so */
sprintf (cmd, "groff -me -t -Tps - > %s", filename); sprintf (cmd, "groff -me -t -Tps - > %s", filename);
fp = popen (cmd, "w"); fp = popen (cmd, "w");
rc = write_wb_roff (wb, fp); if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
rc = -1;
goto out;
}
rc = write_wb_roff (context, wb, fp);
pclose (fp); pclose (fp);
out:
g_free (cmd); g_free (cmd);
return (rc); return (rc);
} }
...@@ -202,12 +214,20 @@ html_write_wb_roff_dvi (CommandContext *context, Workbook *wb, ...@@ -202,12 +214,20 @@ html_write_wb_roff_dvi (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
cmd = g_malloc (strlen (filename) + 64); cmd = g_malloc (strlen (filename) + 64);
if (!cmd) if (!cmd)
return -1; return -1; /* Don't try to report this, we would
* have to allocate memory to do so */
sprintf (cmd, "groff -me -t -Tdvi - > %s", filename); sprintf (cmd, "groff -me -t -Tdvi - > %s", filename);
fp = popen (cmd, "w"); fp = popen (cmd, "w");
rc = write_wb_roff (wb, fp); if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
rc = -1;
goto out;
}
rc = write_wb_roff (context, wb, fp);
pclose (fp); pclose (fp);
out:
g_free (cmd); g_free (cmd);
return (rc); return (rc);
} }
...@@ -227,15 +247,23 @@ html_write_wb_roff_pdf (CommandContext *context, Workbook *wb, ...@@ -227,15 +247,23 @@ html_write_wb_roff_pdf (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
cmd = g_malloc (strlen (filename) + 256); cmd = g_malloc (strlen (filename) + 256);
if (!cmd) if (!cmd)
return -1; return -1; /* Don't try to report this, we would
* have to allocate memory to do so */
sprintf (cmd, sprintf (cmd,
"groff -me -t -Tps - |" "groff -me -t -Tps - |"
"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%s" "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%s"
" -c save pop -f -", filename); " -c save pop -f -", filename);
fp = popen (cmd, "w"); fp = popen (cmd, "w");
rc = write_wb_roff (wb, fp); if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
rc = -1;
goto out;
}
rc = write_wb_roff (context, wb, fp);
pclose (fp); pclose (fp);
out:
g_free (cmd); g_free (cmd);
return (rc); return (rc);
} }
...@@ -254,7 +282,11 @@ html_write_wb_roff (CommandContext *context, Workbook *wb, ...@@ -254,7 +282,11 @@ html_write_wb_roff (CommandContext *context, Workbook *wb,
g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (filename != NULL, -1);
fp = fopen (filename, "w"); fp = fopen (filename, "w");
rc = write_wb_roff (wb, fp); if (!fp) {
gnumeric_error_save (context, g_strerror (errno));
return -1;
}
rc = write_wb_roff (context, wb, fp);
fclose (fp); fclose (fp);
return (rc); return (rc);
} }
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* lotus.c (read_workbook): Add CommandContext.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
* lotus.c (lotus_read): Add CommandContext. Return 0 on success, * lotus.c (lotus_read): Add CommandContext. Return 0 on success,
......
...@@ -149,7 +149,7 @@ attach_sheet (Workbook *wb, int idx) ...@@ -149,7 +149,7 @@ attach_sheet (Workbook *wb, int idx)
/* buf was old siag wb / sheet */ /* buf was old siag wb / sheet */
static int static int
read_workbook (Workbook *wb, FILE *f) read_workbook (CommandContext *context, Workbook *wb, FILE *f)
{ {
int sheetidx = 0; int sheetidx = 0;
Sheet *sheet = NULL; Sheet *sheet = NULL;
...@@ -272,7 +272,7 @@ lotus_read (CommandContext *context, Workbook *wb, const char *filename) ...@@ -272,7 +272,7 @@ lotus_read (CommandContext *context, Workbook *wb, const char *filename)
cell_deep_freeze_redraws (); cell_deep_freeze_redraws ();
res = read_workbook (wb, f); res = read_workbook (context, wb, f);
if (res == 0) { if (res == 0) {
workbook_recalc (wb); workbook_recalc (wb);
cell_deep_thaw_redraws (); cell_deep_thaw_redraws ();
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* oleo.c (oleo_read): Really return 0 on success.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
* oleo.c (oleo_read): Add CommandContext. Return 0 on success, * oleo.c (oleo_read): Add CommandContext. Return 0 on success,
......
...@@ -223,5 +223,5 @@ oleo_read (CommandContext *context, Workbook *wb, const char *filename) ...@@ -223,5 +223,5 @@ oleo_read (CommandContext *context, Workbook *wb, const char *filename)
} }
fclose (f); fclose (f);
return -1; return 0;
} }
...@@ -407,7 +407,6 @@ sc_read_workbook (CommandContext *context, Workbook *book, ...@@ -407,7 +407,6 @@ sc_read_workbook (CommandContext *context, Workbook *book,
g_return_val_if_fail (book, -1); g_return_val_if_fail (book, -1);
g_return_val_if_fail (filename, -1); g_return_val_if_fail (filename, -1);
g_return_val_if_fail (*filename, -1);
f = fopen (filename, "r"); f = fopen (filename, "r");
if (!f) { if (!f) {
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* text-io.c (text_write_workbook): Call gnumeric_error_save on
failure.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
* text-io.c (text_read_workbook, text_write_workbook, * text-io.c (text_read_workbook, text_write_workbook,
......
2000-01-31 Jon K Hellan <hellan@acm.org>
* boot.c: Call gnumeric_error_save on failure.
2000-01-29 Jon K Hellan <hellan@acm.org> 2000-01-29 Jon K Hellan <hellan@acm.org>
* xbase.h (xbase_open): Add CommandContext. * xbase.h (xbase_open): Add CommandContext.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment