- string_map_init (&options);
- string_map_insert (&options, "output-file", filename);
- if (filter == pdf_filter)
- {
- string_map_insert (&options, "output-type", "pdf");
- export_output (window, &options, "cairo");
- }
- else if (filter == html_filter)
- export_output (window, &options, "html");
- else if (filter == odt_filter)
- export_output (window, &options, "odf");
- else if (filter == txt_filter)
- {
- string_map_insert (&options, "headers", "false");
- string_map_insert (&options, "paginate", "false");
- string_map_insert (&options, "squeeze", "true");
- string_map_insert (&options, "emphasis", "none");
- string_map_insert (&options, "chart-type", "none");
- string_map_insert (&options, "top-margin", "0");
- string_map_insert (&options, "bottom-margin", "0");
- export_output (window, &options, "ascii");
- }
- else if (filter == ps_filter)
+ if (file_type == FT_AUTO)
+ {
+ /* If the "Infer file type from extension" option was chosen,
+ search for the respective type in the list.
+ (It's a O(n) search, but fortunately n is small). */
+ gint i;
+ for (i = 1 ; i < N_EXTENSIONS ; ++i)
+ {
+ if (g_str_has_suffix (filename, ft[i].ext))
+ {
+ file_type = i;
+ break;
+ }
+ }
+ }
+ else if (! g_str_has_suffix (filename, ft[file_type].ext))