[gnumeric] sc import: handle "SET"



commit 10a6173ab0bd6c956f12e13c1465f3bb623d18d7
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Oct 8 14:28:27 2010 -0600

    sc import: handle "SET"
    
    2010-10-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* sc.c (sc_parse_set): new
    	(sc_parse_format): new stub
    	(sc_parse_format_definition): new stub
    	(sc_cmd_list): connect sc_parse_set and sc_parse_format
    	(sc_parse_set_handle_option): new

 plugins/sc/ChangeLog |    8 +++++++
 plugins/sc/sc.c      |   51 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/plugins/sc/ChangeLog b/plugins/sc/ChangeLog
index 3329ed9..6b39fbf 100644
--- a/plugins/sc/ChangeLog
+++ b/plugins/sc/ChangeLog
@@ -1,5 +1,13 @@
 2010-10-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* sc.c (sc_parse_set): new
+	(sc_parse_format): new stub
+	(sc_parse_format_definition): new stub
+	(sc_cmd_list): connect sc_parse_set and sc_parse_format
+	(sc_parse_set_handle_option): new
+
+2010-10-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* sc.c (sc_parse_goto): new
 	(sc_cmd_list): connect sc_parse_goto
 
diff --git a/plugins/sc/sc.c b/plugins/sc/sc.c
index 05817ba..b735128 100644
--- a/plugins/sc/sc.c
+++ b/plugins/sc/sc.c
@@ -287,6 +287,36 @@ set_h_align (Sheet *sheet, GnmCellPos const *pos, GnmHAlign ha)
 	sheet_style_apply_range	(sheet, &r, style);
 }
 
+static void
+sc_parse_set_handle_option (ScParseState *state, char const *option)
+{
+	if (g_str_has_prefix (option, "iterations=")) {
+		int it = atoi (option + 11);
+		if (it > 0) {
+			workbook_iteration_enabled (state->sheet->workbook, TRUE);
+			workbook_iteration_max_number (state->sheet->workbook, it);
+		}
+	} else if (g_str_has_prefix (option, "autocalc"))
+		workbook_set_recalcmode	(state->sheet->workbook, TRUE);
+	else if (g_str_has_prefix (option, "!autocalc"))
+		workbook_set_recalcmode (state->sheet->workbook, FALSE);
+}
+
+static gboolean
+sc_parse_set (ScParseState *state, char const *cmd, char const *str,
+	      GnmCellPos const *cpos)
+{
+	gchar** options = g_strsplit (str, " ", -1), **tmp;
+
+	if (options != NULL)
+		for (tmp = options; *tmp != NULL; tmp++)
+			sc_parse_set_handle_option (state, *tmp);
+	g_strfreev(options);
+
+	/* Most of these settings are not applicable to Gnumeric */
+	return TRUE;
+}
+
 static gboolean
 sc_parse_goto (ScParseState *state, char const *cmd, char const *str,
 		GnmCellPos const *cpos)
@@ -306,6 +336,23 @@ sc_parse_goto (ScParseState *state, char const *cmd, char const *str,
 }
 
 static gboolean
+sc_parse_format_definition (ScParseState *state, char const *cmd, char const *str)
+{
+	sc_warning (state, "Ignoring column format definition: %s", str);
+	return TRUE;
+}
+
+static gboolean
+sc_parse_format (ScParseState *state, char const *cmd, char const *str,
+		 GnmCellPos const *cpos)
+{
+	if (g_ascii_isdigit ((gchar) *str))
+		return sc_parse_format_definition (state, cmd, str);
+	sc_warning (state, "Ignoring column formatting: %s", str);
+	return TRUE;
+}
+
+static gboolean
 sc_parse_fmt (ScParseState *state, char const *cmd, char const *str,
 		GnmCellPos const *cpos)
 {
@@ -632,7 +679,9 @@ static sc_cmd_t const sc_cmd_list[] = {
 	{ "let", 3,		sc_parse_let,	 TRUE },
 	{ "define", 6,          sc_parse_define, FALSE },
 	{ "fmt", 3,             sc_parse_fmt,    FALSE },
-	{ "goto", 4,             sc_parse_goto,    FALSE },
+	{ "format", 6,          sc_parse_format, FALSE },
+	{ "set", 3,             sc_parse_set,    FALSE },
+	{ "goto", 4,            sc_parse_goto,   FALSE },
 	{ NULL, 0, NULL, 0 },
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]