[gnumeric] Be compatible wihthe changed LibreOffice ODF documents with tab colours.



commit 15c35796cf2ba490025b56e3d6d1fd5c4d250d1b
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun Aug 28 23:56:08 2011 -0600

    Be compatible wihthe changed LibreOffice ODF documents with tab colours.
    
    2011-08-28  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_style_prop_table): read LibreOffice
    	foreign attribute and ODF 1.3 attribute for tab colour
    	* openoffice-write.c (odf_write_table_style) write LibreOffice
    	foreign attribute and ODF 1.3 attribute (if appropriate) for tab colour
    	(odf_write_ooo_settings): don't write tab colour for ODF 1.3 here

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    8 ++++++++
 plugins/openoffice/openoffice-read.c  |   14 ++++++++++++--
 plugins/openoffice/openoffice-write.c |   13 +++++++++++--
 4 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index b307662..cb88358 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Andreas:
 	* Add HPFILTER function calculating the Hodrick Prescott Filter.
 	* Fix saving of newlines to xls. [#356711]
 	* Enable markup selection in scientific format selector.
+	* Be compatible wihthe changed LibreOffice ODF documents with tab colours.
 
 Jean:
 	* Make things build against gtk+-3.0.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 3ddad60..d1cb94a 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-28  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_style_prop_table): read LibreOffice
+	foreign attribute and ODF 1.3 attribute for tab colour
+	* openoffice-write.c (odf_write_table_style) write LibreOffice
+	foreign attribute and ODF 1.3 attribute (if appropriate) for tab colour
+	(odf_write_ooo_settings): don't write tab colour for ODF 1.3 here
+
 2011-08-05  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (odf_scientific): read gnm:literal-E
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 4d9ac6d..275539d 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -5237,8 +5237,18 @@ oo_style_prop_table (GsfXMLIn *xin, xmlChar const **attrs)
 				style->visibility = GNM_SHEET_VISIBILITY_HIDDEN;
 		} else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "writing-mode", modes, &tmp_i))
 			style->is_rtl = tmp_i;
-		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
-					       OO_GNUM_NS_EXT, "tab-color")) {
+		else if ((!style->tab_color_set &&
+			  /* Gnumeric's version */
+			   gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+					       OO_GNUM_NS_EXT, "tab-color")) ||
+			 (!style->tab_color_set &&
+			  /* Used by LO 3.3.3 and later */
+			  gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+					      OO_NS_TABLE_OOO, "tab-color")) ||
+			 /* For ODF 1.3 etc. */
+			(gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+					     OO_NS_TABLE, "tab-color"))) {
+			/* For ODF 1.3 etc. */
 			GdkRGBA rgba;
 			if (gdk_rgba_parse (&rgba, CXML2C (attrs[1]))) {
 				style->tab_color
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 22992f0..e72a596 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -99,6 +99,7 @@
 #define FORM     "form:"
 #define SCRIPT   "script:"
 #define OOO      "ooo:"
+#define TABLEOOO "tableooo:"
 #define XML      "xml:"
 #define GNMSTYLE "gnm:"  /* We use this for attributes and elements not supported by ODF */
 
@@ -176,6 +177,7 @@ static struct {
 	{ "xmlns:ooo",		"http://openoffice.org/2004/office"; },
 	{ "xmlns:ooow",		"http://openoffice.org/2004/writer"; },
 	{ "xmlns:oooc",		"http://openoffice.org/2004/calc"; },
+	{ "xmlns:tableooo",	"http://openoffice.org/2009/table"; },
 	{ "xmlns:of",		"urn:oasis:names:tc:opendocument:xmlns:of:1.2" },
 	{ "xmlns:dom",		"http://www.w3.org/2001/xml-events"; },
 	{ "xmlns:xforms",	"http://www.w3.org/2002/xforms"; },
@@ -647,10 +649,12 @@ odf_write_table_style (GnmOOExport *state, Sheet const *sheet)
 		sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE);
 	gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "writing-mode",
 		sheet->text_is_rtl ? "rl-tb" : "lr-tb");
-	if (state->with_extension) {
+	if (state->with_extension && get_gsf_odf_version () < 103) {
 		if (sheet->tab_color && !sheet->tab_color->is_auto) {
 			gnm_xml_out_add_hex_color (state->xml, GNMSTYLE "tab-color",
 						   sheet->tab_color, 1);
+			gnm_xml_out_add_hex_color (state->xml, TABLEOOO "tab-color",
+						   sheet->tab_color, 1);
 		}
 		if (sheet->tab_text_color && !sheet->tab_text_color->is_auto) {
 			gnm_xml_out_add_hex_color (state->xml,
@@ -658,6 +662,9 @@ odf_write_table_style (GnmOOExport *state, Sheet const *sheet)
 						   sheet->tab_text_color, 1);
 		}
 	}
+	if (get_gsf_odf_version () >= 103)
+		gnm_xml_out_add_hex_color (state->xml, TABLE "tab-color",
+					   sheet->tab_color, 1);
 	gsf_xml_out_end_element (state->xml); /* </style:table-properties> */
 
 	gsf_xml_out_end_element (state->xml); /* </style:style> */
@@ -5417,7 +5424,9 @@ odf_write_ooo_settings (GnmOOExport *state)
 		Sheet *sheet = l->data;
 		gsf_xml_out_start_element (state->xml, CONFIG "config-item-map-entry");
 		gsf_xml_out_add_cstr (state->xml, CONFIG "name", sheet->name_unquoted);
-		if (sheet->tab_color != NULL && !sheet->tab_color->is_auto) {
+		if (get_gsf_odf_version () < 103  && sheet->tab_color != NULL 
+		    && !sheet->tab_color->is_auto) {
+			/* Not used by LO 3.3.3 and later */
 			gsf_xml_out_start_element (state->xml, CONFIG "config-item");
 			gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", "TabColor");
 			gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "type", "int");



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