[gnumeric] xlsx: don't drop text contents of rectangles on write.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: don't drop text contents of rectangles on write.
- Date: Sun, 6 Feb 2022 20:28:19 +0000 (UTC)
commit 20d9b360af93680abb90dc2af56e824730bf6dbf
Author: Morten Welinder <terra gnome org>
Date: Sun Feb 6 15:27:54 2022 -0500
xlsx: don't drop text contents of rectangles on write.
NEWS | 1 +
plugins/excel/xlsx-write-drawing.c | 32 ++++++++++++++++++++++++++++++++
samples/object-tests.gnumeric | Bin 10186 -> 10262 bytes
3 files changed, 33 insertions(+)
---
diff --git a/NEWS b/NEWS
index f60d26be5..31058c2a3 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Morten:
* Various --with-long-double fixes.
* Fix BITAND.
* Test improvements.
+ * Fix xlsx write for sheet objects with text contents. [#617]
--------------------------------------------------------------------------
Gnumeric 1.12.51
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index bb0c26942..3c4dc1d56 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -1447,6 +1447,28 @@ xlsx_write_nvpr (GsfXMLOut *xml, SheetObject *so, int id)
gsf_xml_out_end_element (xml);
}
+static void
+xlsx_write_drawing_text (XLSXWriteState *stat, GsfXMLOut *xml, const char *text)
+{
+ gsf_xml_out_start_element (xml, "xdr:txBody");
+
+ gsf_xml_out_start_element (xml, "a:bodyPr");
+ // Something likely ought to go here
+ gsf_xml_out_end_element (xml); /* </a:bodyPr> */
+
+ gsf_xml_out_start_element (xml, "a:p");
+ gsf_xml_out_start_element (xml, "a:r");
+
+ gsf_xml_out_simple_element (xml, "a:t", text);
+
+ gsf_xml_out_end_element (xml); /* </a:r> */
+ gsf_xml_out_end_element (xml); /* </a:p> */
+
+ gsf_xml_out_end_element (xml); // </xdr:txBody>
+}
+
+
+
static char const *
xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
GSList *objects, GHashTable *zorder)
@@ -1640,6 +1662,7 @@ xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
GNM_IS_SO_FILLED (so)) {
GOStyle *style = NULL;
XLSXStyleContext sctx;
+ char *text = NULL;
xlsx_style_context_init (&sctx, state);
sctx.spPr_ns = "xdr";
@@ -1664,6 +1687,9 @@ xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
if (g_object_class_find_property (G_OBJECT_GET_CLASS (so), "style"))
g_object_get (so, "style", &style, NULL);
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (so), "text"))
+ g_object_get (so, "text", &text, NULL);
+
if (style) {
gsf_xml_out_start_element (xml, "xdr:sp");
gsf_xml_out_start_element (xml, "xdr:nvSpPr");
@@ -1673,10 +1699,16 @@ xlsx_write_drawing_objects (XLSXWriteState *state, GsfOutput *sheet_part,
gsf_xml_out_end_element (xml); /* </xdr:nvSpPr> */
xlsx_write_go_style_full (xml, style, &sctx);
+
+ if (text)
+ xlsx_write_drawing_text (state, xml, text);
+
gsf_xml_out_end_element (xml); /* </xdr:sp> */
g_object_unref (style);
}
+ g_free (text);
+
g_free (sctx.start_arrow);
g_free (sctx.end_arrow);
}
diff --git a/samples/object-tests.gnumeric b/samples/object-tests.gnumeric
index eea8dc0d2..3dcefda01 100644
Binary files a/samples/object-tests.gnumeric and b/samples/object-tests.gnumeric differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]