GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

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

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);
}
......
......@@ -151,6 +151,17 @@ Workbook_parse (PortableServer_Servant servant,
{
}
static void
Workbook_show (PortableServer_Servant servant, CORBA_boolean show_toplevel, CORBA_Environment *ev)
{
Workbook *workbook = workbook_from_servant (servant);
if (show_toplevel)
gtk_widget_show (workbook->toplevel);
else
gtk_widget_hide (workbook->toplevel);
}
static void
Workbook_corba_class_init ()
{
......@@ -177,6 +188,7 @@ Workbook_corba_class_init ()
gnome_gnumeric_workbook_epv.recalc = Workbook_recalc;
gnome_gnumeric_workbook_epv.recalc_all = Workbook_recalc_all;
gnome_gnumeric_workbook_epv.parse = Workbook_parse;
gnome_gnumeric_workbook_epv.show = Workbook_show;
}
/**
......
......@@ -39,14 +39,15 @@ Grid_get_sheet (PortableServer_Servant servant, CORBA_Environment *ev)
return CORBA_Object_duplicate (eg->sheet->corba_server, ev);
}
static void
Grid_set_header_visibility (PortableServer_Servant servant,
const CORBA_boolean col_headers_visible,
const CORBA_boolean row_headers_visible,
CORBA_Environment *ev)
void
embeddable_grid_set_header_visibility (EmbeddableGrid *eg,
gboolean col_headers_visible,
gboolean row_headers_visible)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
GList *l;
g_return_if_fail (eg != NULL);
g_return_if_fail (IS_EMBEDDABLE_GRID (eg));
for (l = eg->views; l; l = l->next){
GridView *grid_view = GRID_VIEW (l->data);
......@@ -57,6 +58,18 @@ Grid_set_header_visibility (PortableServer_Servant servant,
row_headers_visible);
}
}
static void
Grid_set_header_visibility (PortableServer_Servant servant,
const CORBA_boolean col_headers_visible,
const CORBA_boolean row_headers_visible,
CORBA_Environment *ev)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
embeddable_grid_set_header_visibility (
eg, col_headers_visible, row_headers_visible);
}
static void
Grid_get_header_visibility (PortableServer_Servant servant,
......@@ -295,9 +308,10 @@ grid_view_new (EmbeddableGrid *eg)
}
grid_view->embeddable = eg;
grid_view->sheet_view = sheet_new_sheet_view (eg->sheet);
gtk_widget_show (grid_view->sheet_view);
gnome_view_construct (
GNOME_VIEW (grid_view), corba_grid_view, GTK_WIDGET (grid_view->sheet_view));
grid_view->sheet_view = sheet_new_sheet_view (eg->sheet);
eg->views = g_list_prepend (eg->views, grid_view);
......@@ -306,3 +320,16 @@ grid_view_new (EmbeddableGrid *eg)
return GNOME_VIEW (grid_view);
}
void
embeddable_grid_set_range (EmbeddableGrid *eg,
int start_col, int start_row,
int end_col, int end_row)
{
g_return_if_fail (eg != NULL);
g_return_if_fail (IS_EMBEDDABLE_GRID (eg));
g_return_if_fail (start_col <= end_col);
g_return_if_fail (start_row <= end_row);
}
......@@ -39,6 +39,13 @@ GtkType embeddable_grid_get_type (void);
EmbeddableGrid *embeddable_grid_new_anon (void);
EmbeddableGrid *embeddable_grid_new (Workbook *workbook, Sheet *sheet);
void EmbeddableGridFactory_init (void);
void embeddable_grid_set_range (EmbeddableGrid *eg,
int start_col, int start_row,
int end_col, int end_row);
void embeddable_grid_set_header_visibility (EmbeddableGrid *eg,
gboolean col_headers_visible,
gboolean row_headers_visible);
/*
* The GnomeView object
......
......@@ -136,27 +136,12 @@ file_format_unregister_save (FileFormatSave save)
}
}
Workbook *
workbook_read (const char *filename)
gboolean
workbook_load_from (Workbook *wb, const char *filename)
{
gboolean ret = FALSE;
GList *l;
char *oldlocale;
Workbook *w = NULL;
char *s;
g_return_val_if_fail (filename != NULL, NULL);
/* Files are expected to be in standard C format. */
oldlocale = g_strdup (setlocale (LC_NUMERIC, NULL));
setlocale (LC_NUMERIC, "C");
if (!g_file_exists (filename)){
w = workbook_new ();
workbook_set_filename (w, filename);
return w;
}
for (l = gnumeric_file_openers; l; l = l->next){
const FileOpener *fo = l->data;
......@@ -164,16 +149,37 @@ workbook_read (const char *filename)
continue;
if ((*fo->probe) (filename)){
w = (*fo->open) (filename);
if (w) {
workbook_mark_clean (w);
break;
}
if ((*fo->open) (wb, filename)){
workbook_mark_clean (wb);
ret = TRUE;
} else
ret = FALSE;
break;
}
}
return ret;
}
Workbook *
workbook_read (const char *filename)
{
Workbook *wb = NULL;
char *s;
g_return_val_if_fail (filename != NULL, NULL);
wb = workbook_new ();
if (!g_file_exists (filename)){
workbook_set_filename (wb, filename);
return wb;