[gnumeric] Export text formats to and import from ODF. [#636158]



commit 11008f40a0669d0742c3db46447ce345700668cf
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Nov 30 15:50:14 2010 -0700

    Export text formats to and import from ODF. [#636158]
    
    2010-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_cell): Write office:string-value.
    	The element content may differ also for strings depending on format.
    	* openoffice-read.c (oo_cell_start): ODF uses office:string-value,
    	while oldstyle OOo uses table:string-value.
    	(odf_text_content): new
    	(styles_dtd): connect handlers for children of number:text-style

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    9 +++++++++
 plugins/openoffice/openoffice-read.c  |   17 ++++++++++++++---
 plugins/openoffice/openoffice-write.c |    3 +++
 4 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 03173ca..75e6c0c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
 	* Calculate residuals when using the regression tool. [#635064]
 	* Permit data entry by-passing autocorrection.
 	* Work around OpenOffice date formatting bugs. [#636131]
+	* Export text formats to and import from ODF. [#636158]
 
 Jean:
 	* Only disable the formula bar when a chart sheet is selected. [#636031]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 4bed76f..b9bc0d3 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
 2010-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_write_cell): Write office:string-value.
+	The element content may differ also for strings depending on format.
+	* openoffice-read.c (oo_cell_start): ODF uses office:string-value, 
+	while oldstyle OOo uses table:string-value.
+	(odf_text_content): new
+	(styles_dtd): connect handlers for children of number:text-style
+	
+2010-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_write_style_goformat_name): also write
 	data styles for text formats
 	
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index c0b904a..1f0b73d 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1859,7 +1859,9 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
 				val = value_new_float (secs / (gnm_float)86400);
 				has_time = TRUE;
 			}
-		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "string-value"))
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					       (state->ver == OOO_VER_OPENDOC) ? OO_NS_OFFICE : OO_NS_TABLE, 
+					       "string-value"))
 			val = value_new_string (CXML2C (attrs[1]));
 		else if (oo_attr_float (xin, attrs,
 			(state->ver == OOO_VER_OPENDOC) ? OO_NS_OFFICE : OO_NS_TABLE,
@@ -2971,6 +2973,13 @@ odf_fraction (GsfXMLIn *xin, xmlChar const **attrs)
 }
 
 static void
+odf_text_content (GsfXMLIn *xin, xmlChar const **attrs)
+{
+	OOParseState *state = (OOParseState *)xin->user_state;
+	g_string_append_c (state->cur_format.accum, '@');
+}
+
+static void
 odf_number (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
@@ -3133,6 +3142,7 @@ odf_number_style (GsfXMLIn *xin, xmlChar const **attrs)
 	state->cond_formats = NULL;
 }
 
+
 static void
 odf_number_percentage_style (GsfXMLIn *xin, xmlChar const **attrs)
 {
@@ -7110,9 +7120,10 @@ GSF_XML_IN_NODE (START, OFFICE_STYLES, OO_NS_OFFICE, "styles", GSF_XML_NO_CONTEN
     GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT_PROP, OO_NS_STYLE,	"text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
 
   GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_TEXT, OO_NS_NUMBER, "text-style", GSF_XML_NO_CONTENT, &odf_number_style, &odf_number_style_end),
-    GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_CONTENT, OO_NS_NUMBER,	"text-content", GSF_XML_NO_CONTENT, NULL, NULL),
-    GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_PROP, OO_NS_NUMBER,		"text", GSF_XML_NO_CONTENT, NULL, NULL),
+    GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_CONTENT, OO_NS_NUMBER,	"text-content", GSF_XML_NO_CONTENT,  &odf_text_content, NULL),
+    GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_PROP, OO_NS_NUMBER,		"text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
     GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_MAP, OO_NS_STYLE,		"map", GSF_XML_NO_CONTENT, &odf_map, NULL),
+    GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_TEXT_PROP, OO_NS_STYLE,	"text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
 
 GSF_XML_IN_NODE_END
 };
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 34c010b..83fd0f3 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2944,6 +2944,9 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 		case VALUE_STRING:
 			gsf_xml_out_add_cstr_unchecked (state->xml,
 							OFFICE "value-type", "string");
+			gsf_xml_out_add_cstr (state->xml,
+					      OFFICE "string-value",
+					      value_peek_string (cell->value));
 			break;
 		case VALUE_CELLRANGE:
 		case VALUE_ARRAY:



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