[gnumeric] Handle print flag roundtrip through odf for controls
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Handle print flag roundtrip through odf for controls
- Date: Sat, 9 May 2020 02:56:39 +0000 (UTC)
commit e7821d023e31c677c174ea2b16b802c2623516db
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Fri May 8 20:55:49 2020 -0600
Handle print flag roundtrip through odf for controls
2020-05-08 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_so_set_props): new
(od_style_prop_chart): skip negation
(od_draw_control_start): read style name
(odf_so_filled): use odf_so_set_props
* openoffice-write.c (odf_write_sheet_object_styles): write styles for all sheet objects
(odf_write_control): write style qname
plugins/openoffice/ChangeLog | 9 ++++++++
plugins/openoffice/openoffice-read.c | 43 +++++++++++++++++++++++++++++------
plugins/openoffice/openoffice-write.c | 27 +++++++++-------------
3 files changed, 56 insertions(+), 23 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 892d42bf7..18b4003a2 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-08 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (odf_so_set_props): new
+ (od_style_prop_chart): skip negation
+ (od_draw_control_start): read style name
+ (odf_so_filled): use odf_so_set_props
+ * openoffice-write.c (odf_write_sheet_object_styles): write styles for all sheet objects
+ (odf_write_control): write style name
+
2020-05-06 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_prop_list_has): read style:print-content
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index b0c6e3a2c..9e3a2a537 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1,5 +1,4 @@
/* vm: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
/*
* openoffice-read.c : import open/star calc files
*
@@ -556,6 +555,7 @@ static char const *odf_strunescape (char const *string, GString *target,
G_GNUC_UNUSED GnmConventions const *convs);
static void odf_sheet_suggest_size (GsfXMLIn *xin, int *cols, int *rows);
static void oo_prop_list_has (GSList *props, gboolean *threed, char const *tag);
+static void odf_so_set_props (OOParseState *state, OOChartStyle *oostyle);
/* Implementations */
@@ -7631,7 +7631,7 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
else if (oo_attr_bool (xin, attrs, OO_NS_STYLE, "print-content", &btmp))
style->other_props = g_slist_prepend
(style->other_props,
- oo_prop_new_bool ("do-not-print-content", !btmp));
+ oo_prop_new_bool ("print-content", btmp));
else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "auto-marker-outline-colour", &btmp))
style->style_props = g_slist_prepend (style->style_props,
@@ -8298,12 +8298,15 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
{
OOParseState *state = (OOParseState *)xin->user_state;
char const *name = NULL;
+ char const *style_name = NULL;
od_draw_frame_start (xin, attrs);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "control"))
name = CXML2C (attrs[1]);
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "style-name"))
+ style_name = CXML2C (attrs[1]);
if (name != NULL) {
OOControl *oc = g_hash_table_lookup (state->controls, name);
@@ -8388,6 +8391,12 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
state->chart.so = g_object_new
(oc->t, "text", oc->label, NULL);
}
+ if (state->chart.so && style_name) {
+ OOChartStyle *oostyle = g_hash_table_lookup
+ (state->chart.graph_styles, style_name);
+ if (oostyle != NULL)
+ odf_so_set_props (state, oostyle);
+ }
} else
oo_warning (xin, "Undefined control '%s' encountered!", name);
}
@@ -10352,6 +10361,22 @@ odf_annotation_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
/****************************************************************************/
/******************************** graphic sheet objects *********************/
+static void
+odf_so_set_props (OOParseState *state, OOChartStyle *oostyle)
+{
+ GSList *l;
+ for (l = oostyle->other_props; l != NULL; l = l->next) {
+ OOProp *prop = l->data;
+ if (0 == strcmp ("print-content", prop->name)) {
+ gboolean prop_val;
+ prop_val = g_value_get_boolean (&prop->value);
+ sheet_object_set_print_flag
+ (state->chart.so,
+ &prop_val);
+ }
+ }
+}
+
static void
odf_so_filled (GsfXMLIn *xin, xmlChar const **attrs, gboolean is_oval)
{
@@ -10377,14 +10402,10 @@ odf_so_filled (GsfXMLIn *xin, xmlChar const **attrs, gboolean is_oval)
if (style_name != NULL) {
OOChartStyle *oostyle = g_hash_table_lookup
(state->chart.graph_styles, style_name);
- /* since we are using oo_prop_list_has we need to default to FALSE */
- gboolean has_prop = FALSE;
if (oostyle != NULL) {
odf_apply_style_props (xin, oostyle->style_props,
style, FALSE);
- oo_prop_list_has (oostyle->other_props, &has_prop, "do-not-print-content");
- has_prop =!has_prop;
- sheet_object_set_print_flag (state->chart.so, &has_prop);
+ odf_so_set_props (state, oostyle);
}
}
g_object_set (state->chart.so, "style", style, NULL);
@@ -10979,6 +11000,7 @@ odf_line (GsfXMLIn *xin, xmlChar const **attrs)
GOStyle *style = go_style_dup (style0);
odf_apply_style_props (xin, oostyle->style_props,
style, FALSE);
+
g_object_set (state->chart.so, "style", style, NULL);
g_object_unref (style);
g_object_unref (style0);
@@ -10990,6 +11012,13 @@ odf_line (GsfXMLIn *xin, xmlChar const **attrs)
start_marker = g_value_get_string (&prop->value);
else if (0 == strcmp ("marker-end", prop->name))
end_marker = g_value_get_string (&prop->value);
+ else if (0 == strcmp ("print-content", prop->name)) {
+ gboolean prop_val;
+ prop_val =g_value_get_boolean (&prop->value);
+ sheet_object_set_print_flag
+ (state->chart.so,
+ &prop_val);
+ }
}
if (start_marker != NULL) {
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 8737083ae..e1434c794 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1,3 +1,4 @@
+/* vm: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* openoffice-write.c : export OpenOffice OASIS .ods files
@@ -928,24 +929,14 @@ odf_write_sheet_object_styles (GnmOOExport *state)
for (i = 0; i < workbook_sheet_count (state->wb); i++) {
Sheet const *sheet = workbook_sheet_by_index (state->wb, i);
- GSList *objects = sheet_objects_get (sheet, NULL, GNM_SO_FILLED_TYPE), *l;
+ GSList *objects = sheet_objects_get (sheet, NULL, G_TYPE_NONE), *l;
for (l = objects; l != NULL; l = l->next) {
SheetObject *so = GNM_SO (l->data);
- char *name = odf_write_sheet_object_style (state, so);
- g_hash_table_replace (state->so_styles, so, name);
- }
- g_slist_free (objects);
- objects = sheet_objects_get (sheet, NULL, GNM_SO_LINE_TYPE);
- for (l = objects; l != NULL; l = l->next) {
- SheetObject *so = GNM_SO (l->data);
- char *name = odf_write_sheet_object_line_style (state, so);
- g_hash_table_replace (state->so_styles, so, name);
- }
- g_slist_free (objects);
- objects = sheet_objects_get (sheet, NULL, GNM_SO_PATH_TYPE);
- for (l = objects; l != NULL; l = l->next) {
- SheetObject *so = GNM_SO (l->data);
- char *name = odf_write_sheet_object_style (state, so);
+ char *name;
+ if (GNM_IS_SO_LINE(so))
+ name = odf_write_sheet_object_line_style (state, so);
+ else
+ name = odf_write_sheet_object_style (state, so);
g_hash_table_replace (state->so_styles, so, name);
}
g_slist_free (objects);
@@ -3182,7 +3173,11 @@ odf_write_custom_shape (GnmOOExport *state, SheetObject *so)
static void
odf_write_control (GnmOOExport *state, SheetObject *so, char const *id)
{
+ gchar const *style_name = g_hash_table_lookup (state->so_styles, so);
+
gsf_xml_out_start_element (state->xml, DRAW "control");
+ if (style_name != NULL)
+ gsf_xml_out_add_cstr (state->xml, DRAW "style-name", style_name);
odf_write_frame_size (state, so);
gsf_xml_out_add_cstr (state->xml, DRAW "control", id);
gsf_xml_out_end_element (state->xml); /* DRAW "control" */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]