Commit fc1912f7 authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Burn. (stf_cache_options_free): Burn. (stf_cache_options_set_data): Burn.

2001-06-03  Almer S. Tigelaar  <almer@gnome.org>

	* src/stf-parse.[ch] (stf_cache_options_new): Burn.
	(stf_cache_options_free): Burn.
	(stf_cache_options_set_data): Burn.
	(stf_cache_options_set_range): Burn.
	(stf_cache_options_invalidate): Burn.
	(stf_parse_general_cached): Burn.
	(stf_parse_options_before_modification): Burn.
	(stf_parse_options_after_modification): Burn.
	(stf_parse_options_set_type): Don't set modified.
	(stf_parse_options_set_line_terminator): Idem.
	(stf_parse_options_set_lines_to_parse): Idem.
	(stf_parse_options_set_trim_spaces): Idem.
	(stf_parse_options_csv_set_separators): Idem.
	(stf_parse_options_csv_set_customfieldseparator): Idem.
	(stf_parse_options_csv_set_stringindicator): Idem.
	(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
	(stf_parse_options_csv_set_duplicates): Idem.
	(stf_parse_options_valid): Remove modificationmode.
	(stf_parse_options_new): Idem.
	(trim_spaces_inplace): Make inline.
	(stf_parse_csv_is_separator): Idem and move things around
	a for some more speed.
	(stf_parse_csv_cell): Make inline.
	(stf_parse_fixed_cell): Idem.

	* src/stf.c (stf_read_workbook): Set maximum number of
	lines to parse to infinite.
	(x_selection_to_cell_region): Idem.

2001-06-03  Almer S. Tigelaar  <almer@gnome.org>

	* dialog-stf.c (stf_dialog_druid_page_next): Remove cacheoptions.

	* dialog-stf-preview.c (stf_preview_merge_with_hash): Remove.
	(stf_preview_hash_item_remove): Idem.
	(stf_preview_free_row): Idem.
	(stf_preview_free): Remove hashtable.
	(stf_preview_new): Idem.
	(stf_preview_render): Free the list that is passed.
	(stf_preview_render_row): Truncate strings if they are too long.

	* dialog-stf-csv-page.c (csv_page_global_change): Use
	stf_parse_general.
	(stf_dialog_csv_page_prepare): Remove cacheoptions.
	(stf_dialog_csv_page_init): Idem.
	(stf_dialog_csv_page_cleanup): Idem.

	* dialog-stf-fixed-page.c (fixed_page_update_preview): Use
	stf_parse_general.
	(stf_dialog_fixed_page_prepare): Remove cacheoptions.
	(stf_dialog_fixed_page_cleanup): Idem.
	(stf_dialog_fixed_page_init): Idem.

	* dialog-stf-format-page.c (format_page_update_preview): Use
	stf_parse_general.
	(format_page_scroll_value_changed ): Don't use cacheoptions.
	(format_page_format_changed): Idem.
	(stf_dialog_format_page_prepare): Idem.
	(stf_dialog_format_page_cleanup): Remove cacheoptions.
	(stf_dialog_format_page_init): Idem.
parent 2877e18f
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.[ch] (stf_cache_options_new): Burn.
(stf_cache_options_free): Burn.
(stf_cache_options_set_data): Burn.
(stf_cache_options_set_range): Burn.
(stf_cache_options_invalidate): Burn.
(stf_parse_general_cached): Burn.
(stf_parse_options_before_modification): Burn.
(stf_parse_options_after_modification): Burn.
(stf_parse_options_set_type): Don't set modified.
(stf_parse_options_set_line_terminator): Idem.
(stf_parse_options_set_lines_to_parse): Idem.
(stf_parse_options_set_trim_spaces): Idem.
(stf_parse_options_csv_set_separators): Idem.
(stf_parse_options_csv_set_customfieldseparator): Idem.
(stf_parse_options_csv_set_stringindicator): Idem.
(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
(stf_parse_options_csv_set_duplicates): Idem.
(stf_parse_options_valid): Remove modificationmode.
(stf_parse_options_new): Idem.
(trim_spaces_inplace): Make inline.
(stf_parse_csv_is_separator): Idem and move things around
a for some more speed.
(stf_parse_csv_cell): Make inline.
(stf_parse_fixed_cell): Idem.
* src/stf.c (stf_read_workbook): Set maximum number of
lines to parse to infinite.
(x_selection_to_cell_region): Idem.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/format.c (format_value) : ref the colour.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.[ch] (stf_cache_options_new): Burn.
(stf_cache_options_free): Burn.
(stf_cache_options_set_data): Burn.
(stf_cache_options_set_range): Burn.
(stf_cache_options_invalidate): Burn.
(stf_parse_general_cached): Burn.
(stf_parse_options_before_modification): Burn.
(stf_parse_options_after_modification): Burn.
(stf_parse_options_set_type): Don't set modified.
(stf_parse_options_set_line_terminator): Idem.
(stf_parse_options_set_lines_to_parse): Idem.
(stf_parse_options_set_trim_spaces): Idem.
(stf_parse_options_csv_set_separators): Idem.
(stf_parse_options_csv_set_customfieldseparator): Idem.
(stf_parse_options_csv_set_stringindicator): Idem.
(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
(stf_parse_options_csv_set_duplicates): Idem.
(stf_parse_options_valid): Remove modificationmode.
(stf_parse_options_new): Idem.
(trim_spaces_inplace): Make inline.
(stf_parse_csv_is_separator): Idem and move things around
a for some more speed.
(stf_parse_csv_cell): Make inline.
(stf_parse_fixed_cell): Idem.
* src/stf.c (stf_read_workbook): Set maximum number of
lines to parse to infinite.
(x_selection_to_cell_region): Idem.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/format.c (format_value) : ref the colour.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.[ch] (stf_cache_options_new): Burn.
(stf_cache_options_free): Burn.
(stf_cache_options_set_data): Burn.
(stf_cache_options_set_range): Burn.
(stf_cache_options_invalidate): Burn.
(stf_parse_general_cached): Burn.
(stf_parse_options_before_modification): Burn.
(stf_parse_options_after_modification): Burn.
(stf_parse_options_set_type): Don't set modified.
(stf_parse_options_set_line_terminator): Idem.
(stf_parse_options_set_lines_to_parse): Idem.
(stf_parse_options_set_trim_spaces): Idem.
(stf_parse_options_csv_set_separators): Idem.
(stf_parse_options_csv_set_customfieldseparator): Idem.
(stf_parse_options_csv_set_stringindicator): Idem.
(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
(stf_parse_options_csv_set_duplicates): Idem.
(stf_parse_options_valid): Remove modificationmode.
(stf_parse_options_new): Idem.
(trim_spaces_inplace): Make inline.
(stf_parse_csv_is_separator): Idem and move things around
a for some more speed.
(stf_parse_csv_cell): Make inline.
(stf_parse_fixed_cell): Idem.
* src/stf.c (stf_read_workbook): Set maximum number of
lines to parse to infinite.
(x_selection_to_cell_region): Idem.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/format.c (format_value) : ref the colour.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.[ch] (stf_cache_options_new): Burn.
(stf_cache_options_free): Burn.
(stf_cache_options_set_data): Burn.
(stf_cache_options_set_range): Burn.
(stf_cache_options_invalidate): Burn.
(stf_parse_general_cached): Burn.
(stf_parse_options_before_modification): Burn.
(stf_parse_options_after_modification): Burn.
(stf_parse_options_set_type): Don't set modified.
(stf_parse_options_set_line_terminator): Idem.
(stf_parse_options_set_lines_to_parse): Idem.
(stf_parse_options_set_trim_spaces): Idem.
(stf_parse_options_csv_set_separators): Idem.
(stf_parse_options_csv_set_customfieldseparator): Idem.
(stf_parse_options_csv_set_stringindicator): Idem.
(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
(stf_parse_options_csv_set_duplicates): Idem.
(stf_parse_options_valid): Remove modificationmode.
(stf_parse_options_new): Idem.
(trim_spaces_inplace): Make inline.
(stf_parse_csv_is_separator): Idem and move things around
a for some more speed.
(stf_parse_csv_cell): Make inline.
(stf_parse_fixed_cell): Idem.
* src/stf.c (stf_read_workbook): Set maximum number of
lines to parse to infinite.
(x_selection_to_cell_region): Idem.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/format.c (format_value) : ref the colour.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.[ch] (stf_cache_options_new): Burn.
(stf_cache_options_free): Burn.
(stf_cache_options_set_data): Burn.
(stf_cache_options_set_range): Burn.
(stf_cache_options_invalidate): Burn.
(stf_parse_general_cached): Burn.
(stf_parse_options_before_modification): Burn.
(stf_parse_options_after_modification): Burn.
(stf_parse_options_set_type): Don't set modified.
(stf_parse_options_set_line_terminator): Idem.
(stf_parse_options_set_lines_to_parse): Idem.
(stf_parse_options_set_trim_spaces): Idem.
(stf_parse_options_csv_set_separators): Idem.
(stf_parse_options_csv_set_customfieldseparator): Idem.
(stf_parse_options_csv_set_stringindicator): Idem.
(stf_parse_options_csv_set_indicator_2x_is_single): Idem.
(stf_parse_options_csv_set_duplicates): Idem.
(stf_parse_options_valid): Remove modificationmode.
(stf_parse_options_new): Idem.
(trim_spaces_inplace): Make inline.
(stf_parse_csv_is_separator): Idem and move things around
a for some more speed.
(stf_parse_csv_cell): Make inline.
(stf_parse_fixed_cell): Idem.
* src/stf.c (stf_read_workbook): Set maximum number of
lines to parse to infinite.
(x_selection_to_cell_region): Idem.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/format.c (format_value) : ref the colour.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* dialog-stf.c (stf_dialog_druid_page_next): Remove cacheoptions.
* dialog-stf-preview.c (stf_preview_merge_with_hash): Remove.
(stf_preview_hash_item_remove): Idem.
(stf_preview_free_row): Idem.
(stf_preview_free): Remove hashtable.
(stf_preview_new): Idem.
(stf_preview_render): Free the list that is passed.
(stf_preview_render_row): Truncate strings if they are too long.
* dialog-stf-csv-page.c (csv_page_global_change): Use
stf_parse_general.
(stf_dialog_csv_page_prepare): Remove cacheoptions.
(stf_dialog_csv_page_init): Idem.
(stf_dialog_csv_page_cleanup): Idem.
* dialog-stf-fixed-page.c (fixed_page_update_preview): Use
stf_parse_general.
(stf_dialog_fixed_page_prepare): Remove cacheoptions.
(stf_dialog_fixed_page_cleanup): Idem.
(stf_dialog_fixed_page_init): Idem.
* dialog-stf-format-page.c (format_page_update_preview): Use
stf_parse_general.
(format_page_scroll_value_changed ): Don't use cacheoptions.
(format_page_format_changed): Idem.
(stf_dialog_format_page_prepare): Idem.
(stf_dialog_format_page_cleanup): Remove cacheoptions.
(stf_dialog_format_page_init): Idem.
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* colrow.glade: New simple dialog.
......
/*
* dialog-stf.c : Controls the widget on the CSV (Comma Separated Value) page of the druid
*
* Almer. S. Tigelaar <almer1@dds.nl>
* Copyright (C) Almer S. Tigelaar <almer@gnome.org>
*
*/
......@@ -34,8 +34,7 @@ csv_page_global_change (GtkWidget *widget, DruidPageData_t *data)
GSList *list;
char *textfieldtext;
gboolean customvalid = FALSE;
stf_parse_options_before_modification (parseoptions);
int i;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->csv_custom))) {
char *csvcustomtext = gtk_editable_get_chars (GTK_EDITABLE (info->csv_customseparator), 0, -1);
......@@ -70,29 +69,14 @@ csv_page_global_change (GtkWidget *widget, DruidPageData_t *data)
stf_parse_options_csv_set_duplicates (parseoptions,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->csv_duplicates)));
/* Check if we actually changed something and invalidate the cache if necessary */
if (stf_parse_options_after_modification (parseoptions)) {
int i;
data->colcount = stf_parse_get_colcount (parseoptions, data->cur);
data->colcount = stf_parse_get_colcount (parseoptions, data->cur);
stf_preview_colwidths_clear (info->csv_run_renderdata);
for (i = 0; i < data->colcount + 1; i++)
stf_preview_colwidths_add (info->csv_run_renderdata, stf_parse_get_colwidth (parseoptions, data->cur, i));
stf_cache_options_invalidate (info->csv_run_cacheoptions);
stf_preview_colwidths_clear (info->csv_run_renderdata);
for (i = 0; i < data->colcount + 1; i++)
stf_preview_colwidths_add (info->csv_run_renderdata, stf_parse_get_colwidth (parseoptions, data->cur, i));
}
list = stf_parse_general (parseoptions, data->cur);
/* actually do the parsing and rendering */
stf_cache_options_set_range (info->csv_run_cacheoptions,
info->csv_run_renderdata->startrow - 1,
(info->csv_run_renderdata->startrow - 1) + info->csv_run_displayrows);
list = stf_parse_general_cached (parseoptions,
info->csv_run_cacheoptions);
stf_preview_render (info->csv_run_renderdata,
list,
stf_preview_render (info->csv_run_renderdata, list,
info->csv_run_displayrows,
data->colcount);
}
......@@ -165,18 +149,7 @@ stf_dialog_csv_page_prepare (GnomeDruidPage *page, GnomeDruid *druid, DruidPageD
{
CsvInfo_t *info = pagedata->csv_info;
if (pagedata->cur != info->csv_run_cacheoptions->data ||
pagedata->importlines != info->csv_run_parseoptions->parselines)
{
stf_parse_options_set_lines_to_parse (info->csv_run_parseoptions, pagedata->importlines);
stf_cache_options_set_data (info->csv_run_cacheoptions, info->csv_run_parseoptions, pagedata->cur);
}
stf_parse_options_set_trim_spaces (info->csv_run_parseoptions, pagedata->trim);
stf_cache_options_invalidate (info->csv_run_cacheoptions);
pagedata->colcount = stf_parse_get_colcount (info->csv_run_parseoptions, pagedata->cur);
/*
......@@ -186,10 +159,13 @@ stf_dialog_csv_page_prepare (GnomeDruidPage *page, GnomeDruid *druid, DruidPageD
{
int rowcount = stf_parse_get_rowcount (info->csv_run_parseoptions, pagedata->cur) + 1;
if (rowcount > LINE_DISPLAY_LIMIT)
if (rowcount > LINE_DISPLAY_LIMIT) {
GTK_RANGE (info->csv_scroll)->adjustment->upper = LINE_DISPLAY_LIMIT;
else
stf_parse_options_set_lines_to_parse (info->csv_run_parseoptions, LINE_DISPLAY_LIMIT);
} else {
GTK_RANGE (info->csv_scroll)->adjustment->upper = rowcount;
stf_parse_options_set_lines_to_parse (info->csv_run_parseoptions, pagedata->importlines);
}
}
gtk_adjustment_changed (GTK_RANGE (info->csv_scroll)->adjustment);
......@@ -212,9 +188,6 @@ stf_dialog_csv_page_cleanup (DruidPageData_t *pagedata)
{
CsvInfo_t *info = pagedata->csv_info;
stf_cache_options_free (info->csv_run_cacheoptions);
info->csv_run_cacheoptions = NULL;
if (info->csv_run_parseoptions) {
stf_parse_options_free (info->csv_run_parseoptions);
info->csv_run_parseoptions = NULL;
......@@ -269,11 +242,9 @@ stf_dialog_csv_page_init (GladeXML *gui, DruidPageData_t *pagedata)
/* Set properties */
info->csv_run_renderdata = stf_preview_new (info->csv_canvas, FALSE);
info->csv_run_parseoptions = stf_parse_options_new ();
info->csv_run_cacheoptions = stf_cache_options_new ();
info->csv_run_displayrows = stf_preview_get_displayed_rowcount (info->csv_run_renderdata);
stf_parse_options_set_type (info->csv_run_parseoptions, PARSE_TYPE_CSV);
stf_cache_options_set_data (info->csv_run_cacheoptions, info->csv_run_parseoptions, pagedata->cur);
/* Connect signals */
gtk_signal_connect (GTK_OBJECT (info->csv_tab),
......
/*
* dialog-stf.c : Controls the widgets on the fixed page of the dialog (fixed-width page that is)
*
* Almer. S. Tigelaar <almer1@dds.nl>
* Copyright (C) Almer S. Tigelaar <almer@gnome.org>
*
*/
......@@ -85,8 +85,6 @@ fixed_page_update_preview (DruidPageData_t *pagedata)
char *t[2];
int i, temp;
stf_parse_options_before_modification (parseoptions);
stf_parse_options_fixed_splitpositions_clear (parseoptions);
for (i = 0; i < info->fixed_collist->rows; i++) {
gtk_clist_get_text (info->fixed_collist, i, 1, t);
......@@ -94,26 +92,15 @@ fixed_page_update_preview (DruidPageData_t *pagedata)
stf_parse_options_fixed_splitpositions_add (parseoptions, temp);
}
if (stf_parse_options_after_modification (parseoptions)) {
stf_cache_options_invalidate (info->fixed_run_cacheoptions);
pagedata->colcount = stf_parse_get_colcount (parseoptions, pagedata->cur);
pagedata->colcount = stf_parse_get_colcount (parseoptions, pagedata->cur);
stf_preview_colwidths_clear (info->fixed_run_renderdata);
for (i = 0; i < pagedata->colcount + 1; i++)
stf_preview_colwidths_add (info->fixed_run_renderdata, stf_parse_get_colwidth (parseoptions, pagedata->cur, i));
}
stf_preview_colwidths_clear (info->fixed_run_renderdata);
for (i = 0; i < pagedata->colcount + 1; i++)
stf_preview_colwidths_add (info->fixed_run_renderdata, stf_parse_get_colwidth (parseoptions, pagedata->cur, i));
stf_cache_options_set_range (info->fixed_run_cacheoptions,
info->fixed_run_renderdata->startrow - 1,
(info->fixed_run_renderdata->startrow - 1) + info->fixed_run_displayrows);
list = stf_parse_general (parseoptions, pagedata->cur);
list = stf_parse_general_cached (parseoptions,
info->fixed_run_cacheoptions);
stf_preview_render (info->fixed_run_renderdata,
list,
stf_preview_render (info->fixed_run_renderdata, list,
info->fixed_run_displayrows,
pagedata->colcount);
}
......@@ -538,18 +525,7 @@ stf_dialog_fixed_page_prepare (GnomeDruidPage *page, GnomeDruid *druid, DruidPag
FixedInfo_t *info = pagedata->fixed_info;
GtkAdjustment *spinadjust;
if (pagedata->cur != info->fixed_run_cacheoptions->data ||
pagedata->importlines != info->fixed_run_parseoptions->parselines)
{
stf_parse_options_set_lines_to_parse (info->fixed_run_parseoptions, pagedata->importlines);
stf_cache_options_set_data (info->fixed_run_cacheoptions, info->fixed_run_parseoptions, pagedata->cur);
}
stf_parse_options_set_trim_spaces (info->fixed_run_parseoptions, TRIM_TYPE_NEVER);
stf_cache_options_invalidate (info->fixed_run_cacheoptions);
pagedata->colcount = stf_parse_get_colcount (info->fixed_run_parseoptions, pagedata->cur);
/*
......@@ -559,10 +535,13 @@ stf_dialog_fixed_page_prepare (GnomeDruidPage *page, GnomeDruid *druid, DruidPag
{
int rowcount = stf_parse_get_rowcount (info->fixed_run_parseoptions, pagedata->cur) + 1;
if (rowcount > LINE_DISPLAY_LIMIT)
if (rowcount > LINE_DISPLAY_LIMIT) {
GTK_RANGE (info->fixed_scroll)->adjustment->upper = LINE_DISPLAY_LIMIT;
else
stf_parse_options_set_lines_to_parse (info->fixed_run_parseoptions, LINE_DISPLAY_LIMIT);
} else {
GTK_RANGE (info->fixed_scroll)->adjustment->upper = rowcount;
stf_parse_options_set_lines_to_parse (info->fixed_run_parseoptions, pagedata->importlines);
}
}
gtk_adjustment_changed (GTK_RANGE (info->fixed_scroll)->adjustment);
......@@ -595,9 +574,6 @@ stf_dialog_fixed_page_cleanup (DruidPageData_t *pagedata)
stf_parse_options_free (info->fixed_run_parseoptions);
info->fixed_run_parseoptions = NULL;
}
stf_cache_options_free (info->fixed_run_cacheoptions);
info->fixed_run_cacheoptions = NULL;
}
/**
......@@ -635,7 +611,6 @@ stf_dialog_fixed_page_init (GladeXML *gui, DruidPageData_t *pagedata)
/* Set properties */
info->fixed_run_renderdata = stf_preview_new (info->fixed_canvas, FALSE);
info->fixed_run_parseoptions = stf_parse_options_new ();
info->fixed_run_cacheoptions = stf_cache_options_new ();
info->fixed_run_manual = FALSE;
info->fixed_run_index = -1;
info->fixed_run_displayrows = stf_preview_get_displayed_rowcount (info->fixed_run_renderdata);
......@@ -643,7 +618,6 @@ stf_dialog_fixed_page_init (GladeXML *gui, DruidPageData_t *pagedata)
info->fixed_run_xorigin = 0;
stf_parse_options_set_type (info->fixed_run_parseoptions, PARSE_TYPE_FIXED);
stf_cache_options_set_data (info->fixed_run_cacheoptions, info->fixed_run_parseoptions, pagedata->cur);
gtk_clist_column_titles_passive (info->fixed_collist);
......
/*
* dialog-stf.c : Controls the widgets on the format page of the dialog
*
* Almer. S. Tigelaar <almer1@dds.nl>
* Copyright (C) Almer S. Tigelaar <almer@gnome.org>
*
*/
......@@ -36,11 +36,9 @@ format_page_update_preview (DruidPageData_t *pagedata)
iterator = g_slist_next (iterator);
}
list = stf_parse_general_cached (info->format_run_parseoptions,
info->format_run_cacheoptions);
list = stf_parse_general (info->format_run_parseoptions, pagedata->cur);
stf_preview_render (info->format_run_renderdata,
list,
stf_preview_render (info->format_run_renderdata, list,
info->format_run_displayrows,
pagedata->colcount);
......@@ -66,11 +64,6 @@ format_page_scroll_value_changed (GtkAdjustment *adjustment, DruidPageData_t *da
FormatInfo_t *info = data->format_info;
stf_preview_set_startrow (info->format_run_renderdata, adjustment->value);
stf_cache_options_set_range (info->format_run_cacheoptions,
info->format_run_renderdata->startrow - 1,
(info->format_run_renderdata->startrow - 1) + info->format_run_displayrows);
format_page_update_preview (data);
}
......@@ -202,14 +195,9 @@ format_page_format_changed (GtkEntry *entry, DruidPageData_t *data)
g_return_if_fail (listitem != NULL);
sf = listitem->data;
if (sf) {
char *fmt = style_format_as_XL (sf, TRUE);
if (strcmp (fmt, new_fmt) != 0)
stf_cache_options_invalidate (info->format_run_cacheoptions);
g_free (fmt);
if (sf)
style_format_unref (sf);
}
listitem->data = style_format_new_XL (new_fmt, TRUE);
gtk_clist_set_text (info->format_collist, info->format_run_index, 1, new_fmt);
......@@ -288,20 +276,19 @@ stf_dialog_format_page_prepare (GnomeDruidPage *page, GnomeDruid *druid, DruidPa
gtk_clist_columns_autosize (info->format_collist);
if (data->lines > LINE_DISPLAY_LIMIT)
if (data->lines > LINE_DISPLAY_LIMIT) {
GTK_RANGE (info->format_scroll)->adjustment->upper = LINE_DISPLAY_LIMIT;
else
stf_parse_options_set_lines_to_parse (info->format_run_parseoptions, LINE_DISPLAY_LIMIT);
} else {
GTK_RANGE (info->format_scroll)->adjustment->upper = data->lines + 1;
stf_parse_options_set_lines_to_parse (info->format_run_parseoptions, data->importlines);
}
stf_preview_colwidths_clear (info->format_run_renderdata);
for (i = 0; i < data->colcount + 1; i++) {
stf_preview_colwidths_add (info->format_run_renderdata, stf_parse_get_colwidth (info->format_run_parseoptions, data->cur, i));
}
stf_cache_options_set_range (info->format_run_cacheoptions,
info->format_run_renderdata->startrow - 1,
(info->format_run_renderdata->startrow - 1) + stf_preview_get_displayed_rowcount (info->format_run_renderdata));
info->format_run_manual_change = TRUE;
gtk_clist_select_row (info->format_collist, 0, 0);
gnumeric_clist_moveto (info->format_collist, 0);
......@@ -335,9 +322,6 @@ stf_dialog_format_page_cleanup (DruidPageData_t *pagedata)
FormatInfo_t *info = pagedata->format_info;
stf_preview_free (info->format_run_renderdata);
stf_cache_options_free (info->format_run_cacheoptions);
info->format_run_cacheoptions = NULL;
}
/**
......@@ -381,7 +365,6 @@ stf_dialog_format_page_init (GladeXML *gui, DruidPageData_t *pagedata)
info->format_run_manual_change = FALSE;
info->format_run_sublist_select = TRUE;
info->format_run_displayrows = stf_preview_get_displayed_rowcount (info->format_run_renderdata);
info->format_run_cacheoptions = stf_cache_options_new ();
info->format_run_parseoptions = NULL; /* stf_parse_options_new (); */
gtk_clist_column_titles_passive (info->format_sublist);
......
......@@ -3,7 +3,7 @@
* render sheet previews on the gnomecanvas and offers
* functions for making this preview more interactive.
*
* Almer. S. Tigelaar <almer1@dds.nl>
* Copyright (C) Almer S. Tigelaar <almer@gnome.org>
*
* NOTES :
* 1) This is rather sucky, it works, reasonably fast, but it's not ideal.
......@@ -21,47 +21,7 @@
* |
* |--- GSList (Sub) --> Contains strings as GSList->Data
*
* What it comes down to is that the stf_preview_render call actually
* merges this which an internal hash. The previewing system is thus
* responsible for freeing all the lists _and_ the strings. Ofcourse
* it does not have to do this immediately (and in fact it does not)
* It first puts the Sublists in a hash and 'overwrites' them when
* newer 'version' of these sublists come available.
*
* This sounds complex, but is really simple in essence, to illustrate
* see the diagram below. It tries to tell what happens to each item in
* GSList (Sub)
* (Note that the NULL item has a special meaning, it means that
* the line has been parsed before and we just have to use
* the existing value in the hash)
*
* |-----< GSList (Sub) Item
* |
* Is this item's data NULL?
* |
* |--------------------------------------
* | |
* Nope Yes
* | |
* | Look up the existing list of strings
* | in the hash and use it for display
* |
* Is this item already in hash?
* |
* |--------------------------------------
* | |
* Yes Nope
* | |
* Replace our hashed list of string Insert the new list of strings
* with this new one and use the into the hash and use it for
* new one for display display
* (Free both the old list and it's
* strings!)
*
* Lists from the stf_parse_cached routines are _exacly_ in this format
* look in the stf-parse.[ch] for more details on this.
*/
#include <config.h>
#include "format.h"
#include "number-match.h"
......@@ -337,7 +297,14 @@ stf_preview_render_row (RenderData_t *renderdata, double rowy, GSList *row, int
int widthwanted;
if (iterator != NULL && iterator->data != NULL) {
char *text = NULL;
/*
* We need an upper limit or else we'll crash X
*/
if (strlen (iterator->data) > INT_MAX)
text = g_strndup (iterator->data, INT_MAX);
/* In case the active color differs from the inactive color
* this code can be activated
*
......@@ -346,13 +313,16 @@ stf_preview_render_row (RenderData_t *renderdata, double rowy, GSList *row, int
* else
* color = text_color;
*/
textwidth = stf_preview_draw_text (renderdata->group,
iterator->data,
renderdata->font,
TEXT_COLOR,
xpos + (CELL_HPAD / 2),
rowy + (CELL_VPAD / 2));
if (text)
g_free (text);
}
widthwanted = renderdata->charwidth * g_array_index (renderdata->colwidths, int, col);
......@@ -371,28 +341,6 @@ stf_preview_render_row (RenderData_t *renderdata, double rowy, GSList *row, int
return rowy + CELL_VPAD + renderdata->charheight;
}
/**
* stf_preview_free_row
* @row : a GSList row
*
* will free @row and the char*'s it points too
*
* returns : nothing
**/
static void
stf_preview_free_row (GSList *row)
{
GSList *iterator = row;
while (iterator) {
g_free ( (char *) iterator->data);
iterator = g_slist_next (iterator);
}
g_slist_free (row);
}
/**
* stf_preview_format_recalc_colwidths
* @renderdata : renderdata struct
......@@ -506,78 +454,6 @@ stf_preview_format_line (RenderData_t *renderdata, GSList *data, int colcount)
}
}
/**
* stf_preview_format_recalc_colwidths
* @renderdata : renderdata struct
* @data : a list containing lists with strings
* @colcount : number of items in each list in @data
*
* Walks trough a list which has been acquired by calling parse_sheet_cached and
* creates a new list which is a merge of items that were in the hash and items
* that are 'new'
*
* returns : a new list (which the calling routine HAS to free)
**/
static GSList *
stf_preview_merge_with_hash (RenderData_t *renderdata, GSList *list, int colcount)
{
GSList *result = NULL;
GSList *result_end = NULL;
GSList *iterator = list;
int i = 0;
while (iterator) {
GSList *data;
int row = renderdata->startrow + i;
if (iterator->data == NULL) {
data = g_hash_table_lookup (renderdata->hashtable, &row);
/*
* If the data is NULL we simply assume
* this means the line is empty
*/
} else {
int *key;
GSList *orig_data;
if (g_hash_table_lookup_extended (renderdata->hashtable, &row, (gpointer*) &key, (gpointer*) &orig_data)) {
stf_preview_free_row (orig_data);
} else {
key = g_new (int, 1);
*key = row;
}
data = iterator->data;
g_hash_table_insert (renderdata->hashtable, key, data);
/* Reformat the line */
if (renderdata->formatted && data != NULL)
stf_preview_format_line (renderdata, data, colcount);
}
if (result != NULL) {
result_end = g_slist_append (result_end, data)->next;
} else {
result = g_slist_append (result, data);
result_end = result;
}
iterator = g_slist_next (iterator);
i++;
}
g_slist_free (list);
return result;
}
/**
* stf_preview_render
* @renderdata : a renderdata struct
......@@ -622,8 +498,6 @@ stf_preview_render (RenderData_t *renderdata, GSList *list, int rowcount, int co
"y", 0.0,
NULL));
list = stf_preview_merge_with_hash (renderdata, list, colcount);
if (renderdata->formatted)
stf_preview_format_recalc_colwidths (renderdata, list, colcount);
......@@ -639,11 +513,16 @@ stf_preview_render (RenderData_t *renderdata, GSList *list, int rowcount, int co
/* Render line by line */
iterator = list;
i = 1;
while (iterator) {
ypos = stf_preview_render_row (renderdata, ypos, iterator->data, colcount);
if (i >= renderdata->startrow) {
if (renderdata->formatted && iterator->data != NULL)
stf_preview_format_line (renderdata, iterator->data, colcount);
ypos = stf_preview_render_row (renderdata, ypos, iterator->data, colcount);
}
iterator = g_slist_next (iterator);
i++;
}