Re: You can't select the importer to use when using ssconvert
- From: Jody Goldberg <jody gnome org>
- To: David J Craigon <david arabidopsis info>
- Cc: gnumeric list <gnumeric-list gnome org>
- Subject: Re: You can't select the importer to use when using ssconvert
- Date: Wed, 24 Nov 2004 10:24:30 -0500
On Wed, Nov 24, 2004 at 02:47:18PM +0000, David J Craigon wrote:
David J Craigon wrote:
Hello everybody,
At the moment (1.3.93) you can select the exporter for use with
ssconvert, but you can't select the importer. This is a bit of a shame,
since I want to use the SAX reader for Gnumeric files, since my files
are too big to use with DOM. I think you should be able to tell
ssconvert which importer to use.
I like the idea of the patch. Before reviewing it I should point
out a few things
- The sax importer is not quite finished (even in 1.4). You
will lose sheet objects (lines, graphs, comments). Although
that's not an issue for ssconvert.
- if you do not mind losing the objects you can make the sax
importer the default by changing it's precedence in the
plugin.xml file
So here's a patch that does that. Please note, this is my first ever
Gnome patch, let alone Gnumeric, so please check it carefully! If you
could put this functionality in any other way, that would be great too.
diff -Naur gnumeric-1.3.93/src/ssconvert.c ohno/src/ssconvert.c
--- gnumeric-1.3.93/src/ssconvert.c 2004-11-23 18:35:23.216981704 +0000
+++ ohno/src/ssconvert.c 2004-11-23 13:10:27.000000000 +0000
@@ -28,6 +28,7 @@
static gboolean ssconvert_list_importers = FALSE;
static gboolean ssconvert_one_file_per_sheet = FALSE;
static char const *ssconvert_import_encoding = NULL;
+static char const *ssconvert_import_id = NULL;
static char const *ssconvert_export_id = NULL;
#ifdef WIN32
@@ -47,6 +48,8 @@
{ "import-encoding", 'E', POPT_ARG_STRING,
&ssconvert_import_encoding, 0,
N_("Optionally specify an encoding for imported content"),
N_("ENCODING") },
+ { "import-type", 'I', POPT_ARG_STRING, &ssconvert_import_id, 0,
+ N_("Optionally specify which importer to use"), "ID" },
{ "export-type", 'T', POPT_ARG_STRING, &ssconvert_export_id, 0,
N_("Optionally specify which exporter to use"), "ID" },
{ "list-exporters", '\0', POPT_ARG_NONE, &ssconvert_list_exporters, 0,
@@ -96,6 +99,7 @@
{
int res = 0;
GnmFileSaver *fs = NULL;
+ GnmFileOpener *fo = NULL;
char *outfile = go_shell_arg_to_uri (args[1]);
if (ssconvert_export_id != NULL) {
@@ -135,11 +139,21 @@
if (outfile == NULL)
fprintf (stderr, _("An output file name or an explicit export
type is required.\n"
"Try --list-exporters to see a list of possibilities.\n"));
+
+ if (ssconvert_import_id != NULL) {
+ fo = gnm_file_opener_for_id (ssconvert_import_id);
+ if (fo == NULL) {
+ res = 1;
+ fprintf (stderr, _("Unknown importer '%s'.\n"
+ "Try --list-importers to see a list of
possibilities.\n"),
+ ssconvert_import_id);
+ }
+ }
if (fs != NULL) {
IOContext *io_context = gnumeric_io_context_new (cc);
char *uri = go_shell_arg_to_uri (args[0]);
- WorkbookView *wbv = wb_view_new_from_uri (uri, NULL,
+ WorkbookView *wbv = wb_view_new_from_uri (uri, fo,
io_context, ssconvert_import_encoding);
g_free (uri);
if (gnm_file_saver_get_save_scope (fs) !=
Nice work for your first patch. We're frozen for 1.4.0 to be
released, but we should put it in for 1.4.1. Please open a bugzilla
report and attach the patch.
Thanks
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]