[gnumeric] Fix ODF roundtrip of underlines.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix ODF roundtrip of underlines.
- Date: Mon, 17 Mar 2014 14:49:02 +0000 (UTC)
commit 0f7f7151e52ed3f2e4a3a7c88385d0bbae61ff95
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Mon Mar 17 08:48:38 2014 -0600
Fix ODF roundtrip of underlines.
2014-03-17 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_write_style_cell_properties): use
extension to determine high or low underlines
* openoffice-read.c (oo_style_prop_cell): read new gnm: attribute
and make sure we reverse the mapping we use when we write
NEWS | 3 +-
plugins/openoffice/ChangeLog | 7 ++++++
plugins/openoffice/openoffice-read.c | 39 ++++++++++++++++++++++----------
plugins/openoffice/openoffice-write.c | 21 +++++++++++------
4 files changed, 50 insertions(+), 20 deletions(-)
---
diff --git a/NEWS b/NEWS
index b1b593d..e1a080d 100644
--- a/NEWS
+++ b/NEWS
@@ -8,8 +8,9 @@ Andreas:
* Fix fill-alignment export/import to and from ODF. [part of #726035]
* Fix distributed-alignment export to ODF. [part of #726035]
* Fix ODF roundtrip of "center accross selection". [#726010]
- * Fix ODF roundtrip of conditional formats. [#726201]
+ * Improve ODF roundtrip of conditional formats. [#726201]
* Fix import & export of cell indent from/to ODF.
+ * Fix ODF roundtrip of underlines.
Jean:
* Fix tooltip position for scale or RTL sheets. [#725941]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 2b33c2c..b8145a4 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
2014-03-17 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-write.c (odf_write_style_cell_properties): use
+ extension to determine high or low underlines
+ * openoffice-read.c (oo_style_prop_cell): read new gnm: attribute
+ and make sure we reverse the mapping we use when we write
+
+2014-03-17 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (openoffice-read.c): also set the script to
standard when appropriate
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 93dc7af..dae0264 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6227,6 +6227,7 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
int underline_type = 0;
int underline_style = 0;
gboolean underline_bold = FALSE;
+ gboolean underline_low = FALSE;
g_return_if_fail (style != NULL);
@@ -6324,6 +6325,9 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_NS_STYLE, "text-underline-width")) {
underline_bold = attr_eq (attrs[1], "bold");
+ } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+ OO_GNUM_NS_EXT, "text-underline-placement")) {
+ underline_low = attr_eq (attrs[1], "low");
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_FO, "font-style"))
gnm_style_set_font_italic (style, attr_eq (attrs[1], "italic"));
else if (oo_attr_font_weight (xin, attrs, &tmp))
@@ -6352,18 +6356,29 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
if (underline_style > 0) {
- GnmUnderline underline;
- if (underline_style == 1)
- underline = UNDERLINE_NONE;
- else if (underline_style == 4)
- underline = UNDERLINE_SINGLE_LOW;
- else if (underline_bold)
- underline = UNDERLINE_DOUBLE_LOW;
- else if (underline_type == 2)
- underline = UNDERLINE_DOUBLE;
- else
- underline = UNDERLINE_SINGLE;
-
+ GnmUnderline underline = UNDERLINE_NONE;
+ if (underline_style > 1) {
+ switch (underline_type) {
+ case 0:
+ underline = UNDERLINE_NONE;
+ break;
+ case 2:
+ if (underline_low) {
+ underline = UNDERLINE_DOUBLE_LOW;
+ } else {
+ underline = UNDERLINE_DOUBLE;
+ }
+ break;
+ case 1:
+ default:
+ if (underline_low) {
+ underline = underline_bold ? UNDERLINE_DOUBLE_LOW :
UNDERLINE_SINGLE_LOW;
+ } else {
+ underline = underline_bold ? UNDERLINE_DOUBLE : UNDERLINE_SINGLE;
+ }
+ break;
+ }
+ }
gnm_style_set_font_uline (style, underline);
}
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index b7dfc25..0271897 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1173,12 +1173,19 @@ odf_get_gnm_border_format (GnmBorder *border)
} \
}
-#define UNDERLINESPECS(type, style, width) gsf_xml_out_add_cstr (state->xml, \
+#define UNDERLINESPECS(type, style, width, low) gsf_xml_out_add_cstr (state->xml, \
STYLE "text-underline-type", type); \
gsf_xml_out_add_cstr (state->xml, \
STYLE "text-underline-style", style); \
gsf_xml_out_add_cstr (state->xml, \
- STYLE "text-underline-width", width)
+ STYLE "text-underline-width", width); \
+ gsf_xml_out_add_cstr_unchecked (state->xml, \
+ STYLE "text-underline-color", "font-color"); \
+ gsf_xml_out_add_cstr_unchecked (state->xml, \
+ STYLE "text-underline-mode", "continuous"); \
+ if (low && state->with_extension) \
+ gsf_xml_out_add_cstr_unchecked (state->xml, \
+ GNMSTYLE "text-underline-placement",
"low"); \
static void
odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
@@ -1445,19 +1452,19 @@ odf_write_style_text_properties (GnmOOExport *state, GnmStyle const *style)
if (gnm_style_is_element_set (style, MSTYLE_FONT_UNDERLINE))
switch (gnm_style_get_font_uline (style)) {
case UNDERLINE_NONE:
- UNDERLINESPECS("none", "none", "auto");
+ UNDERLINESPECS("none", "none", "auto", FALSE);
break;
case UNDERLINE_SINGLE:
- UNDERLINESPECS("single", "solid", "auto");
+ UNDERLINESPECS("single", "solid", "auto", FALSE);
break;
case UNDERLINE_DOUBLE:
- UNDERLINESPECS("double", "solid", "auto");
+ UNDERLINESPECS("double", "solid", "auto", FALSE);
break;
case UNDERLINE_SINGLE_LOW:
- UNDERLINESPECS("single", "solid", "auto");
+ UNDERLINESPECS("single", "dash", "auto", TRUE);
break;
case UNDERLINE_DOUBLE_LOW:
- UNDERLINESPECS("double", "solid", "auto");
+ UNDERLINESPECS("double", "dash", "auto", TRUE);
break;
}
/* Superscript/Subscript */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]