Commit b4129181 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa
Browse files

Handle locale switching here. (xml_workbook_read): Handle locale switching

1999-08-09  Miguel de Icaza  <miguel@gnu.org>

	* src/xml-io.c (xml_workbook_write): Handle locale switching here.
	(xml_workbook_read): Handle locale switching here.

	* src/file.c: Removed all references to saving and re-setting the
	locale.  This should be handled in the xml-io code.

1999-08-10  Miguel de Icaza  <miguel@gnu.org>

	* src/workbook.c (workbook_do_destroy): remove g_free from the
	workbook.  We are now a GtkObject.

1999-08-09  Miguel de Icaza  <miguel@gnu.org>

	* src/xml-io.c (xml_workbook_write): Move the locale
	setting/resetting here, instead of putting it all over the place.

1999-08-09    <miguel@gnu.org>

	* src/xml-io.c (xml_workbook_read): Adjusted to use the new file
	open convention.

	* src/file.h: File open methods now take a workbook as an argument
	instead of creating it themselves.  Required for the
	GNOME::Persist bonobo interfaces.

	* src/file.c (workbook_read): Fix the workbook creation order to
	keep the locale correct if the file did not exist.
parent 299216aa
1999-08-09 Miguel de Icaza <miguel@gnu.org>
* src/xml-io.c (xml_workbook_write): Handle locale switching here.
(xml_workbook_read): Handle locale switching here.
* src/file.c: Removed all references to saving and re-setting the
locale. This should be handled in the xml-io code.
1999-08-10 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c (workbook_do_destroy): remove g_free from the
workbook. We are now a GtkObject.
1999-08-09 Miguel de Icaza <miguel@gnu.org>
* src/xml-io.c (xml_workbook_write): Move the locale
setting/resetting here, instead of putting it all over the place.
1999-08-09 <miguel@gnu.org>
* src/xml-io.c (xml_workbook_read): Adjusted to use the new file
open convention.
* src/file.h: File open methods now take a workbook as an argument
instead of creating it themselves. Required for the
GNOME::Persist bonobo interfaces.
* src/file.c (workbook_read): Fix the workbook creation order to
keep the locale correct if the file did not exist.
1999-08-10 Morten Welinder <terra@diku.dk>
* src/workbook.c (workbook_do_destroy): Don't free the workbook
......
1999-08-09 Miguel de Icaza <miguel@gnu.org>
* src/xml-io.c (xml_workbook_write): Handle locale switching here.
(xml_workbook_read): Handle locale switching here.
* src/file.c: Removed all references to saving and re-setting the
locale. This should be handled in the xml-io code.
1999-08-10 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c (workbook_do_destroy): remove g_free from the
workbook. We are now a GtkObject.
1999-08-09 Miguel de Icaza <miguel@gnu.org>
* src/xml-io.c (xml_workbook_write): Move the locale
setting/resetting here, instead of putting it all over the place.
1999-08-09 <miguel@gnu.org>
* src/xml-io.c (xml_workbook_read): Adjusted to use the new file
open convention.
* src/file.h: File open methods now take a workbook as an argument
instead of creating it themselves. Required for the
GNOME::Persist bonobo interfaces.
* src/file.c (workbook_read): Fix the workbook creation order to
keep the locale correct if the file did not exist.
1999-08-10 Morten Welinder <terra@diku.dk>
* src/workbook.c (workbook_do_destroy): Don't free the workbook
......
......@@ -102,6 +102,11 @@ main (int argc, char *argv[])
exit (1);
}
/*
* Show the workbook
*/
GNOME_Gnumeric_Workbook_show (workbook, 1, &ev);
do_test (workbook);
CORBA_exception_free (&ev);
......
1999-08-09 Miguel de Icaza <miguel@gnu.org>
* boot.c (excel_load): Changed calling conventions.
* ms-excel-read.c (ms_excel_read_workbook): Adjusted to use the
new file-open convention
1999-08-08 Michael Meeks <michael@imaginator.com>
* ole.c (dump_vba_module): Kill leak & fix logic.
......
......@@ -34,19 +34,19 @@ excel_probe (const char *filename)
return res;
}
static Workbook *
excel_load (const char *filename)
static gboolean
excel_load (Workbook *wb, const char *filename)
{
Workbook *wb;
MsOle *f;
gboolean ret;
f = ms_ole_open (filename);
if (!f)
return NULL;
return FALSE;
printf ("Opening '%s' ", filename);
wb = ms_excel_read_workbook (f);
if (wb) {
ret = ms_excel_read_workbook (wb, f);
if (ret) {
char *name = g_strconcat (filename, ".gnumeric", NULL);
ms_summary_read (f, wb->sin);
......@@ -59,7 +59,7 @@ excel_load (const char *filename)
ms_ole_destroy (f);
return wb;
return ret;
}
......
......@@ -17,9 +17,9 @@ typedef enum _eBiff_version { eBiffV2=2, eBiffV3=3,
eBiffV8=8, /* Excel 97 */
eBiffVUnknown=0} eBiff_version ;
extern Workbook *ms_excel_read_workbook (MsOle *file);
extern int ms_excel_write_workbook (MsOle *file, Workbook *wb,
eBiff_version ver);
extern gboolean ms_excel_read_workbook (Workbook *wb, MsOle *file);
extern int ms_excel_write_workbook (MsOle *file, Workbook *wb,
eBiff_version ver);
/* We need to use these for both read and write */
typedef struct {
......
......@@ -2632,8 +2632,8 @@ ms_excel_read_supporting_wb (BIFF_BOF_DATA *ver, BiffQuery *q)
#endif
}
Workbook *
ms_excel_read_workbook (MsOle *file)
gboolean
ms_excel_read_workbook (Workbook *workbook, MsOle *file)
{
ExcelWorkbook *wb = NULL;
MsOleStream *stream;
......@@ -2716,7 +2716,7 @@ ms_excel_read_workbook (MsOle *file)
if (ver->type == eBiffTWorkbook) {
wb = ms_excel_workbook_new (ver->version);
wb->gnum_wb = workbook_new ();
wb->gnum_wb = workbook;
if (ver->version >= eBiffV8) {
guint32 ver = MS_OLE_GET_GUINT32 (q->data + 4);
if (ver == 0x4107cd18)
......@@ -3062,10 +3062,9 @@ ms_excel_read_workbook (MsOle *file)
/* cell_deep_thaw_dependencies (); */
if (wb) {
Workbook *ans = wb->gnum_wb;
ms_excel_workbook_destroy (wb);
workbook_recalc (ans);
return ans;
workbook_recalc (wb->gnum_wb);
return TRUE;
}
return 0;
return FALSE;
}
......@@ -31,25 +31,20 @@ load_table_into_sheet (struct csv_table *table, Sheet *sheet)
}
}
static Workbook *
csv_read_workbook (const char* filename)
static gboolean
csv_read_workbook (Workbook *book, const char* filename)
{
struct csv_table table;
Workbook *book;
Sheet *sheet;
FILE *f;
char *name;
book = workbook_new ();
if (!book)
return NULL;
f = fopen (filename, "r");
if (f == NULL)
return NULL;
return FALSE;
if (csv_load_table (f, &table) == -1)
return NULL;
return FALSE;
fclose (f);
......@@ -64,7 +59,7 @@ csv_read_workbook (const char* filename)
csv_destroy_table (&table);
return book;
return TRUE;
}
......
......@@ -392,11 +392,10 @@ html_cell_italic (Cell *cell)
/*
* try at least to read back what we have written before..
*/
Workbook *
html_read (const char *filename)
gboolean
html_read (Workbook *wb, const char *filename)
{
FILE *fp;
Workbook *wb;
Sheet *sheet;
Cell *cell;
int num, row, col, flags;
......@@ -405,18 +404,14 @@ html_read (const char *filename)
char buf[LINESIZE];
if (!filename)
return NULL;
return FALSE;
wb = workbook_new();
if (!wb)
return NULL;
workbook_set_filename (wb, filename);
fp = fopen (filename, "r");
if (!fp) {
/* Q: how to free the "wb"? */
return NULL;
}
if (!fp)
return FALSE;
sheet = NULL;
col = 0;
row = -1;
......@@ -496,6 +491,6 @@ html_read (const char *filename)
}
}
fclose (fp);
return wb;
return TRUE;
}
......@@ -27,7 +27,7 @@
int html_write_wb_html32 (Workbook *wb, const char *filename);
int html_write_wb_html40 (Workbook *wb, const char *filename);
Workbook *html_read (const char *filename);
gboolean html_read (Workbook *wb, const char *filename);
#define G_PLUGIN_FOR_HTML "GPFH/0.5"
......
......@@ -392,11 +392,10 @@ html_cell_italic (Cell *cell)
/*
* try at least to read back what we have written before..
*/
Workbook *
html_read (const char *filename)
gboolean
html_read (Workbook *wb, const char *filename)
{
FILE *fp;
Workbook *wb;
Sheet *sheet;
Cell *cell;
int num, row, col, flags;
......@@ -405,18 +404,14 @@ html_read (const char *filename)
char buf[LINESIZE];
if (!filename)
return NULL;
return FALSE;
wb = workbook_new();
if (!wb)
return NULL;
workbook_set_filename (wb, filename);
fp = fopen (filename, "r");
if (!fp) {
/* Q: how to free the "wb"? */
return NULL;
}
if (!fp)
return FALSE;
sheet = NULL;
col = 0;
row = -1;
......@@ -496,6 +491,6 @@ html_read (const char *filename)
}
}
fclose (fp);
return wb;
return TRUE;
}
1999-08-09 <miguel@gnu.org>
* boot.c (lotus_cleanup_plugin): Change to new file open
conventions.
1999-08-02 Michael Meeks <michael@imaginator.com>
* Makefile.am: Remove redundant reference to boot.h
......
......@@ -51,15 +51,15 @@ lotus_probe (const char *filename)
}
static Workbook *
lotus_load (const char *filename)
static gboolean
lotus_load (Workbook *wb, const char *filename)
{
char *name, *p;
Workbook *wb;
gboolean ret;
wb = lotus_read (filename);
ret = lotus_read (filename);
if (wb) {
if (ret) {
if ((p = filename_ext (filename)) != NULL)
*p = '\0'; /* remove "wk1" */
name = g_strconcat (p, "gnumeric", NULL);
......@@ -67,7 +67,7 @@ lotus_load (const char *filename)
g_free (name);
}
return wb;
return ret;
}
static int
......
......@@ -9,4 +9,4 @@ double lotus_getdouble (const guint8 *p);
void lotus_setdouble (guint8 *p, double d);
#endif
Workbook *lotus_read (const char *filename);
gboolean lotus_read (Workbook *wb, const char *filename);
......@@ -288,10 +288,9 @@ text_parse_file (gchar *file, gint flen, gint start,
}
static Workbook *
readTextWorkbook (const char* filename, gboolean probe)
static gboolean
readTextWorkbook (Workbook *book, const char* filename, gboolean probe)
{
Workbook *book = NULL;
Sheet *sheet = NULL;
int fd;
struct stat buf;
......@@ -308,20 +307,20 @@ readTextWorkbook (const char* filename, gboolean probe)
gnumeric_notice (NULL, GNOME_MESSAGE_BOX_ERROR, msg);
g_free (msg);
return NULL;
return FALSE;
}
if (fstat (fd, &buf) == -1){
gnumeric_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
"Can not stat the file");
close(fd);
return NULL;
return FALSE;
}
/* FIXME: ARBITRARY VALUE */
if (buf.st_size < 1 || buf.st_size > 1000000){
close(fd);
return NULL;
return FALSE;
} else
flen = buf.st_size;
......@@ -330,13 +329,9 @@ readTextWorkbook (const char* filename, gboolean probe)
gnumeric_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
"Can not mmap the file");
close (fd);
return NULL;
return FALSE;
}
book = workbook_new ();
if (book == NULL)
return NULL;
idx = 0;
while (idx >= 0 && idx < flen){
sheet = sheet_new (book, _("NoName"));
......@@ -354,22 +349,22 @@ readTextWorkbook (const char* filename, gboolean probe)
munmap (file, flen);
close (fd);
return book;
return TRUE;
}
static Workbook *
text_read_workbook (const char* filename)
static gboolean
text_read_workbook (Workbook *wb, const char* filename)
{
Workbook *wb;
wb = readTextWorkbook (filename, FALSE);
if (wb != NULL){
gboolean ret;
ret = readTextWorkbook (wb, filename, FALSE);
if (ret){
workbook_set_filename (wb, filename);
workbook_set_title (wb, filename);
workbook_recalc_all (wb);
}
return wb;
return TRUE;
}
#if 0
......
1999-08-09 <miguel@gnu.org>
* boot.c (xbase_load): Adapted to new file open conventions.
1999-08-02 Elliot Lee <sopwith@redhat.com>
* Makefile.am: boot.h not needed.
......
......@@ -134,24 +134,22 @@ xbase_field_as_value (XBrecord *record, guint num)
}
}
static Workbook *
xbase_load (const char *filename)
static gboolean
xbase_load (Workbook *wb, const char *filename)
{
XBfile *file;
XBrecord *rec;
guint row, field;
char *name = g_strdup(filename), *p;
Workbook *wb = NULL;
Sheet *sheet = NULL;
Cell *cell;
Value *val;
if ((file = xbase_open (filename)) == NULL)
return NULL;
return FALSE
if ((p = filename_ext (name)) != NULL)
*p = '\0'; /* remove "dbf" */
rec = record_new (file);
wb = workbook_new ();
sheet = sheet_new (wb, name);
p = name;
name = g_strconcat (p, "gnumeric", NULL);
......@@ -186,7 +184,7 @@ xbase_load (const char *filename)
xbase_close (file);
return wb;
return TRUE;
}
static int
......
......@@ -236,6 +236,11 @@ module GNOME {
// Cell reference parsing
//
void parse (in string cellref, out Sheet sheet, out long col, out long row);
//
// Window control
//
void show (in boolean show_toplevel);
};
interface WorkbookFactory : GNOME::GenericFactory {
......
......@@ -725,7 +725,7 @@ Sheet_cell_set_alignment (PortableServer_Servant servant,
break;
}
return cell_set_alignment (cell, h, v, orientation, auto_return);
cell_set_alignment (cell, h, v, orientation, auto_return);
}
static void
......
......@@ -76,7 +76,6 @@ WorkbookFactory_create_object (PortableServer_Servant servant,
}
workbook = workbook_new ();
gtk_widget_show (workbook->toplevel);
return CORBA_Object_duplicate (workbook->corba_server, ev);
}
......
Supports Markdown
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