[goffice] GOStyle: same auto_width property.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOStyle: same auto_width property.
- Date: Fri, 9 May 2014 01:37:13 +0000 (UTC)
commit d7b6872a4530f1210a83b0278ffc4dbc0d8a2c07
Author: Morten Welinder <terra gnome org>
Date: Thu May 8 21:36:47 2014 -0400
GOStyle: same auto_width property.
ChangeLog | 5 +++++
goffice/utils/go-style.c | 20 ++++++++++++++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aa75944..d11800d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2014-05-08 Morten Welinder <terra gnome org>
+ * goffice/utils/go-style.c (go_style_sax_load_line): Read
+ auto-width.
+ (go_style_line_sax_save): Save auto_width. Don't save width when
+ auto_width.
+
* goffice/graph/gog-axis.c (map_linear_calc_ticks): Keep values as
integers as long as possible.
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index 8bbe866..3bdd02e 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -1408,7 +1408,9 @@ go_style_line_sax_save (GsfXMLOut *output, char const *name,
gsf_xml_out_add_cstr_unchecked (output, "dash",
go_line_dash_as_str (line->dash_type));
- gsf_xml_out_add_float (output, "width", line->width, 6);
+ gsf_xml_out_add_bool (output, "auto-width", line->auto_width);
+ if (!line->auto_width)
+ gsf_xml_out_add_float (output, "width", line->width, 6);
gsf_xml_out_add_bool (output, "auto-color", line->auto_color);
if (!line->auto_color)
@@ -1537,13 +1539,15 @@ go_style_sax_load_line (GsfXMLIn *xin, xmlChar const **attrs)
{
GOStyle *style = GO_STYLE (xin->user_state);
GOStyleLine *line = &style->line;
+ gboolean seen_auto_width = FALSE, seen_width = FALSE;
- for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (0 == strcmp (attrs[0], "dash"))
line->dash_type = go_line_dash_from_str (attrs[1]);
else if (bool_sax_prop ("auto-dash", attrs[0], attrs[1], &line->auto_dash))
;
else if (0 == strcmp (attrs[0], "width")) {
+ seen_width = TRUE;
line->width = g_strtod (attrs[1], NULL);
/* For compatibility with older graphs, when dash_type
* didn't exist */
@@ -1551,10 +1555,22 @@ go_style_sax_load_line (GsfXMLIn *xin, xmlChar const **attrs)
line->width = 0.;
line->dash_type = GO_LINE_NONE;
}
+ } else if (bool_sax_prop ("auto-width", attrs[0], attrs[1], &line->auto_width)) {
+ /* auto-width was introduced in 0.10.16 */
+ seen_auto_width = TRUE;
} else if (0 == strcmp (attrs[0], "color"))
go_color_from_str (attrs[1], &line->color);
else if (bool_sax_prop ("auto-color", attrs[0], attrs[1], &line->auto_color))
;
+ }
+
+ if (seen_width && !seen_auto_width) {
+ /*
+ * Pre-0.10.16 lacked the auto-width attribute. Let's just
+ * assume the width was explicitly set iff it is non-zero.
+ */
+ line->auto_width = (line->width == 0);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]