[gnumeric] Add validation stubs to ODF export



commit cdb9f38e1b8e265780c98ec2f510a2aa6ef208d1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri May 13 16:05:20 2011 -0600

    Add validation stubs to ODF export
    
    2011-05-13  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (opendoc_content_dtd): add CELL_ANNOTATION_TEXT_LINE_BREAK,
    	* openoffice-write.c (odf_validation_general): new stub
    	(odf_validation_length): new stub
    	(odf_validation_custom): new stub
    	(odf_print_spreadsheet_content_validations): connect above stubs

 plugins/openoffice/ChangeLog          |    8 ++++
 plugins/openoffice/openoffice-read.c  |    1 +
 plugins/openoffice/openoffice-write.c |   68 +++++++++++++++++++++++++++-----
 3 files changed, 66 insertions(+), 11 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 3a43bec..7739ae1 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,13 @@
 2011-05-13  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (opendoc_content_dtd): add CELL_ANNOTATION_TEXT_LINE_BREAK,
+	* openoffice-write.c (odf_validation_general): new stub
+	(odf_validation_length): new stub
+	(odf_validation_custom): new stub
+	(odf_print_spreadsheet_content_validations): connect above stubs
+
+2011-05-13  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (odf_validation_new_single_expr): make argument const
 	(odf_validation_new_pair_expr): ditto
 	(odf_validations_analyze): handle (plain) is-true-formula
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 78a1c56..49a8958 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -7941,6 +7941,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
 	          GSF_XML_IN_NODE (TABLE_CELL, CELL_ANNOTATION, OO_NS_OFFICE, "annotation", GSF_XML_NO_CONTENT, &odf_annotation_start, &odf_annotation_end),
 	            GSF_XML_IN_NODE (CELL_ANNOTATION, CELL_ANNOTATION_TEXT, OO_NS_TEXT, "p", GSF_XML_CONTENT, NULL, &odf_annotation_content_end),
   		      GSF_XML_IN_NODE (CELL_ANNOTATION_TEXT, CELL_ANNOTATION_TEXT_S,    OO_NS_TEXT, "s", GSF_XML_NO_CONTENT, NULL, NULL),
+		      GSF_XML_IN_NODE (CELL_ANNOTATION_TEXT, CELL_ANNOTATION_TEXT_LINE_BREAK, OO_NS_TEXT, "line-break", GSF_XML_NO_CONTENT, NULL, NULL),
   		      GSF_XML_IN_NODE (CELL_ANNOTATION_TEXT, CELL_ANNOTATION_TEXT_TAB,  OO_NS_TEXT, "tab", GSF_XML_NO_CONTENT, NULL, NULL),
 		      GSF_XML_IN_NODE (CELL_ANNOTATION_TEXT, CELL_ANNOTATION_TEXT_SPAN, OO_NS_TEXT, "span", GSF_XML_SHARED_CONTENT, NULL, NULL),
 		        GSF_XML_IN_NODE (CELL_ANNOTATION_TEXT_SPAN, CELL_ANNOTATION_TEXT_SPAN, OO_NS_TEXT, "span", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd def */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 8c4f718..a957976 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3802,6 +3802,25 @@ odf_validation_general_attributes (GnmOOExport *state, GnmValidation const *val)
 }
 
 static void
+odf_validation_general (GnmOOExport *state, GnmValidation const *val,
+			Sheet *sheet, GnmStyleRegion const *sr,
+			char const *prefix)
+{
+}
+
+static void
+odf_validation_length (GnmOOExport *state, GnmValidation const *val,
+			Sheet *sheet, GnmStyleRegion const *sr)
+{
+}
+
+static void
+odf_validation_custom (GnmOOExport *state, GnmValidation const *val,
+			Sheet *sheet, GnmStyleRegion const *sr)
+{
+}
+
+static void
 odf_validation_in_list (GnmOOExport *state, GnmValidation const *val,
 			Sheet *sheet, GnmStyleRegion const *sr)
 {
@@ -3851,19 +3870,46 @@ odf_print_spreadsheet_content_validations (GnmOOExport *state)
 			GnmStyleRegion const *sr  = l->data;
 			GnmValidation const *val = gnm_style_get_validation (sr->style);
 
-			if (val->type == VALIDATION_TYPE_IN_LIST) {
-				if (!element_written) {
-					gsf_xml_out_start_element
-						(state->xml, TABLE "content-validations");
-					element_written = TRUE;
-				}
-				gsf_xml_out_start_element (state->xml,
-							   TABLE "content-validation");
-				odf_validation_general_attributes (state, val);
+			if (!element_written) {
+				gsf_xml_out_start_element
+					(state->xml, TABLE "content-validations");
+				element_written = TRUE;
+			}
+			gsf_xml_out_start_element (state->xml,
+						   TABLE "content-validation");
+			odf_validation_general_attributes (state, val);
+			switch (val->type) {
+			case VALIDATION_TYPE_ANY:
+				odf_validation_general (state, val, sheet, sr, "");
+				break;
+			case VALIDATION_TYPE_AS_INT:
+				odf_validation_general (state, val, sheet, sr, 
+							"cell-content-is-whole-number() and ");
+				break;
+			case VALIDATION_TYPE_AS_NUMBER:
+				odf_validation_general (state, val, sheet, sr, 
+							"cell-content-is-decimal-number() and ");
+				break;
+			case VALIDATION_TYPE_AS_DATE:
+				odf_validation_general (state, val, sheet, sr, 
+							"ell-content-is-date() and ");
+				break;
+			case VALIDATION_TYPE_AS_TIME:
+				odf_validation_general (state, val, sheet, sr, 
+							"ell-content-is-time() and ");
+				break;
+			case VALIDATION_TYPE_IN_LIST:
 				odf_validation_in_list (state, val, sheet, sr);
-				gsf_xml_out_end_element (state->xml);
-				/* </table:content-validation> */
+				break;
+			case VALIDATION_TYPE_TEXT_LENGTH:
+				odf_validation_length (state, val, sheet, sr);
+				break;
+			case VALIDATION_TYPE_CUSTOM:
+				odf_validation_custom (state, val, sheet, sr);
+				break;
 			}
+			gsf_xml_out_end_element (state->xml);
+			/* </table:content-validation> */
 		}
 
 		style_list_free (list);



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