Beispiel #1
0
static void
gnm_stf_file_saver_save (G_GNUC_UNUSED GOFileSaver const *fs, GOIOContext *context,
			 GoView const *view, GsfOutput *output)
{
	WorkbookView *wbv = GNM_WORKBOOK_VIEW (view);
	Workbook *wb = wb_view_get_workbook (wbv);
	GnmStfExport *stfe = gnm_stf_get_stfe (G_OBJECT (wb));
	GsfOutput *dummy_sink;

	/* TODO: move this GUI dependent code out of this
	 * filesaver into gui-file.c. After this, remove includes (see above). */
	if (GNM_IS_WBC_GTK (context->impl)) {
		gboolean cancelled =
			stf_export_dialog (WBC_GTK (context->impl), stfe, wb);
		if (cancelled) {
			go_io_error_unknown (context);
			return;
		}
	}

	if (!stfe->sheet_list)
		gnm_stf_export_options_sheet_list_add
			(stfe, wb_view_cur_sheet (wbv));

	g_object_set (G_OBJECT (stfe), "sink", output, NULL);
	if (gnm_stf_export (stfe) == FALSE)
		go_cmd_context_error_import (GO_CMD_CONTEXT (context),
			_("Error while trying to export file as text"));

	/* We're not allowed to set a NULL sink, so use a dummy.  */
	dummy_sink = gsf_output_memory_new ();
	g_object_set (G_OBJECT (stfe), "sink", dummy_sink, NULL);
	g_object_unref (dummy_sink);
}
Beispiel #2
0
void
dif_file_open (GOFileOpener const *fo, GOIOContext *io_context,
               WorkbookView *wbv, GsfInput *input)
{
	Workbook *wb = wb_view_get_workbook (wbv);
	DifInputContext *ctxt = dif_input_context_new (io_context, wb, input);

	workbook_set_saveinfo (wb, GO_FILE_FL_MANUAL_REMEMBER,
		go_file_saver_for_id ("Gnumeric_dif:dif"));
	if (ctxt != NULL) {
		dif_parse_sheet (ctxt);
		if (go_io_error_occurred (io_context))
			go_io_error_push (io_context,
				go_error_info_new_str (_("Error while reading DIF file.")));
		dif_input_context_destroy (ctxt);
	} else if (!go_io_error_occurred (io_context))
		go_io_error_unknown (io_context);
}