Commit 85eeec0e authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

change dialogresult->formats to dialogresult->parseoptions->formats

2003-07-05  Andreas J. Guelzow  <aguelzow@taliesin.ca>

	* src/gui-clipboard.c: change dialogresult->formats to
	  dialogresult->parseoptions->formats thoughout
	* src/stf-parse.c (stf_parse_options_new): initialize formats
	(stf_parse_options_free (stf_parse_region): rewrite
	* src/stf-parse.h: add formats list to parseoptions
	* src/stf.c (stf_store_results): split into stf_store_results
	  and stf_apply_formats
	(stf_apply_formats): new

2003-07-05  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* dialog-stf.c: change dialogresult->formats to
	  dialogresult->parseoptions->formats throughout
	(stf_dialog_result_free): don't free formats
	* dialog-stf.h: remove formats from DialogStfResult_t
parent 50920d3c
......@@ -245,7 +245,7 @@ Pending Patches
2.16) Fix character set mess on paste (DONE)
2.17) Tabs: handle optional expansion.
2.18) Kill use of "importlines" and properly find the end. (DONE)
2.19) Fix locale specific parsing on paste.
2.19) Fix locale specific parsing on paste. (DONE)
3) hlinks
3.1) Finish the edit dialog to load and store results (DONE)
......
2003-07-05 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-clipboard.c: change dialogresult->formats to
dialogresult->parseoptions->formats thoughout
* src/stf-parse.c (stf_parse_options_new): initialize formats
(stf_parse_options_free (stf_parse_region): rewrite
* src/stf-parse.h: add formats list to parseoptions
* src/stf.c (stf_store_results): split into stf_store_results
and stf_apply_formats
(stf_apply_formats): new
2003-07-05 Morten Welinder <terra@gnome.org>
* src/position.c (cellref_hash): Use hash space much better.
......
......@@ -16,6 +16,7 @@ Andreas:
* Update consolidate dialog
* Permit to ignore any columns during text import
* Add column header menu to format page of text import
* Fix locale specific parsing on paste
Ben Liblit:
* Another attempt at configure time path generation.
......
2003-07-05 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-clipboard.c: change dialogresult->formats to
dialogresult->parseoptions->formats thoughout
* src/stf-parse.c (stf_parse_options_new): initialize formats
(stf_parse_options_free (stf_parse_region): rewrite
* src/stf-parse.h: add formats list to parseoptions
* src/stf.c (stf_store_results): split into stf_store_results
and stf_apply_formats
(stf_apply_formats): new
2003-07-05 Morten Welinder <terra@gnome.org>
* src/position.c (cellref_hash): Use hash space much better.
......
2003-07-05 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-clipboard.c: change dialogresult->formats to
dialogresult->parseoptions->formats thoughout
* src/stf-parse.c (stf_parse_options_new): initialize formats
(stf_parse_options_free (stf_parse_region): rewrite
* src/stf-parse.h: add formats list to parseoptions
* src/stf.c (stf_store_results): split into stf_store_results
and stf_apply_formats
(stf_apply_formats): new
2003-07-05 Morten Welinder <terra@gnome.org>
* src/position.c (cellref_hash): Use hash space much better.
......
2003-07-05 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-stf.c: change dialogresult->formats to
dialogresult->parseoptions->formats throughout
(stf_dialog_result_free): don't free formats
* dialog-stf.h: remove formats from DialogStfResult_t
2003-07-04 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-stf-format-page.c (format_page_update_preview): preserve
......
......@@ -401,7 +401,7 @@ stf_dialog (WorkbookControlGUI *wbcg,
dialogresult->parseoptions->locale = pagedata.locale;
pagedata.locale = NULL;
dialogresult->formats = pagedata.format.formats;
dialogresult->parseoptions->formats = pagedata.format.formats;
pagedata.format.formats = NULL;
dialogresult->parseoptions->col_import_array
= pagedata.format.col_import_array;
......@@ -438,20 +438,10 @@ stf_dialog (WorkbookControlGUI *wbcg,
void
stf_dialog_result_free (DialogStfResult_t *dialogresult)
{
unsigned int ui;
GPtrArray *formats;
g_return_if_fail (dialogresult != NULL);
stf_parse_options_free (dialogresult->parseoptions);
formats = dialogresult->formats;
for (ui = 0; ui < formats->len; ui++) {
StyleFormat *sf = g_ptr_array_index (formats, ui);
style_format_unref (sf);
}
g_ptr_array_free (formats, TRUE);
g_free (dialogresult->text);
g_free (dialogresult->encoding);
......
......@@ -124,7 +124,6 @@ typedef struct {
char *text; /* Decoded text. */
int rowcount; /* Number of resulting rows. */
StfParseOptions_t *parseoptions; /* parse options */
GPtrArray *formats; /* Contains StyleFormat *s */
} DialogStfResult_t;
/* This is the main function which handles all the dialog import stuff */
......
......@@ -131,9 +131,10 @@ text_to_cell_region (WorkbookControlGUI *wbcg,
}
targetcol = 0;
for (col = 0; col < dialogresult->formats->len; col++) {
for (col = 0; col < dialogresult->parseoptions->formats->len; col++) {
if (dialogresult->parseoptions->col_import_array[col]) {
StyleFormat *sf = g_ptr_array_index (dialogresult->formats, col);
StyleFormat *sf = g_ptr_array_index
(dialogresult->parseoptions->formats, col);
StyleRegion *sr = g_new (StyleRegion, 1);
sr->range.start.col = targetcol;
......
......@@ -40,6 +40,7 @@
#include "gutils.h"
#include "parse-util.h"
#include "format.h"
#include "datetime.h"
#include <stdlib.h>
#include <locale.h>
......@@ -162,6 +163,7 @@ stf_parse_options_new (void)
parseoptions->sep.chr = NULL;
parseoptions->col_import_array = NULL;
parseoptions->formats = NULL;
return parseoptions;
}
......@@ -195,6 +197,18 @@ stf_parse_options_free (StfParseOptions_t *parseoptions)
stf_parse_options_clear_line_terminator (parseoptions);
if (parseoptions->formats) {
unsigned int ui;
GPtrArray *formats = parseoptions->formats;
for (ui = 0; ui < formats->len; ui++) {
StyleFormat *sf = g_ptr_array_index (formats, ui);
style_format_unref (sf);
}
g_ptr_array_free (formats, TRUE);
parseoptions->formats = NULL;
}
g_free (parseoptions);
}
......@@ -1163,6 +1177,8 @@ stf_parse_region (StfParseOptions_t *parseoptions, char const *data, char const
for (row = 0; row < lines->len; row++) {
GPtrArray *line = g_ptr_array_index (lines, row);
unsigned int col, targetcol = 0;
#warning FIXME: We should not just assume the 1900 convention
GnmDateConventions date_conv = {FALSE};
for (col = 0; col < line->len; col++) {
if (parseoptions->col_import_array[col]) {
......@@ -1170,35 +1186,26 @@ stf_parse_region (StfParseOptions_t *parseoptions, char const *data, char const
if (text) {
CellCopy *ccopy;
Value *v;
StyleFormat *fmt = g_ptr_array_index
(parseoptions->formats, col);
#warning FIXME
/************************
* AAARRRGGGGG
* This is bogus
* none of this should be at this level.
* we need the user selected formats
* which are currently stuck down in the render info ??
* All we really need at this level is the set of values.
* See stf_parse_sheet
**/
if (text[0] == '\'' || gnm_expr_char_start_p (text)) {
char *tmp = g_strconcat ("\'", text, NULL);
g_free (text);
text = tmp;
v = format_match (text, fmt, &date_conv);
if (v == NULL) {
v = value_new_string_nocopy (text);
g_ptr_array_index (line, col) = NULL;
}
ccopy = g_new (CellCopy, 1);
ccopy->type = CELL_COPY_TYPE_TEXT;
ccopy->type = CELL_COPY_TYPE_CELL;
ccopy->col_offset = targetcol;
ccopy->row_offset = row;
ccopy->u.text = text; /* No need to free this here */
ccopy->u.cell = cell_new ();
cell_set_value(ccopy->u.cell, v);
ccopy->comment = NULL;
content = g_list_prepend (content, ccopy);
g_ptr_array_index (line, col) = NULL;
if (targetcol > colhigh)
colhigh = targetcol;
......
......@@ -56,6 +56,7 @@ typedef struct {
int colcount; /* Number of columns parsed */
gboolean *col_import_array; /* 0/1 array indicating */
/* which cols to import */
GPtrArray *formats; /* Contains StyleFormat *s */
} StfParseOptions_t;
/* CREATION/DESTRUCTION of stf options struct */
......
......@@ -114,29 +114,38 @@ stf_preparse (CommandContext *context, GsfInput *input, size_t *data_len)
return data;
}
static gboolean
stf_store_results (DialogStfResult_t *dialogresult,
Sheet *sheet, int start_col, int start_row)
static void
stf_apply_formats (StfParseOptions_t *parseoptions,
Sheet *sheet, int col, int start_row, int end_row)
{
unsigned int ui;
Range range;
range.start.col = start_col;
range.start.col = col;
range.start.row = start_row;
range.end.col = start_col;
range.end.row = start_row + dialogresult->rowcount - 1;
range.end.col = col;
range.end.row = end_row;
for (ui = 0; ui < dialogresult->formats->len; ui++) {
if (dialogresult->parseoptions->col_import_array[ui]) {
for (ui = 0; ui < parseoptions->formats->len; ui++) {
if (parseoptions->col_import_array[ui]) {
MStyle *style = mstyle_new ();
StyleFormat *sf = g_ptr_array_index (dialogresult->formats, ui);
StyleFormat *sf = g_ptr_array_index
(parseoptions->formats, ui);
mstyle_set_format (style, sf);
sheet_style_apply_range (sheet, &range, style);
range.start.col++;
range.end.col++;
}
}
}
static gboolean
stf_store_results (DialogStfResult_t *dialogresult,
Sheet *sheet, int start_col, int start_row)
{
stf_apply_formats (dialogresult->parseoptions,
sheet, start_col, start_row,
start_row + dialogresult->rowcount - 1);
return stf_parse_sheet (dialogresult->parseoptions,
dialogresult->text, NULL, sheet,
start_col, start_row);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment