[gnumeric] solver: persist and load model type.



commit 2708413b5a3ac799c493445a812cdcf932ddd105
Author: Morten Welinder <terra gnome org>
Date:   Fri May 21 21:50:18 2010 -0400

    solver: persist and load model type.

 ChangeLog           |    4 ++++
 NEWS                |    1 +
 src/xml-sax-read.c  |    8 +++++---
 src/xml-sax-write.c |    1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4d32e5a..45352ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-05-21  Morten Welinder  <terra gnome org>
 
+	* src/xml-sax-write.c (xml_write_solver): Write model type.
+
+	* src/xml-sax-read.c (xml_sax_solver_start): Load model type.
+
 	* src/stf-parse.c (stf_parse_region): Avoid reading beyond the end
 	of the format array.  Fixes #619283.
 
diff --git a/NEWS b/NEWS
index 0cd615a..655b45c 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Gnumeric 1.10.5
 
 Morten:
 	* Fix stf crash.  [#619283]
+	* Persist solver model type.
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.4
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 8116253..d53902c 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2347,15 +2347,17 @@ xml_sax_solver_start (GsfXMLIn *xin, xmlChar const **attrs)
 	Sheet *sheet = gnm_xml_in_cur_sheet (xin);
 	GnmSolverParameters *sp = sheet->solver_parameters;
 	int col = -1, row = -1;
-	int ptype;
+	int ptype, mtype;
 	GnmParsePos pp;
 	gboolean old = FALSE;
 
 	parse_pos_init_sheet (&pp, sheet);
 
 	for (; attrs && attrs[0] && attrs[1] ; attrs += 2) {
-		if (gnm_xml_attr_int (attrs, "ProblemType", &ptype)) {
-			sp->problem_type = (GnmSolverProblemType)ptype;
+		if (gnm_xml_attr_int (attrs, "ModelType", &mtype)) {
+			sp->options.model_type = (GnmSolverModelType)mtype;
+		} else if (gnm_xml_attr_int (attrs, "ProblemType", &ptype)) {
+				sp->problem_type = (GnmSolverProblemType)ptype;
 		} else if (attr_eq (attrs[0], "Inputs")) {
 			GnmValue *v = value_new_cellrange_parsepos_str
 				(&pp,
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index bc016fb..5261274 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -990,6 +990,7 @@ xml_write_solver (GnmOutputXML *state)
 		gnm_expr_free (expr);
 	}
 
+	gsf_xml_out_add_int (state->output, "ModelType", param->options.model_type);
 	gsf_xml_out_add_int (state->output, "ProblemType", param->problem_type);
 	input = gnm_solver_param_get_input (param);
 	if (input)



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