[gnumeric] export more style conditions



commit e9b0033934f0ed78c471c747a83828f774f7e93c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri May 18 18:38:02 2012 -0600

    export more style conditions
    
    2012-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_save_style_map): handle more conditions

 plugins/openoffice/ChangeLog          |    4 ++
 plugins/openoffice/openoffice-write.c |   65 ++++++++++++++++++++++++++-------
 2 files changed, 56 insertions(+), 13 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 4d61787..7f6e35b 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,9 @@
 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>
+
 	* openoffice-read.c (odf_text_p_apply_pango_attribute): new
 	(odf_text_p_apply_style): splicing messes with the end indices of
 	existing attributes, so just insert.
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index c367e62..94d4dc7 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1495,49 +1495,88 @@ odf_save_style_map (GnmOOExport *state, GnmStyleCond const *cond)
 
 	switch (cond->op) {
 	case GNM_STYLE_COND_BETWEEN:
-		g_string_append (str, "cell-content-is-between");
+		g_string_append (str, "of:cell-content-is-between");
 		odf_save_style_map_double_f (state, str, cond);
 		break;
 	case GNM_STYLE_COND_NOT_BETWEEN:
-		g_string_append (str, "cell-content-is-not-between");
+		g_string_append (str, "of:cell-content-is-not-between");
 		odf_save_style_map_double_f (state, str, cond);
 		break;
 	case GNM_STYLE_COND_EQUAL:
-		g_string_append (str, "cell-content()=");
+		g_string_append (str, "of:cell-content()=");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
 	case GNM_STYLE_COND_NOT_EQUAL:
-		g_string_append (str, "cell-content()!=");
+		g_string_append (str, "of:cell-content()!=");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
 	case GNM_STYLE_COND_GT:
-		g_string_append (str, "cell-content()>");
+		g_string_append (str, "of:cell-content()>");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
 	case GNM_STYLE_COND_LT:
-		g_string_append (str, "cell-content()<");
+		g_string_append (str, "of:cell-content()<");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
 	case GNM_STYLE_COND_GTE:
-		g_string_append (str, "cell-content()>=");
+		g_string_append (str, "of:cell-content()>=");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
 	case GNM_STYLE_COND_LTE:
-		g_string_append (str, "cell-content()<=");
+		g_string_append (str, "of:cell-content()<=");
 		odf_save_style_map_single_f (state, str, cond->texpr[0]);
 		break;
-
-	case GNM_STYLE_COND_CUSTOM:
+	case GNM_STYLE_COND_CONTAINS_ERR:
+		g_string_append (str, "of:is-true-formula(ISERROR([.A1]))");
+		break;
+	case GNM_STYLE_COND_NOT_CONTAINS_ERR:
+		g_string_append (str, "of:is-true-formula(NOT(ISERROR([.A1])))");
+		break;
 	case GNM_STYLE_COND_CONTAINS_STR:
+		g_string_append (str, "of:is-true-formula(NOT(ISERROR(FIND(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";[.A1]))))");
+		break;
 	case GNM_STYLE_COND_NOT_CONTAINS_STR:
+		g_string_append (str, "of:is-true-formula(ISERROR(FIND(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";[.A1])))");
+		break;
 	case GNM_STYLE_COND_BEGINS_WITH_STR:
+		g_string_append (str, "of:is-true-formula(IFERROR(FIND(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";[.A1]);2)=1)");
+		break;
 	case GNM_STYLE_COND_NOT_BEGINS_WITH_STR:
+		g_string_append (str, "of:is-true-formula(NOT(IFERROR(FIND(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";[.A1]);2)=1))");
+		break;
 	case GNM_STYLE_COND_ENDS_WITH_STR:
+		g_string_append (str, "of:is-true-formula(EXACT(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";RIGHT([.A1];LEN(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ")))");
+		break;
 	case GNM_STYLE_COND_NOT_ENDS_WITH_STR:
-	case GNM_STYLE_COND_CONTAINS_ERR:
-	case GNM_STYLE_COND_NOT_CONTAINS_ERR:
+		g_string_append (str, "of:is-true-formula(NOT(EXACT(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ";RIGHT([.A1];LEN(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, "))))");
+		break;
 	case GNM_STYLE_COND_CONTAINS_BLANKS:
+		g_string_append (str, "of:is-true-formula(NOT(ISERROR(FIND(\" \";[.A1]))))");
+		break;
 	case GNM_STYLE_COND_NOT_CONTAINS_BLANKS:
+		g_string_append (str, "of:is-true-formula(ISERROR(FIND(\" \";[.A1])))");
+		break;
+	case GNM_STYLE_COND_CUSTOM:
+		g_string_append (str, "of:is-true-formula(");
+		odf_save_style_map_single_f (state, str, cond->texpr[0]);
+		g_string_append (str, ")");
+		break;
 	default:
 		g_string_free (str, TRUE);
 		return;
@@ -1546,7 +1585,7 @@ odf_save_style_map (GnmOOExport *state, GnmStyleCond const *cond)
 	gsf_xml_out_start_element (state->xml, STYLE "map");
 
 	gsf_xml_out_add_cstr (state->xml, STYLE "apply-style-name", name);
-/* 	gsf_xml_out_add_cstr (state->xml, STYLE "base-cell-address","A1"); */
+	gsf_xml_out_add_cstr (state->xml, STYLE "base-cell-address","A1");
 	gsf_xml_out_add_cstr (state->xml, STYLE "condition", str->str);
 
 	gsf_xml_out_end_element (state->xml); /* </style:map> */



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