2 * boot.c: Lotus 123 support for Gnumeric
6 * Michael Meeks <mmeeks@gnu.org>
7 * Morten Welinder (terra@gnome.org)
9 #include <gnumeric-config.h>
10 #include <glib/gi18n-lib.h>
13 #include "lotus-formula.h"
14 #include "lotus-types.h"
16 #include <goffice/goffice.h>
17 #include <workbook-view.h>
18 #include <gnm-plugin.h>
21 #include <gsf/gsf-input.h>
22 #include <gsf/gsf-utils.h>
24 GNM_PLUGIN_MODULE_HEADER
;
26 G_MODULE_EXPORT gboolean
lotus_file_probe (GOFileOpener
const *fo
, GsfInput
*input
,
28 G_MODULE_EXPORT
void lotus_file_open (GOFileOpener
const *fo
, GOIOContext
*io_context
,
29 WorkbookView
*wb_view
, GsfInput
*input
);
33 lotus_file_probe (GOFileOpener
const *fo
, GsfInput
*input
, GOFileProbeLevel pl
)
39 if (!gsf_input_seek (input
, 0, G_SEEK_SET
))
40 h
= gsf_input_read (input
, 6, NULL
);
43 (GSF_LE_GET_GUINT16 (h
+ 0) != LOTUS_BOF
&&
44 GSF_LE_GET_GUINT16 (h
+ 0) != WORKS_BOF
))
47 len
= GSF_LE_GET_GUINT16 (h
+ 2);
51 version
= GSF_LE_GET_GUINT16 (h
+ 4);
53 case LOTUS_VERSION_ORIG_123
:
54 case LOTUS_VERSION_SYMPHONY
:
55 case LOTUS_VERSION_SYMPHONY2
:
58 case LOTUS_VERSION_123V4
: /* Barely and crudely handled. */
59 case LOTUS_VERSION_123V6
:
60 case LOTUS_VERSION_123V7
:
61 case LOTUS_VERSION_123SS98
:
70 lotus_file_open (GOFileOpener
const *fo
, GOIOContext
*io_context
,
71 WorkbookView
*wb_view
, GsfInput
*input
)
76 state
.io_context
= io_context
;
78 state
.wb
= wb_view_get_workbook (wb_view
);
80 state
.sheet_area_error
= FALSE
;
81 state
.style_pool
= NULL
;
83 state
.works_conv
= (GIConv
)(-1);
85 if (!lotus_read (&state
))
86 go_io_error_string (io_context
,
87 _("Error while reading lotus workbook."));
90 g_hash_table_destroy (state
.style_pool
);
92 g_hash_table_destroy (state
.fonts
);
93 if (state
.works_conv
!= (GIConv
)(-1))
94 gsf_iconv_close (state
.works_conv
);
100 go_plugin_init (G_GNUC_UNUSED GOPlugin
*plugin
,
101 G_GNUC_UNUSED GOCmdContext
*cc
)
104 lotus_formula_init ();
108 go_plugin_shutdown (G_GNUC_UNUSED GOPlugin
*plugin
,
109 G_GNUC_UNUSED GOCmdContext
*cc
)
111 lotus_formula_shutdown ();