[gnumeric] Improve ODF import of style conditions.



commit e83b1f93d66335b5dd20e0ef0df656eff17a5b3f
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri May 18 20:20:28 2012 -0600

    Improve ODF import of style conditions.
    
    2012-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_validations_analyze): add argument,
    	change all callers
    	(odf_validations_translate): check for namespaced condition
    	(oo_style_map): check for namespaced condition

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    7 +++++++
 plugins/openoffice/openoffice-read.c |   21 ++++++++++++++-------
 3 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index c60f691..6251a13 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Andreas:
 	* Write the formatted text of sheet objects to ODF.
 	* Fix consolidate tool. [#670155]
 	* Fix crash on ODF import of messagefree validations.
+	* Improve ODF import/export of style conditions.
 
 Jean:
 	* Fix graph series headers when a multiple selection is used. [#675913]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 7f6e35b..2363774 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2012-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_validations_analyze): add argument,
+	change all callers
+	(odf_validations_translate): check for namespaced condition
+	(oo_style_map): check for namespaced condition
+
+2012-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_save_style_map): handle more conditions
 
 2012-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 30e47c2..cf63b0f 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2493,7 +2493,8 @@ odf_validation_new_op (GsfXMLIn *xin, odf_validation_t *val, guint offset, Valid
 }
 
 static GnmValidation *
-odf_validations_analyze (GsfXMLIn *xin, odf_validation_t *val, guint offset, ValidationType vtype)
+odf_validations_analyze (GsfXMLIn *xin, odf_validation_t *val, guint offset,
+			 ValidationType vtype, OOFormula f_type)
 {
 	char const *str = val->condition + offset;
 
@@ -2518,19 +2519,19 @@ odf_validations_analyze (GsfXMLIn *xin, odf_validation_t *val, guint offset, Val
 	else if (g_str_has_prefix (str, "cell-content-is-decimal-number() and"))
 		return odf_validations_analyze
 			(xin, val, str - val->condition + strlen ("cell-content-is-decimal-number() and"),
-			 GNM_VALIDATION_TYPE_AS_NUMBER);
+			 GNM_VALIDATION_TYPE_AS_NUMBER, f_type);
 	else if (g_str_has_prefix (str, "cell-content-is-whole-number() and"))
 		return odf_validations_analyze
 			(xin, val, str - val->condition + strlen ("cell-content-is-whole-number() and"),
-			 GNM_VALIDATION_TYPE_AS_INT);
+			 GNM_VALIDATION_TYPE_AS_INT, f_type);
 	else if (g_str_has_prefix (str, "cell-content-is-date() and"))
 		return odf_validations_analyze
 			(xin, val, str - val->condition + strlen ("cell-content-is-date() and"),
-			 GNM_VALIDATION_TYPE_AS_DATE);
+			 GNM_VALIDATION_TYPE_AS_DATE, f_type);
 	else if (g_str_has_prefix (str, "cell-content-is-time() and"))
 		return odf_validations_analyze
 			(xin, val, str - val->condition + strlen ("cell-content-is-time() and"),
-			 GNM_VALIDATION_TYPE_AS_TIME);
+			 GNM_VALIDATION_TYPE_AS_TIME, f_type);
 	else if (g_str_has_prefix (str, "is-true-formula")) {
 		if (vtype != GNM_VALIDATION_TYPE_ANY) {
 			oo_warning
@@ -2572,8 +2573,11 @@ odf_validations_translate (GsfXMLIn *xin, char const *name)
 	}
 
 	if (val->condition != NULL && val->f_type != FORMULA_NOT_SUPPORTED) {
-		GnmValidation *validation = odf_validations_analyze
-			(xin, val, 0, GNM_VALIDATION_TYPE_ANY);
+		const char *str = val->condition;
+		GnmValidation *validation;
+		OOFormula f_type = odf_get_formula_type (xin, &str);
+		validation = odf_validations_analyze
+			(xin, val, str - val->condition, GNM_VALIDATION_TYPE_ANY, f_type);
 		if (validation != NULL) {
 			GError   *err;
 			if (NULL == (err = gnm_validation_is_ok (validation)))
@@ -5956,6 +5960,7 @@ oo_style_map (GsfXMLIn *xin, xmlChar const **attrs)
 	GnmStyleCond cond;
 	GnmStyleConditions *sc;
 	gboolean success = FALSE;
+	OOFormula f_type;
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "condition"))
@@ -5976,6 +5981,8 @@ oo_style_map (GsfXMLIn *xin, xmlChar const **attrs)
 	cond.texpr[0] = NULL;
 	cond.texpr[1] = NULL;
 
+	f_type = odf_get_formula_type (xin, &condition);
+
 	if (g_str_has_prefix (condition, "cell-content()")) {
 		condition += strlen ("cell-content()") - 1;
 		while (*(++condition) == ' ');



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