Re: You can't select the importer to use when using ssconvert
- From: David J Craigon <david arabidopsis info>
- To: gnumeric list <gnumeric-list gnome org>
- Subject: Re: You can't select the importer to use when using ssconvert
- Date: Wed, 24 Nov 2004 14:47:18 +0000
Sorry to waste your time, but I don't think my previous patch worked.
This one does, however.
Again, apologies.
David
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.
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) !=
Thanks,
David
This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
--- gnumeric-1.3.93/src/ssconvert.c.old 2004-11-24 14:39:17.326727872 +0000
+++ gnumeric-1.3.93/src/ssconvert.c 2004-11-24 14:39:46.977220312 +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) !=
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]