[gnumeric] xlsx: import/export text wrapping for chart titles.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: import/export text wrapping for chart titles.
- Date: Fri, 23 Jan 2015 01:15:21 +0000 (UTC)
commit f49993ee9459393d36fb7b46b683b4302693ffca
Author: Morten Welinder <terra gnome org>
Date: Thu Jan 22 20:12:41 2015 -0500
xlsx: import/export text wrapping for chart titles.
plugins/excel/xlsx-read-drawing.c | 15 +++++++++++++--
plugins/excel/xlsx-write-drawing.c | 16 ++++++++++------
2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index f6c1749..9c47731 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -246,9 +246,19 @@ static void
xlsx_body_pr (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ static EnumVal const wrap_types[] = {
+ { "none", 0 },
+ { "square", 1 },
+ { NULL, 0 }
+ };
+
if (GO_IS_STYLED_OBJECT (state->cur_obj) && state->cur_style) {
- for (; attrs && *attrs; attrs += 2)
- if (!strcmp (attrs[0], "rot")) {
+ for (; attrs && *attrs; attrs += 2) {
+ int val;
+
+ if (attr_enum (xin, attrs, "wrap", wrap_types, &val)) {
+ g_object_set (state->cur_obj, "allow-wrap", val, NULL);
+ } else if (!strcmp (attrs[0], "rot")) {
/* FIXME: be careful if the "vert" property exists (not yet supported) */
int rotation;
if (attr_int (xin, attrs, "rot", &rotation)) {
@@ -256,6 +266,7 @@ xlsx_body_pr (GsfXMLIn *xin, xmlChar const **attrs)
state->cur_style->text_layout.angle = (double) rotation / 60000.;
}
}
+ }
}
}
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index cc8efc0..297473a 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -282,19 +282,25 @@ xlsx_write_go_style (GsfXMLOut *xml, GOStyle *style)
static void
xlsx_write_chart_text (XLSXWriteState *state, GsfXMLOut *xml,
- GOData *data, GOStyle *style)
+ GOData *data, GogObject const *label)
{
/* I don't really know what I am doing here. */
char *text = go_data_get_scalar_string (data);
+ GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (label));
gboolean has_font_color = ((style->interesting_fields & GO_STYLE_FONT) &&
!style->font.auto_color);
gboolean has_font = ((style->interesting_fields & GO_STYLE_FONT) &&
TRUE /* !style->font.auto_font */);
+ gboolean allow_wrap;
gsf_xml_out_start_element (xml, "c:tx");
gsf_xml_out_start_element (xml, "c:rich");
- gsf_xml_out_simple_element (xml, "a:bodyPr", NULL);
+ gsf_xml_out_start_element (xml, "a:bodyPr");
+ g_object_get (G_OBJECT (label), "allow-wrap", &allow_wrap, NULL);
+ if (!allow_wrap)
+ gsf_xml_out_add_cstr_unchecked (xml, "wrap", "none");
+ gsf_xml_out_end_element (xml); /* </a:bodyPr> */
gsf_xml_out_start_element (xml, "a:p");
gsf_xml_out_start_element (xml, "a:r");
@@ -400,9 +406,8 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
if (label) {
GOData *text = gog_dataset_get_dim (GOG_DATASET (label), 0);
if (text != NULL) {
- GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (label));
gsf_xml_out_start_element (xml, "c:title");
- xlsx_write_chart_text (state, xml, text, style);
+ xlsx_write_chart_text (state, xml, text, label);
gsf_xml_out_end_element (xml);
}
}
@@ -755,9 +760,8 @@ xlsx_write_one_chart (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *ch
if (obj) {
GOData *text = gog_dataset_get_dim (GOG_DATASET (obj), 0);
if (text != NULL) {
- GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (obj));
gsf_xml_out_start_element (xml, "c:title");
- xlsx_write_chart_text (state, xml, text, style);
+ xlsx_write_chart_text (state, xml, text, obj);
gsf_xml_out_end_element (xml);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]