Commit 207743fd authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

DO NOT STORE CONTROL. The command context of the inititing action should


2002-10-02  Jody Goldberg <jody@gnome.org>

	* src/commands.c (cmd_reorganize_sheets) : DO NOT STORE CONTROL.
	  The command context of the inititing action should never be stored.
	  Undo should use the context from the control that initiated the
	  undo.

	* src/io-context-priv.h : Inherit from CommandContext and make our
	  lives easier.  Also avoid the pointless duplication.

	* src/command-context-priv.h : remove the plethora of err types in
	  favour of GError with a tag and ErrorInfo.
	  Protect cmd_context_progress_set, cmd_context_progress_message_set.
	* src/command-context-stderr.c : Adjust to the changes.

	* src/bonobo-io.c : IOContext inherits from CommandContext now use the
	  error handlers there.
	* src/plugin-util.c : ditto.
	* src/sheet-object-bonobo.c : ditto.
	* src/stf.c : ditto.
	* src/workbook-control-gui.c : ditto.
	* src/workbook-view.c : ditto.
	* src/xml-io.c : ditto.

2002-10-01  Jody Goldberg <jody@gnome.org>

	* src/pixmaps/Makefile.am : add the rest of the new artwork.

2002-10-01  Jody Goldberg <jody@gnome.org>

	* src/workbook.c (workbook_sheet_reorder) : take a workbook not a
	  control.

2002-10-01  Jody Goldberg <jody@gnome.org>

	* src/workbook-control-gui.c (cb_insert_hyperlink) : hook up the
	  hyperlink dialog.

	* src/sheet-control-gui.c (context_menu_handler) : adjust to new
	  calling convention for dialog_hyperlink.

2002-09-30  Jody Goldberg <jody@gnome.org>

	* src/application.c (gnumeric_application_setup_icons) : add the new
	  icons.
	* src/pixmaps/Makefile.am : add the new protection icons
parent e3dd36a6
2002-10-02 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_reorganize_sheets) : DO NOT STORE CONTROL.
The command context of the inititing action should never be stored.
Undo should use the context from the control that initiated the
undo.
* src/io-context-priv.h : Inherit from CommandContext and make our
lives easier. Also avoid the pointless duplication.
* src/command-context-priv.h : remove the plethora of err types in
favour of GError with a tag and ErrorInfo.
Protect cmd_context_progress_set, cmd_context_progress_message_set.
* src/command-context-stderr.c : Adjust to the changes.
* src/bonobo-io.c : IOContext inherits from CommandContext now use the
error handlers there.
* src/plugin-util.c : ditto.
* src/sheet-object-bonobo.c : ditto.
* src/stf.c : ditto.
* src/workbook-control-gui.c : ditto.
* src/workbook-view.c : ditto.
* src/xml-io.c : ditto.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/pixmaps/Makefile.am : add the rest of the new artwork.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook.c (workbook_sheet_reorder) : take a workbook not a
control.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_insert_hyperlink) : hook up the
......
......@@ -3,6 +3,7 @@ Gnumeric 1.1.10
Jody:
* Decrease GAL dependence.
* More work on opencalc importer.
* Start clean up of error handling routines.
--------------------------------------------------------------------------
Gnumeric 1.1.9
......
2002-10-02 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_reorganize_sheets) : DO NOT STORE CONTROL.
The command context of the inititing action should never be stored.
Undo should use the context from the control that initiated the
undo.
* src/io-context-priv.h : Inherit from CommandContext and make our
lives easier. Also avoid the pointless duplication.
* src/command-context-priv.h : remove the plethora of err types in
favour of GError with a tag and ErrorInfo.
Protect cmd_context_progress_set, cmd_context_progress_message_set.
* src/command-context-stderr.c : Adjust to the changes.
* src/bonobo-io.c : IOContext inherits from CommandContext now use the
error handlers there.
* src/plugin-util.c : ditto.
* src/sheet-object-bonobo.c : ditto.
* src/stf.c : ditto.
* src/workbook-control-gui.c : ditto.
* src/workbook-view.c : ditto.
* src/xml-io.c : ditto.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/pixmaps/Makefile.am : add the rest of the new artwork.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook.c (workbook_sheet_reorder) : take a workbook not a
control.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_insert_hyperlink) : hook up the
......
2002-10-02 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_reorganize_sheets) : DO NOT STORE CONTROL.
The command context of the inititing action should never be stored.
Undo should use the context from the control that initiated the
undo.
* src/io-context-priv.h : Inherit from CommandContext and make our
lives easier. Also avoid the pointless duplication.
* src/command-context-priv.h : remove the plethora of err types in
favour of GError with a tag and ErrorInfo.
Protect cmd_context_progress_set, cmd_context_progress_message_set.
* src/command-context-stderr.c : Adjust to the changes.
* src/bonobo-io.c : IOContext inherits from CommandContext now use the
error handlers there.
* src/plugin-util.c : ditto.
* src/sheet-object-bonobo.c : ditto.
* src/stf.c : ditto.
* src/workbook-control-gui.c : ditto.
* src/workbook-view.c : ditto.
* src/xml-io.c : ditto.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/pixmaps/Makefile.am : add the rest of the new artwork.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook.c (workbook_sheet_reorder) : take a workbook not a
control.
2002-10-01 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_insert_hyperlink) : hook up the
......
2002-10-02 Jody Goldberg <jody@gnome.org>
* corba-workbook.c : adjust to changes in CommandContext
2002-09-30 Jody Goldberg <jody@gnome.org>
* Release 1.1.9
......
......@@ -8,8 +8,8 @@ module GNOME {
exception ErrorSave { string msg; };
exception ErrorPlugin { string msg; };
exception ErrorInfo { string msg; };
exception ErrorInvalid { string msg; string value; };
exception ErrorSplitsArray { string msg; string range; };
exception ErrorInvalid { string msg; };
exception ErrorSplitsArray { string msg; };
interface Sheet {
attribute string name;
......
......@@ -144,75 +144,36 @@ cworkbook_sheets (PortableServer_Servant servant,
}
static void
wbcc_system (CommandContext *ctxt, char const *msg)
wbcc_error (CommandContext *ctxt, GError *gerr)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorSystem *err = GNOME_Gnumeric_ErrorSystem__alloc();
err->msg = CORBA_string_dup (msg);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSystem, err);
}
static void
wbcc_plugin (CommandContext *ctxt, char const *msg)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorPlugin *err = GNOME_Gnumeric_ErrorPlugin__alloc();
err->msg = CORBA_string_dup (msg);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorPlugin, err);
}
static void
wbcc_read (CommandContext *ctxt, char const *msg)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorRead *err = GNOME_Gnumeric_ErrorRead__alloc();
err->msg = CORBA_string_dup (msg);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorRead, err);
}
static void
wbcc_save (CommandContext *ctxt, char const *msg)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorSave *err = GNOME_Gnumeric_ErrorSave__alloc();
err->msg = CORBA_string_dup (msg);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSave, err);
}
static void
wbcc_splits_array (CommandContext *ctxt, char const *cmd, Range const *array)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorSplitsArray *err = GNOME_Gnumeric_ErrorSplitsArray__alloc();
err->msg = CORBA_string_dup (cmd);
err->range = CORBA_string_dup (range_name (array));
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSplitsArray, err);
}
static void
wbcc_invalid (CommandContext *ctxt, char const *msg, char const *val)
{
WorkbookControlCORBA *wbcc = WORKBOOK_CONTROL_CORBA (ctxt);
GNOME_Gnumeric_ErrorInvalid *err = GNOME_Gnumeric_ErrorInvalid__alloc();
err->msg = CORBA_string_dup (msg);
err->value = CORBA_string_dup (val);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorInvalid, err);
if (gerr->domain == gnm_error_system ()) {
GNOME_Gnumeric_ErrorSystem *err = GNOME_Gnumeric_ErrorSystem__alloc();
err->msg = CORBA_string_dup (gerr->message);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSystem, err);
} else if (gerr->domain == gnm_error_read ()) {
GNOME_Gnumeric_ErrorRead *err = GNOME_Gnumeric_ErrorRead__alloc();
err->msg = CORBA_string_dup (gerr->message);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorRead, err);
} else if (gerr->domain == gnm_error_write ()) {
GNOME_Gnumeric_ErrorSave *err = GNOME_Gnumeric_ErrorSave__alloc();
err->msg = CORBA_string_dup (gerr->message);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSave, err);
} else if (gerr->domain == gnm_error_array ()) {
GNOME_Gnumeric_ErrorSplitsArray *err = GNOME_Gnumeric_ErrorSplitsArray__alloc();
err->msg = CORBA_string_dup (gerr->message);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorSplitsArray, err);
} else if (gerr->domain == gnm_error_invalid ()) {
GNOME_Gnumeric_ErrorInvalid *err = GNOME_Gnumeric_ErrorInvalid__alloc();
err->msg = CORBA_string_dup (gerr->message);
CORBA_exception_set (wbcc->ev, CORBA_USER_EXCEPTION,
ex_GNOME_Gnumeric_ErrorInvalid, err);
}
}
static char *
......@@ -293,12 +254,7 @@ wbcc_class_init (GObjectClass *object_class)
g_return_if_fail (cc_class != NULL);
cc_class->get_password = wbcc_get_password;
cc_class->set_sensitive = wbcc_set_sensitive;
cc_class->error.system = wbcc_system;
cc_class->error.plugin = wbcc_plugin;
cc_class->error.read = wbcc_read;
cc_class->error.save = wbcc_save;
cc_class->error.splits_array = wbcc_splits_array;
cc_class->error.invalid = wbcc_invalid;
cc_class->error.error = wbcc_error;
wbc_class->sheet.add = wbcc_sheet_add;
wbc_class->sheet.remove = wbcc_sheet_remove;
......
2002-10-02 Jody Goldberg <jody@gnome.org>
* ms-chart.c (BC_R) : handle empty text.
* boot.c : simplify now that IOContext inherits from CommandContext
Move the metadata export here for symetry with the import.
2002-09-30 Jody Goldberg <jody@gnome.org>
* plugin.xml.in : disable 97 until it is ready for widespread use
......
......@@ -15,6 +15,7 @@
#include "file.h"
#include "libgnumeric.h"
#include "io-context.h"
#include "command-context.h"
#include "workbook-view.h"
#include "workbook.h"
#include "plugin-util.h"
......@@ -91,7 +92,7 @@ excel_file_probe (GnumFileOpener const *fo, GsfInput *input, FileProbeLevel pl)
}
static void
excel_read_metadata (GsfInfile *ole, char const *name, IOContext *context)
excel_read_metadata (GsfInfile *ole, char const *name, CommandContext *context)
{
GError *err = NULL;
GsfInput *stream = gsf_infile_child_by_name (ole, name);
......@@ -99,7 +100,7 @@ excel_read_metadata (GsfInfile *ole, char const *name, IOContext *context)
if (stream != NULL) {
gsf_msole_metadata_read (stream, &err);
if (err != NULL) {
gnumeric_io_error_read (context, err->message);
gnumeric_error_read (context, err->message);
g_error_free (err);
}
g_object_unref (G_OBJECT (stream));
......@@ -131,7 +132,8 @@ excel_file_open (GnumFileOpener const *fo, IOContext *context,
if (ole == NULL) {
g_return_if_fail (err != NULL);
gnumeric_io_error_read (context, err->message);
gnumeric_error_read (COMMAND_CONTEXT (context),
err->message);
g_error_free (err);
return;
}
......@@ -140,7 +142,7 @@ excel_file_open (GnumFileOpener const *fo, IOContext *context,
stream = gsf_infile_child_by_name (ole, content[i++]);
} while (stream == NULL && i < G_N_ELEMENTS (content));
if (stream == NULL) {
gnumeric_io_error_read (context,
gnumeric_error_read (COMMAND_CONTEXT (context),
_("No Workbook or Book streams found."));
g_object_unref (G_OBJECT (ole));
return;
......@@ -149,8 +151,8 @@ excel_file_open (GnumFileOpener const *fo, IOContext *context,
ms_excel_read_workbook (context, wbv, stream);
g_object_unref (G_OBJECT (stream));
excel_read_metadata (ole, "\05SummaryInformation", context);
excel_read_metadata (ole, "\05DocumentSummaryInformation", context);
excel_read_metadata (ole, "\05SummaryInformation", COMMAND_CONTEXT (context));
excel_read_metadata (ole, "\05DocumentSummaryInformation", COMMAND_CONTEXT (context));
/* See if there are any macros to keep around */
stream = gsf_infile_child_by_name (ole, "_VBA_PROJECT_CUR");
......@@ -176,7 +178,7 @@ excel_save (IOContext *context, WorkbookView *wbv, const char *filename,
MsBiffVersion ver)
{
Workbook *wb;
GsfOutput *output;
GsfOutput *output, *content;
GsfOutfile *outfile;
void *state = NULL;
GError *err;
......@@ -197,7 +199,7 @@ excel_save (IOContext *context, WorkbookView *wbv, const char *filename,
if (output == NULL) {
char *str = g_strdup_printf (_("Can't open '%s' : %s"),
filename, err->message);
gnumeric_io_error_save (context, str);
gnumeric_error_save (COMMAND_CONTEXT (context), str);
ms_excel_write_free_state (state);
g_error_free (err);
g_free (str);
......@@ -212,11 +214,17 @@ excel_save (IOContext *context, WorkbookView *wbv, const char *filename,
io_progress_range_pop (context);
wb = wb_view_workbook (wbv);
#warning re-enable when gsf meta data generator is ready
#if 0
Workbook *wb = wb_view_workbook (wbv);
ms_summary_write (f, wb->summary_info);
#endif
content = gsf_outfile_new_child (outfile,
"\05DocumentSummaryInformation", FALSE);
gsf_msole_metadata_write (content, TRUE, NULL);
gsf_output_close (content);
g_object_unref (G_OBJECT (content));
content = gsf_outfile_new_child (outfile,
"\05SummaryInformation", FALSE);
gsf_msole_metadata_write (content, FALSE, NULL);
gsf_output_close (content);
g_object_unref (G_OBJECT (content));
/* restore the macros we loaded */
macros = g_object_get_data (G_OBJECT (wb), "MS_EXCEL_MACROS");
......
......@@ -1806,6 +1806,9 @@ BC_R(seriestext)(ExcelChartHandler const *handle,
g_return_val_if_fail (id == 0, FALSE);
if (slen == 0)
return FALSE;
str = biff_get_text (q->data + 3, slen, NULL);
d (2, puts (str););
......
......@@ -43,6 +43,7 @@
#include <gutils.h>
#include <application.h>
#include <io-context.h>
#include <command-context.h>
#include <sheet-object-cell-comment.h>
#include <sheet-object-widget.h>
#include <sheet-object-graphic.h>
......@@ -4945,12 +4946,12 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
case BIFF_FILEPASS: /* All records after this are encrypted */
do {
char *passwd = gnm_io_get_password (context,
char *passwd = cmd_context_get_password (COMMAND_CONTEXT (context),
_("This file is encrypted"));
if (!ms_biff_query_set_decrypt (q, passwd))
problem_loading = _("Invalid password");
if (passwd == NULL)
break;
if (!ms_biff_query_set_decrypt (q, passwd))
problem_loading = _("Invalid password");
g_free (passwd);
if (problem_loading == NULL)
break;
......@@ -5068,11 +5069,12 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
/* If we were forced to stop then the load failed */
if (problem_loading != NULL)
gnumeric_io_error_read (context, problem_loading);
gnumeric_error_read (COMMAND_CONTEXT (context), problem_loading);
return;
}
gnumeric_io_error_read (context, _("Unable to locate valid MS Excel workbook"));
gnumeric_error_read (COMMAND_CONTEXT (context),
_("Unable to locate valid MS Excel workbook"));
}
......
......@@ -40,6 +40,7 @@
#include <workbook-view.h>
#include <workbook.h>
#include <io-context.h>
#include <command-context.h>
#include <expr.h>
#include <expr-impl.h>
#include <expr-name.h>
......@@ -3333,7 +3334,7 @@ excel_sheet_new (ExcelWorkbook *ewb, Sheet *gnum_sheet, IOContext *context)
char *msg = g_strdup_printf (
_("Too many rows for this format (%d > %d)"),
extent.end.col, maxrows);
gnumeric_io_error_save (context, msg);
gnumeric_error_save (COMMAND_CONTEXT (context), msg);
g_free (msg);
return NULL;
}
......@@ -3590,7 +3591,7 @@ ms_excel_write_workbook (IOContext *context, GsfOutfile *outfile, void *state,
((ver >= MS_BIFF_V8) ? "Workbook" : "Book"), FALSE);
if (content == NULL) {
free_workbook (wb);
gnumeric_io_error_save (context,
gnumeric_error_save (COMMAND_CONTEXT (context),
_("Couldn't open stream for writing\n"));
return;
}
......@@ -3602,18 +3603,6 @@ ms_excel_write_workbook (IOContext *context, GsfOutfile *outfile, void *state,
gsf_output_close (content);
g_object_unref (G_OBJECT (content));
content = gsf_outfile_new_child (outfile,
"\05DocumentSummaryInformation", FALSE);
gsf_msole_metadata_write (content, TRUE, NULL);
gsf_output_close (content);
g_object_unref (G_OBJECT (content));
content = gsf_outfile_new_child (outfile,
"\05SummaryInformation", FALSE);
gsf_msole_metadata_write (content, FALSE, NULL);
gsf_output_close (content);
g_object_unref (G_OBJECT (content));
d (0, fflush (stdout););
}
......
2002-10-02 Jody Goldberg <jody@gnome.org>
* openoffice-read.c : Ensure that the sheet ordering is correct.
2002-10-01 Jody Goldberg <jody@gnome.org>
* openoffice-read.c (oo_attr_enum) : new.
......
......@@ -31,11 +31,12 @@
#include <value.h>
#include <expr.h>
#include <parse-util.h>
#include <io-context.h>
#include <datetime.h>
#include <style-color.h>
#include <sheet-style.h>
#include <mstyle.h>
#include <command-context.h>
#include <io-context.h>
#include <gnumeric-i18n.h>
#include <gsf/gsf-libxml.h>
......@@ -61,6 +62,7 @@ typedef struct {
GHashTable *styles;
MStyle *style;
MStyle *col_default_styles[SHEET_MAX_COLS];
GSList *sheet_order;
} OOParseState;
static void oo_warning (OOParseState *state, char const *fmt, ...)
......@@ -222,10 +224,11 @@ oo_table_start (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
if (NULL == state->pos.sheet) {
state->pos.sheet = sheet_new (state->pos.wb, attrs[1]);
workbook_sheet_attach (state->pos.wb, state->pos.sheet, NULL);
puts (attrs[1]);
} else {
/* TODO : check the order */
}
/* store a list of the sheets in the correct order */
state->sheet_order = g_slist_prepend (state->sheet_order,
state->pos.sheet);
}
for (i = SHEET_MAX_COLS ; i-- > 0 ; )
state->col_default_styles[i] = NULL;
......@@ -292,7 +295,6 @@ oo_cellref_parse (CellRef *ref, char const *start, ParsePos const *pp)
*/
ref->sheet = workbook_sheet_by_name (pp->wb, name);
if (ref->sheet == NULL) {
printf ("--> %s\n", name);
ref->sheet = sheet_new (pp->wb, name);
workbook_sheet_attach (pp->wb, ref->sheet, NULL);
}
......@@ -649,14 +651,15 @@ openoffice_file_open (GnumFileOpener const *fo, IOContext *io_context,
zip = gsf_infile_zip_new (input, &err);
if (zip == NULL) {
g_return_if_fail (err != NULL);
gnumeric_io_error_read (io_context, err->message);
gnumeric_error_read (COMMAND_CONTEXT (io_context),
err->message);
g_error_free (err);
return;
}
content = gsf_infile_child_by_name (zip, "content.xml");
if (content == NULL) {
gnumeric_io_error_read (io_context,
gnumeric_error_read (COMMAND_CONTEXT (io_context),
_("No stream named content.xml found."));
g_object_unref (G_OBJECT (zip));
return;
......@@ -672,7 +675,8 @@ openoffice_file_open (GnumFileOpener const *fo, IOContext *io_context,
state.styles = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) mstyle_unref);
state.style = NULL;
state.style = NULL;
state.sheet_order = NULL;
state.base.root = opencalc_dtd;
if (!gsf_xmlSAX_parse (content, &state.base))
......@@ -680,6 +684,10 @@ openoffice_file_open (GnumFileOpener const *fo, IOContext *io_context,
else
workbook_queue_all_recalc (state.pos.wb);
state.sheet_order = g_slist_reverse (state.sheet_order);
workbook_sheet_reorder (state.pos.wb, state.sheet_order, NULL);
g_slist_free (state.sheet_order);
g_hash_table_destroy (state.styles);
g_object_unref (G_OBJECT (content));
g_object_unref (G_OBJECT (zip));
......
2002-10-01 Jody Goldberg <jody@gnome.org>
* xbase.c (xbase_close) : close the iconv handler.
(xbase_read_header) : set the iconv handler.
* boot.c (xbase_field_as_value) : map strings to utf8
2002-09-30 Jody Goldberg <jody@gnome.org>
* Release 1.1.9
......
......@@ -73,16 +73,19 @@ xb_setdouble (guint8 *p, double d)
#endif
static Value *
xbase_field_as_value (gchar *content, XBfield *field)
xbase_field_as_value (gchar *content, XBfield *field, XBfile *file)
{
gchar *s = g_strndup (content, field->len);
Value *val;
switch (field->type) {
case 'C':
val = value_new_string (g_strchomp (s));
case 'C': {
val = value_new_string_nocopy (
g_convert_with_iconv (g_strchomp (s), -1,
file->char_map, NULL, NULL, NULL));
g_free (s);
return val;
}
case 'N':
val = value_new_int (atoi (s));
g_free (s);
......@@ -190,7 +193,7 @@ xbase_file_open (GnumFileOpener const *fo, IOContext *io_context,
for (i = 0; i < file->fields ; i++) {
field = record->file->format [i];
val = xbase_field_as_value (
record_get_field (record, i), field);
record_get_field (record, i), field, file);
cell = sheet_cell_fetch (sheet, i, row);
value_set_fmt (val, field->fmt);
cell_set_value (cell, val);
......
......@@ -12,8 +12,14 @@
#include <stdio.h>
#include <gsf/gsf-input.h>
#include <gsf/gsf-utils.h>
#include <gsf/gsf-msole-utils.h>
#define XBASE_DEBUG 0
#if XBASE_DEBUG > 0
#define d(level, code) do { if (XBASE_DEBUG > level) { code } } while (0)
#else
#define d(level, code)
#endif
static char const * const field_types = "CNLDMF?BGPYTI";
......@@ -95,7 +101,40 @@ record_get_field (XBrecord const *record, guint num)
static gboolean
xbase_read_header (XBfile *x)
{
int cp;
static struct {
guint8 const id;
int const codepage;
char const *const name;
} const codepages [] = {
{ 0x01, 437, "U.S. MS-DOS" },
{ 0x69, 620, "Mazovia (Polish) MS-DOS" },
{ 0x6A, 737, "Greek MS-DOS (437G)" },
{ 0x02, 850, "International MS-DOS" },
{ 0x64, 852, "Eastern European MS-DOS" },
{ 0x6B, 857, "Turkish MS-DOS" },
{ 0x67, 861, "Icelandic MS-DOS" },
{ 0x66, 865, "Nordic MS-DOS" },
{ 0x65, 866, "Russian MS-DOS" },
{ 0x7C, 874, "Thai Windows" },
{ 0x68, 895, "Kamenicky (Czech) MS-DOS" },
{ 0x7B, 932, "Japanese Windows" },
{ 0x7A, 936, "Chinese (PRC, Singapore) Windows" },
{ 0x79, 949, "Korean Windows" },
{ 0x78, 950, "Chinese (Hong Kong SAR, Taiwan) Windows" },
{ 0xC8, 1250, "Eastern European Windows" },
{ 0xC9, 1251, "Russian Windows" },
{ 0x03, 1252, "Windows ANSI" },
{ 0xCB, 1253, "Greek Windows" },
{ 0xCA, 1254, "Turkish Windows" },
{ 0x7D, 1255, "Hebrew Windows" },
{ 0x7E, 1256, "Arabic Windows" },
{ 0x04, 10000, "Standard Macintosh" },
{ 0x98, 10006, "Greek Macintosh" },
{ 0x96, 10007, "Russian Macintosh" },
{ 0x97, 10029, "Macintosh EE" },
{ 0x00, 0, NULL }
};
int i;
guint8 hdr[32];
if (gsf_input_read (x->input, 32, hdr) == NULL) {
......@@ -132,91 +171,20 @@ xbase_read_header (XBfile *x)
fprintf (stderr, "Reserved (multi-user):\t%" G_GINT64_FORMAT "\n",
GSF_LE_GET_GUINT64(hdr + 20));
fprintf (stderr, "MDX flag:\t%d\n", hdr[28]); /* FIXME: decode */
fprintf (stderr, "Language driver (code page):\t");
switch (hdr[29]) {
case 0x01: cp = 437;
fprintf (stderr, "U.S. MS-DOS (%d)\n", cp);
break;
case 0x69: cp = 620;
fprintf (stderr, "Mazovia (Polish) MS-DOS (%d)\n", cp);
break;
case 0x6A: cp = 737;
fprintf (stderr, "Greek MS-DOS (437G) (%d)\n", cp);
break;
case 0x02: cp = 850;
fprintf (stderr, "International MS-DOS (%d)\n", cp);
break;
case 0x64: cp = 852;
fprintf (stderr, "Eastern European MS-DOS (%d)\n", cp);
break;
case 0x6B: cp = 857;
fprintf (stderr, "Turkish MS-DOS (%d)\n", cp);
break;
case 0x67: cp = 861;
fprintf (stderr, "Icelandic MS-DOS (%d)\n", cp);
break;
case 0x66: cp = 865;
fprintf (stderr, "Nordic MS-DOS (%d)\n", cp);
break;
case 0x65: cp = 866;
fprintf (stderr, "Russian MS-DOS (%d)\n", cp);
break;
case 0x7C: cp = 874;
fprintf (stderr, "Thai Windows (%d)\n", cp);
break;
case 0x68: cp = 895;
fprintf (stderr, "Kamenicky (Czech) MS-DOS (%d)\n", cp);
break;
case 0x7B: cp = 932;
fprintf (stderr, "Japanese Windows (%d)\n", cp);
break;
case 0x7A: cp = 936;
fprintf (stderr, "Chinese (PRC, Singapore) Windows (%d)\n", cp);
break;
case 0x79: cp = 949;
fprintf (stderr, "Korean Windows (%d)\n", cp);
break;
case 0x78: cp = 950;
fprintf (stderr, "Chinese (Hong Kong SAR, Taiwan) Windows (%d)\n", cp);
break;