[gnumeric] Write cell borders to ODF and fix reading of cell borders from ODF.



commit 5cfaccd69ac671d6da8328f7a8697124aee5820e
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sat May 16 17:59:42 2009 -0600

    Write cell borders to ODF and fix reading of cell borders from ODF.
    
        2009-05-16  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        	* openoffice-write.c (odf_get_border_format): use goffice GO_PT_TO_CM
        	  utility
        	* openoffice-read.c (oo_parse_border): spacing may vary and there are
        	  more borders including "none"
        	(oo_style_prop_cell): The tag is officially called diagonal-bl-tr,
        	  not diagonal-tr-bl
---
 NEWS                                  |    2 ++
 plugins/openoffice/ChangeLog          |    9 +++++++++
 plugins/openoffice/openoffice-read.c  |   21 ++++++++++++++++-----
 plugins/openoffice/openoffice-write.c |    5 +++--
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 31e6ba1..9a20420 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ Andreas:
 	* Write some character based formats to HTML files. [#582118]
 	* Handle whitespace in created ODF files correctly. 
 	* Write cell styles to the ODF file. [#553508]
+	* Write cell borders to ODF and fix reading of cell borders from ODF. 
+	  [# 582903]
 
 Jody:
 	* Closer to a turnkey win32 build.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f525936..6765b52 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
 2009-05-16  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_get_border_format): use goffice GO_PT_TO_CM
+	  utility
+	* openoffice-read.c (oo_parse_border): spacing may vary and there are
+	  more borders including "none"
+	(oo_style_prop_cell): The tag is officially called diagonal-bl-tr,
+	  not diagonal-tr-bl
+
+2009-05-16  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_write_cell): export border styles for 
 	  non-empty cells
 	(ns): add a gnumeric namespace to handle export of specifications
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index ff2938e..8f913ba 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1607,7 +1607,7 @@ oo_parse_border (GsfXMLIn *xin, GnmStyle *style,
 
 	if (end == NULL || end == CXML2C (str))
 		return;
-	if (*end == ' ')
+	while (*end == ' ')
 		end++;
 	/* "0.035cm solid #000000" */
 	border_color = strchr (end, '#');
@@ -1615,16 +1615,27 @@ oo_parse_border (GsfXMLIn *xin, GnmStyle *style,
 		char *border_type = g_strndup (end, border_color - end);
 		color = oo_parse_color (xin, CC2XML (border_color), "color");
 
-		if (!strcmp ("solid", border_type)) {
+		if (g_str_has_prefix (border_type, "none")||
+		    g_str_has_prefix (border_type, "hidden"))
+			border_style = GNM_STYLE_BORDER_NONE;
+		else if (g_str_has_prefix (border_type, "solid") ||
+			 g_str_has_prefix (border_type, "groove") ||
+			 g_str_has_prefix (border_type, "ridge") ||
+			 g_str_has_prefix (border_type, "inset") ||
+			 g_str_has_prefix (border_type, "outset")) {
 			if (pts <= OD_BORDER_THIN)
 				border_style = GNM_STYLE_BORDER_THIN;
 			else if (pts <= OD_BORDER_MEDIUM)
 				border_style = GNM_STYLE_BORDER_MEDIUM;
 			else
 				border_style = GNM_STYLE_BORDER_THICK;
-		} else
+		} else if (g_str_has_prefix (border_type, "dashed"))
+			border_style = GNM_STYLE_BORDER_DASHED;
+		else if (g_str_has_prefix (border_type, "dotted"))
+			border_style = GNM_STYLE_BORDER_DOTTED;
+		else 
 			border_style = GNM_STYLE_BORDER_DOUBLE;
-
+		
 		border = gnm_style_border_fetch (border_style, color,
 						 gnm_style_border_get_orientation (loc));
 		border->width = pts;
@@ -1717,7 +1728,7 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
 			oo_parse_border (xin, style, attrs[1], MSTYLE_BORDER_LEFT);
 			oo_parse_border (xin, style, attrs[1], MSTYLE_BORDER_RIGHT);
 			oo_parse_border (xin, style, attrs[1], MSTYLE_BORDER_TOP);
-		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "diagonal-tr-bl"))
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "diagonal-bl-tr"))
 			oo_parse_border (xin, style, attrs[1], MSTYLE_BORDER_DIAGONAL);
 		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "diagonal-tl-br"))
 			oo_parse_border (xin, style, attrs[1], MSTYLE_BORDER_REV_DIAGONAL);
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 260fd98..52c0e52 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -33,6 +33,7 @@
 #include <goffice/app/file.h>
 #include <goffice/app/io-context.h>
 #include <goffice/utils/go-format.h>
+#include <goffice/utils/go-units.h>
 #include <gnm-format.h>
 #include <workbook.h>
 #include <workbook-priv.h> /* Workbook::names */
@@ -125,7 +126,7 @@ static struct {
 	{ "xmlns:xforms",	"http://www.w3.org/2002/xforms"; },
 	{ "xmlns:xsd",		"http://www.w3.org/2001/XMLSchema"; },
 	{ "xmlns:xsi",		"http://www.w3.org/2001/XMLSchema-instance"; },
-	{ "xmlns:gnm",		"http://www.gnumeric.org/odf-extension"},
+	{ "xmlns:gnm",		"http://www.gnumeric.org/odf-extension/1.0"},
 };
 
 static void
@@ -479,7 +480,7 @@ odf_get_border_format (GnmBorder   *border)
 		break;
 	}
 
-	w = w * 0.033;
+	w = GO_PT_TO_CM (w);
 	g_string_append_printf (str, "%.3fcm ", w);
 	g_string_append (str, border_type);
 	g_string_append_printf (str, " #%.2x%.2x%.2x",  



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