Commit 3ab1a0fb authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Add links for Data -> Text To Columns Data -> Import External -> From File


2002-10-14  Jody Goldberg <jody@gnome.org>

	* src/workbook-control-gui.c : Add links for
	    Data -> Text To Columns
	    Data -> Import External -> From File
	Only partially implemented in the last hour, but these are just too
	easy to pass up.

	* src/stf.c (stf_store_results) : new, split out of.
	(stf_read_workbook) : here.
	(cb_get_content) : new utility.
	(stf_text_to_columns) : new.  Only partially done.
	  We still need a way to get the target region.

	* src/stf-parse.c (stf_parse_sheet) : take a starting offset for the
	  output, and return a boolean in place of the sheet that was passed in.

	* src/sheet.c (sheet_queue_respan) : new.

	* src/selection.c (selection_first_range) : start cleanup and take a
	  CommandContext rather than a Control.

	* src/gui-util.c (gnumeric_notice) : Cheat and access the private
	  label member to set it to accept markup.

	* src/commands.c (cmd_area_set_text_redo) : a nifty optimization.
	  Just redraw all and queue respanning for the effected regions.

	* src/GNOME_Gnumeric.xml : Add entries for Text to columns and
	  External Data -> Import from File
parent 7054f8de
2002-10-13 Jody Goldberg <jody@gnome.org>
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c : Add links for
Data -> Text To Columns
Data -> Import External -> From File
Only partially implemented in the last hour, but these are just too
easy to pass up.
* src/stf.c (stf_store_results) : new, split out of.
(stf_read_workbook) : here.
(cb_get_content) : new utility.
(stf_text_to_columns) : new. Only partially done.
We still need a way to get the target region.
* src/stf-parse.c (stf_parse_sheet) : take a starting offset for the
output, and return a boolean in place of the sheet that was passed in.
* src/sheet.c (sheet_queue_respan) : new.
* src/selection.c (selection_first_range) : start cleanup and take a
CommandContext rather than a Control.
* src/gui-util.c (gnumeric_notice) : Cheat and access the private
label member to set it to accept markup.
* src/commands.c (cmd_area_set_text_redo) : a nifty optimization.
Just redraw all and queue respanning for the effected regions.
* src/GNOME_Gnumeric.xml : Add entries for Text to columns and
External Data -> Import from File
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : only center if
we are in the top left, else do H or V only.
* src/sheet-view.c (sv_freeze_panes) : relax restrictions to allow for
H or V only freezing.
* src/gnumeric-pane.c (gnm_pane_init) : control configuration of col
and row headers seperately.
* src/sheet-control-gui.c (scg_resize) : support H or V only freezing.
(scg_set_panes) : ditto.
(sheet_control_gui_new) : adjust to the new gnm_pane_init interface.
(scg_set_left_col) : test for freezing distinctly from the existence
of pane 3.
(scg_set_top_row) : test for freezing distincly from the existence of
......
......@@ -44,6 +44,8 @@ Jody:
* Make format parsing utf8 clean
* Fix mishandling of empty strings in xls data validation importer
* Support Horizontal and Vertical only frozen panes
* Some optimizations for filling large regions
* Start work on 'Text from Columns' and 'External Data -> Text File'
Morten:
* Port search center from gal's e-table to gtk's treeview.
......
2002-10-13 Jody Goldberg <jody@gnome.org>
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c : Add links for
Data -> Text To Columns
Data -> Import External -> From File
Only partially implemented in the last hour, but these are just too
easy to pass up.
* src/stf.c (stf_store_results) : new, split out of.
(stf_read_workbook) : here.
(cb_get_content) : new utility.
(stf_text_to_columns) : new. Only partially done.
We still need a way to get the target region.
* src/stf-parse.c (stf_parse_sheet) : take a starting offset for the
output, and return a boolean in place of the sheet that was passed in.
* src/sheet.c (sheet_queue_respan) : new.
* src/selection.c (selection_first_range) : start cleanup and take a
CommandContext rather than a Control.
* src/gui-util.c (gnumeric_notice) : Cheat and access the private
label member to set it to accept markup.
* src/commands.c (cmd_area_set_text_redo) : a nifty optimization.
Just redraw all and queue respanning for the effected regions.
* src/GNOME_Gnumeric.xml : Add entries for Text to columns and
External Data -> Import from File
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : only center if
we are in the top left, else do H or V only.
* src/sheet-view.c (sv_freeze_panes) : relax restrictions to allow for
H or V only freezing.
* src/gnumeric-pane.c (gnm_pane_init) : control configuration of col
and row headers seperately.
* src/sheet-control-gui.c (scg_resize) : support H or V only freezing.
(scg_set_panes) : ditto.
(sheet_control_gui_new) : adjust to the new gnm_pane_init interface.
(scg_set_left_col) : test for freezing distinctly from the existence
of pane 3.
(scg_set_top_row) : test for freezing distincly from the existence of
......
2002-10-13 Jody Goldberg <jody@gnome.org>
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c : Add links for
Data -> Text To Columns
Data -> Import External -> From File
Only partially implemented in the last hour, but these are just too
easy to pass up.
* src/stf.c (stf_store_results) : new, split out of.
(stf_read_workbook) : here.
(cb_get_content) : new utility.
(stf_text_to_columns) : new. Only partially done.
We still need a way to get the target region.
* src/stf-parse.c (stf_parse_sheet) : take a starting offset for the
output, and return a boolean in place of the sheet that was passed in.
* src/sheet.c (sheet_queue_respan) : new.
* src/selection.c (selection_first_range) : start cleanup and take a
CommandContext rather than a Control.
* src/gui-util.c (gnumeric_notice) : Cheat and access the private
label member to set it to accept markup.
* src/commands.c (cmd_area_set_text_redo) : a nifty optimization.
Just redraw all and queue respanning for the effected regions.
* src/GNOME_Gnumeric.xml : Add entries for Text to columns and
External Data -> Import from File
2002-10-14 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : only center if
we are in the top left, else do H or V only.
* src/sheet-view.c (sv_freeze_panes) : relax restrictions to allow for
H or V only freezing.
* src/gnumeric-pane.c (gnm_pane_init) : control configuration of col
and row headers seperately.
* src/sheet-control-gui.c (scg_resize) : support H or V only freezing.
(scg_set_panes) : ditto.
(sheet_control_gui_new) : adjust to the new gnm_pane_init interface.
(scg_set_left_col) : test for freezing distinctly from the existence
of pane 3.
(scg_set_top_row) : test for freezing distincly from the existence of
......
......@@ -611,12 +611,16 @@
_label="_Validate..."
_tip="Validate input with preset criteria"/>
<separator/>
<menuitem name="DataTextToColumns" verb=""
_label="_Text to Columns..."
_tip="Parse the text in the selection into data"/>
<menuitem name="DataConsolidate" verb=""
_label="_Consolidate..."
_tip="Consolidate regions using a function"/>
<separator/>
<submenu name="Outline" _label="_Group and Outline">
<menuitem name="DataOutlineHideDetail" verb=""
......@@ -646,6 +650,14 @@
<menuitem name="SheetOutlineRight" verb=""/>
</submenu>
<submenu name="ExternalData" _label="Get _External Data">
<menuitem name="DataImportText" verb=""
pixtype="stock" pixname="gtk-dnd"
_label="Import _Text File..."
_tip="Import the text from a file"/>
</submenu>
</submenu>
<submenu name="Help" _label="_Help">
......
......@@ -340,7 +340,7 @@ cmd_paste_to_selection (WorkbookControl *wbc, SheetView *dest_sv, int paste_flag
Range const *r;
PasteTarget pt;
if (!(r = selection_first_range (dest_sv, wbc, _("Paste"))))
if (!(r = selection_first_range (dest_sv, COMMAND_CONTEXT (wbc), _("Paste"))))
return;
g_return_if_fail (r !=NULL);
......
......@@ -969,20 +969,10 @@ cmd_area_set_text_redo (GnumericCommand *cmd, WorkbookControl *wbc)
/* mark content as dirty */
sheet_flag_status_update_range (me->cmd.sheet, r);
sheet_queue_respan (me->cmd.sheet, r->start.row, r->end.row);
}
me->old_content = g_slist_reverse (me->old_content);
/*
* Now that things have been filled in and recalculated we can generate
* the spans. Non expression cells need to be rendered.
* TODO : We could be smarter here. Only the left and
* right columns can span,
* so there is no need to check the middles.
*/
for (l = me->selection ; l != NULL ; l = l->next) {
Range const * const r = l->data;
sheet_range_calc_spans (me->cmd.sheet, r, SPANCALC_RENDER);
}
sheet_redraw_all (me->cmd.sheet, FALSE);
return FALSE;
}
......
2002-10-14 Jody Goldberg <jody@gnome.org>
* dialog-stf-preview.c (stf_preview_format_line) : take advantage of
the fact that values in 1.1 store their parse formats so that we don't
loose dates.
2002-10-12 Jody Goldberg <jody@gnome.org>
* dialog-function-select.c (dialog_function_load_recent_funcs) : don't
......
......@@ -32,6 +32,7 @@
#include <ranges.h>
#include <cmd-edit.h>
#include <workbook-edit.h>
#include <command-context.h>
#include <glade/glade.h>
......@@ -127,7 +128,7 @@ dialog_delete_cells (WorkbookControlGUI *wbcg)
g_return_if_fail (wbcg != NULL);
if (!(sel = selection_first_range (sv, wbc, _("Delete"))))
if (!(sel = selection_first_range (sv, COMMAND_CONTEXT (wbc), _("Delete"))))
return;
cols = sel->end.col - sel->start.col + 1;
rows = sel->end.row - sel->start.row + 1;
......
......@@ -32,6 +32,7 @@
#include <ranges.h>
#include <cmd-edit.h>
#include <workbook-edit.h>
#include <command-context.h>
#include <glade/glade.h>
......@@ -127,7 +128,7 @@ dialog_insert_cells (WorkbookControlGUI *wbcg)
g_return_if_fail (wbcg != NULL);
if (!(sel = selection_first_range (sv, wbc, _("Insert"))))
if (!(sel = selection_first_range (sv, COMMAND_CONTEXT (wbc), _("Insert"))))
return;
cols = sel->end.col - sel->start.col + 1;
rows = sel->end.row - sel->start.row + 1;
......
......@@ -464,6 +464,9 @@ stf_preview_format_line (RenderData_t *renderdata, GList *data, int colcount)
if (NULL == (value = format_match (iterator->data, sf)))
value = value_new_string (iterator->data);
/* if the format is general honour the parse format */
if (style_format_is_general (sf))
sf = NULL;
celltext = format_value (sf, value, NULL, -1);
value_release (value);
......
......@@ -59,6 +59,7 @@ gnumeric_notice (WorkbookControlGUI *wbcg, GtkMessageType type, char const *str)
dialog = gtk_message_dialog_new (wbcg == NULL ? NULL : wbcg_toplevel (wbcg),
GTK_DIALOG_DESTROY_WITH_PARENT, type,
GTK_BUTTONS_OK, str);
gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
gnumeric_dialog_run (wbcg, GTK_DIALOG (dialog));
}
......
......@@ -17,6 +17,7 @@
#include "selection.h"
#include "workbook.h"
#include "workbook-control.h"
#include "command-context.h"
#include "dialogs.h"
#include "gnumeric-gconf.h"
#include "libgnumeric.h"
......@@ -971,7 +972,7 @@ sheet_print_selection (PrintJobInfo *pj, Sheet const *sheet,
Range extent;
if (!(sel = selection_first_range (sheet_get_view (sheet, wb_control_view (wbc)),
wbc, _("Print Region"))))
COMMAND_CONTEXT (wbc), _("Print Region"))))
return;
extent = *sel;
......
......@@ -330,7 +330,7 @@ sv_menu_enable_insert (SheetView *sv, gboolean col, gboolean row)
*/
Range const *
selection_first_range (SheetView const *sv,
WorkbookControl *wbc, char const *cmd_name)
CommandContext *cc, char const *cmd_name)
{
Range const *r;
GList *l;
......@@ -341,8 +341,8 @@ selection_first_range (SheetView const *sv,
g_return_val_if_fail (l != NULL && l->data != NULL, NULL);
r = l->data;
if (wbc != NULL && l->next != NULL) {
gnumeric_error_invalid (COMMAND_CONTEXT (wbc), cmd_name,
if (cc != NULL && l->next != NULL) {
gnumeric_error_invalid (cc, cmd_name,
_("cannot be performed with multiple ranges selected"));
return NULL;
}
......
......@@ -24,7 +24,7 @@ ColRowSelectionType sheet_row_selection_type (SheetView const *sv, int row);
char *selection_to_string (SheetView *sv,
gboolean include_sheet_name_prefix);
Range const *selection_first_range (SheetView const *sv,
WorkbookControl *wbc, char const *cmd_name);
CommandContext *cc, char const *cmd_name);
GSList *selection_get_ranges (SheetView const *sv,
gboolean allow_intersection);
......
......@@ -37,6 +37,7 @@
#include "value.h"
#include "parse-util.h"
#include "expr-name.h"
#include "command-context.h"
#include <gsf/gsf-impl-utils.h>
......@@ -303,7 +304,7 @@ sv_selection_copy (SheetView *sv, WorkbookControl *wbc)
{
Range const *sel;
if (!(sel = selection_first_range (sv, wbc, _("Copy"))))
if (!(sel = selection_first_range (sv, COMMAND_CONTEXT (wbc), _("Copy"))))
return FALSE;
application_clipboard_cut_copy (wbc, FALSE, sv, sel, TRUE);
......@@ -328,7 +329,7 @@ sv_selection_cut (SheetView *sv, WorkbookControl *wbc)
*/
g_return_val_if_fail (IS_SHEET_VIEW (sv), FALSE);
if (!(sel = selection_first_range (sv, wbc, _("Cut"))))
if (!(sel = selection_first_range (sv, COMMAND_CONTEXT (wbc), _("Cut"))))
return FALSE;
if (sheet_range_splits_region (sv_sheet (sv), sel, NULL, wbc, _("Cut")))
......@@ -686,5 +687,4 @@ sv_set_initial_top_left (SheetView *sv, int col, int row)
sv->initial_top_left.col = col;
sv->initial_top_left.row = row;
printf ("initial = %s\n", cellpos_as_string (&sv->initial_top_left));
}
......@@ -1273,10 +1273,10 @@ sheet_range_set_text (ParsePos const *pos, Range const *r, char const *str)
merged = sheet_merge_get_overlap (pos->sheet, r);
for (ptr = merged ; ptr != NULL ; ptr = ptr->next) {
Range const *r = ptr->data;
Range const *tmp = ptr->data;
sheet_foreach_cell_in_range (pos->sheet, CELL_ITER_ALL,
r->start.col, r->start.row, r->end.col, r->end.row,
(CellIterFunc)&cb_clear_non_corner, (gpointer)r);
tmp->start.col, tmp->start.row, tmp->end.col, tmp->end.row,
(CellIterFunc)&cb_clear_non_corner, (gpointer)tmp);
}
g_slist_free (merged);
......@@ -4085,3 +4085,26 @@ sheet_get_view (Sheet const *sheet, WorkbookView const *wbv)
});
return NULL;
}
static gboolean
cb_queue_respan (ColRowInfo *info, void *user_data)
{
info->needs_respan = TRUE;
return FALSE;
}
/**
* sheet_queue_respan *
* @sheet :
* @start_row :
* @end_row :
*
* queues a span generation for the selected rows.
* the caller is responsible for queuing a redraw
**/
void
sheet_queue_respan (Sheet const *sheet, int start_row, int end_row)
{
colrow_foreach (&sheet->rows, start_row, end_row,
cb_queue_respan, NULL);
}
......@@ -246,6 +246,7 @@ Value const *sheet_cell_get_value (Sheet *sheet, int const col, int const row);
void sheet_range_set_text (ParsePos const *pos, Range const *r, char const *str);
void sheet_apply_style (Sheet *sheet, Range const *range, MStyle *mstyle);
void sheet_calc_spans (Sheet const *sheet, SpanCalcFlags flags);
void sheet_queue_respan (Sheet const *sheet, int start_row, int end_row);
void sheet_range_calc_spans (Sheet *sheet, Range const *r, SpanCalcFlags flags);
void sheet_cell_calc_span (Cell *cell, SpanCalcFlags flags);
void sheet_regen_adjacent_spans (Sheet *sheet,
......
......@@ -1169,23 +1169,24 @@ stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions, int const
* functions into something meaningful (== application specific)
*******************************************************************************************************/
Sheet *
stf_parse_sheet (StfParseOptions_t *parseoptions, char const *data, Sheet *sheet)
gboolean
stf_parse_sheet (StfParseOptions_t *parseoptions, char const *data, Sheet *sheet,
int start_col, int start_row)
{
GList *res, *l;
int row;
g_return_val_if_fail (parseoptions != NULL, NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (parseoptions != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (IS_SHEET (sheet), FALSE);
res = stf_parse_general (parseoptions, data);
for (row = 0, l = res; l != NULL; l = l->next, row++) {
for (row = start_row, l = res; l != NULL; l = l->next, row++) {
GList *mres = l->data;
GList *m;
int col;
for (col = 0, m = mres; m != NULL; m = m->next, col++) {
for (col = start_col, m = mres; m != NULL; m = m->next, col++) {
char *text = m->data;
if (text) {
......@@ -1210,7 +1211,7 @@ stf_parse_sheet (StfParseOptions_t *parseoptions, char const *data, Sheet *sheet
}
g_list_free (res);
return sheet;
return TRUE;
}
CellRegion *
......
......@@ -94,8 +94,9 @@ void stf_parse_options_fixed_autodiscover (StfParseO
int const data_lines, char const *data);
/* Higher level functions, can be used for directly parsing into an application specific data container */
Sheet *stf_parse_sheet (StfParseOptions_t *parseoptions,
char const *data, Sheet *sheet);
gboolean stf_parse_sheet (StfParseOptions_t *parseoptions,
char const *data, Sheet *sheet,
int start_col, int start_row);
CellRegion *stf_parse_region (StfParseOptions_t *parseoptions,
char const *data);
......
......@@ -39,11 +39,19 @@
#include "workbook.h"
#include "dialog-stf.h"
#include "dialog-stf-export.h"
#include "position.h"
#include "expr.h"
#include "value.h"
#include "format.h"
#include "selection.h"
#include "ranges.h"
#include <gsf/gsf-input.h>
#include <ctype.h>
#include <string.h>
#include <glade/glade.h>
#include <gsf/gsf-output.h>
#include <gsf/gsf-output-memory.h>
/**
* stf_open_and_read
......@@ -119,6 +127,41 @@ stf_preparse (CommandContext *context, GsfInput *input)
return data;
}
static gboolean
stf_store_results (DialogStfResult_t *dialogresult,
Sheet *sheet, int start_col, int start_row)
{
GSList *iterator;
int col, rowcount;
stf_parse_options_set_lines_to_parse (dialogresult->parseoptions, dialogresult->lines);
iterator = dialogresult->formats;
col = start_col;
rowcount = stf_parse_get_rowcount (dialogresult->parseoptions, dialogresult->newstart);
while (iterator) {
Range range;
MStyle *style = mstyle_new ();
mstyle_set_format (style, iterator->data);
range.start.col = col;
range.start.row = start_row;
range.end.col = col;
range.end.row = rowcount;
sheet_style_apply_range (sheet, &range, style);
iterator = g_slist_next (iterator);
col++;
}
return stf_parse_sheet (dialogresult->parseoptions,
dialogresult->newstart, sheet,
start_col, start_row);
}
/**
* stf_read_workbook
* @fo : file opener
......@@ -137,58 +180,23 @@ stf_read_workbook (GnumFileOpener const *fo, IOContext *context, WorkbookView *w
Sheet *sheet;
Workbook *book;
book = wb_view_workbook (wbv);
data = stf_preparse (COMMAND_CONTEXT (context), input);
if (!data)
return;
/* FIXME : how to do this cleanly ? */
if (!IS_WORKBOOK_CONTROL_GUI (context->impl))
return;
/* Add Sheet */
name = g_path_get_basename (gsf_input_name (input));
book = wb_view_workbook (wbv);
sheet = sheet_new (book, name);
workbook_sheet_attach (book, sheet, NULL);
g_free (name);
/* FIXME : how to do this cleanly ? */
if (IS_WORKBOOK_CONTROL_GUI (context->impl))
dialogresult = stf_dialog (WORKBOOK_CONTROL_GUI (context->impl), name, data);
if (dialogresult != NULL) {
GSList *iterator;
int col, rowcount;
stf_parse_options_set_lines_to_parse (dialogresult->parseoptions, dialogresult->lines);
iterator = dialogresult->formats;
col = 0;
rowcount = stf_parse_get_rowcount (dialogresult->parseoptions, dialogresult->newstart);
while (iterator) {
Range range;
MStyle *style = mstyle_new ();
mstyle_set_format (style, iterator->data);
range.start.col = col;
range.start.row = 0;
range.end.col = col;
range.end.row = rowcount;
sheet_style_apply_range (sheet, &range, style);
iterator = g_slist_next (iterator);
col++;
}
if (!stf_parse_sheet (dialogresult->parseoptions, dialogresult->newstart, sheet)) {
workbook_sheet_detach (book, sheet);
g_free (data);
gnumeric_error_read (COMMAND_CONTEXT (context),
_("Parse error while trying to parse data into sheet"));
return;
}
dialogresult = stf_dialog (WORKBOOK_CONTROL_GUI (context->impl), name, data);
if (dialogresult != NULL && stf_store_results (dialogresult, sheet, 0, 0)) {
workbook_recalc (book);
sheet_calc_spans (sheet, SPANCALC_RENDER);
workbook_set_saveinfo (book, name, FILE_FL_MANUAL, NULL);
......@@ -196,12 +204,98 @@ stf_read_workbook (GnumFileOpener const *fo, IOContext *context, WorkbookView *w
workbook_sheet_detach (book, sheet);
g_free (data);
g_free (name);
if (dialogresult != NULL)
stf_dialog_result_free (dialogresult);
}
static Value *
cb_get_content (Sheet *sheet, int col, int row,
Cell *cell, GsfOutput *buf)
{
char *tmp;
if (cell_has_expr (cell)) {
ParsePos pp;
tmp = gnm_expr_as_string (cell->base.expression,
parse_pos_init_cell (&pp, cell));
} else if (VALUE_FMT (cell->value) != NULL)
tmp = format_value (NULL, cell->value, NULL, -1);
else
gnumeric_error_read (COMMAND_CONTEXT (context), _("Unknown error while importing"));
tmp = value_get_as_string (cell->value);
gsf_output_write (buf, strlen (tmp), tmp);
gsf_output_write (buf, 1, "\n");
g_free (tmp);
return NULL;
}
/**
* stf_text_to_columns
* @wbc : The control making the request
*
* Main routine, handles importing a file including all dialog mumbo-jumbo
**/
void
stf_text_to_columns (WorkbookControl *wbc, CommandContext *cc)
{
DialogStfResult_t *dialogresult = NULL;
SheetView *sv;
Sheet *src_sheet, *target_sheet;
Range const *src;
Range target;
GsfOutput *buf;
guint8 *data;
gsf_off_t len;
sv = wb_control_cur_sheet_view (wbc);
src_sheet = sv_sheet (sv);
src = selection_first_range (sv, cc, _("Text to Columns"));
if (src == NULL)
return;
if (range_width (src) > 1) {
cmd_context_error (cc, g_error_new (gnm_error_invalid (), 0,
_("Only 1 one column of <b>input</b> data can be parsed at a time, not %d"),
range_width (src)));
return;
}
/* FIXME : how to do this cleanly ? */
if (!IS_WORKBOOK_CONTROL_GUI (wbc))
return;
#warning Add UI for this
target_sheet = src_sheet;
target = *src;
range_translate (&target, 1, 0);
buf = gsf_output_memory_new ();
sheet_foreach_cell_in_range (src_sheet,
CELL_ITER_IGNORE_BLANK | CELL_ITER_IGNORE_HIDDEN,
src->start.col, src->start.row,
src->end.col, src->end.row,
(CellIterFunc) &cb_get_content, buf);
gsf_output_write (buf, 1, "\0");
gsf_output_close (buf);
gsf_output_memory_get_bytes (GSF_OUTPUT_MEMORY (buf), &data, &len);
dialogresult = stf_dialog (WORKBOOK_CONTROL_GUI (wbc),
_("Text to Columns"), data);
if (dialogresult == NULL ||
!stf_store_results (dialogresult, target_sheet,
target.start.col, target.start.row)) {
gnumeric_error_read (COMMAND_CONTEXT (cc),
_("Error while trying to parse data into sheet"));
} else {
sheet_flag_status_update_range (target_sheet, &target);
sheet_queue_respan (target_sheet, target.start.row, target.end.row);
workbook_recalc (target_sheet->workbook);
sheet_redraw_all (target_sheet, FALSE);
}
g_object_unref (G_OBJECT (buf));
if (dialogresult != NULL)
stf_dialog_result_free (dialogresult);
}
#define STF_PROBE_SIZE 16384
......@@ -261,7 +355,7 @@ stf_read_workbook_auto_csvtab (GnumFileOpener const *fo, IOContext *context,
if (tab >= lines && tab > comma)
stf_parse_options_csv_set_separators (po, "\t", NULL);
if (!stf_parse_sheet (po, data, sheet)) {
if (!stf_parse_sheet (po, data, sheet, 0, 0)) {
workbook_sheet_detach (book, sheet);
g_free (data);
......
#ifndef GNUMERIC_STF_H
#define GNUMERIC_STF_H
#include <gnumeric.h>
void stf_init (void);
void stf_text_to_columns (WorkbookControl *wbc, CommandContext *cc);
#endif /* GNUMERIC_STF_H */
......@@ -72,6 +72,7 @@
#include "gnumeric-gconf.h"
#include "filter.h"
#include "io-context.h"
#include "stf.h"