[gnumeric] ODF: Import frames.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ODF: Import frames.
- Date: Sun, 12 Sep 2010 17:27:21 +0000 (UTC)
commit 7088eb9451d36a9eed696d2331d29ed05e3c4961
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Sep 12 11:26:33 2010 -0600
ODF: Import frames.
2010-09-12 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_draw_control_start): handle frames
(odf_form_control): handle form:generic-control (our frames)
(odf_form_generic): new
(odf_form_button_end): rename to odf_form_control_end
(odf_control_property): new
(opendoc_content_dtd): connect the above
NEWS | 2 +-
plugins/openoffice/ChangeLog | 9 +++++
plugins/openoffice/openoffice-read.c | 56 ++++++++++++++++++++++++++++-----
3 files changed, 57 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1f8bb7c..32cf1d8 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Andreas:
* Fix image-fill, pattern and gradient export. [#628762]
* Read tab colors from OOo config in ODF files.
* Improve some ODF chart import/export.
- * Import/export various form controls from and to ODF files.
+ * Import/export all form controls from and to ODF files.
* Export all sheet objects to ODF files.
--------------------------------------------------------------------------
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 21ffc20..9cb65a7 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-12 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (od_draw_control_start): handle frames
+ (odf_form_control): handle form:generic-control (our frames)
+ (odf_form_generic): new
+ (odf_form_button_end): rename to odf_form_control_end
+ (odf_control_property): new
+ (opendoc_content_dtd): connect the above
+
2010-09-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (opendoc_content_dtd): add more elements
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index daf0499..c98ffc2 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4751,6 +4751,9 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
} else if (oc->t == sheet_widget_button_get_type ()) {
so = state->chart.so = g_object_new
(oc->t, "text", oc->label, NULL);
+ } else if (oc->t == sheet_widget_frame_get_type ()) {
+ so = state->chart.so = g_object_new
+ (oc->t, "text", oc->label, NULL);
}
od_draw_frame_end (xin, NULL);
@@ -6155,6 +6158,7 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
};
int tmp;
+ state->cur_control = NULL;
oc->step = oc->page_step = 1;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
@@ -6239,19 +6243,24 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
"ooo:com.sun.star.form."
"component.ScrollBar"))
oc->t = sheet_widget_scrollbar_get_type ();
+ } else if (t == sheet_widget_frame_get_type ()) {
+ if (oc->implementation == NULL ||
+ 0 != strcmp (oc->implementation, "gnm:frame")) {
+ oo_control_free (oc);
+ return;
+ } else
+ oc->t = t;
} else
oc->t = t;
g_hash_table_replace (state->controls, name, oc);
} else {
oo_control_free (oc);
- oc = NULL;
+ return;
}
- if (t == sheet_widget_button_get_type ())
+ if (t == sheet_widget_button_get_type () ||
+ t == sheet_widget_frame_get_type ())
state->cur_control = oc;
- else
- state->cur_control = NULL;
-
}
@@ -6275,6 +6284,12 @@ odf_form_radio (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
+odf_form_generic (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ odf_form_control (xin, attrs, sheet_widget_frame_get_type ());
+}
+
+static void
odf_form_listbox (GsfXMLIn *xin, xmlChar const **attrs)
{
odf_form_control (xin, attrs, sheet_widget_list_get_type ());
@@ -6293,7 +6308,7 @@ odf_form_button (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
-odf_form_button_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+odf_form_control_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
OOParseState *state = (OOParseState *)xin->user_state;
state->cur_control = NULL;
@@ -6327,6 +6342,29 @@ odf_button_event_listener (GsfXMLIn *xin, xmlChar const **attrs)
state->cur_control->linked_cell = g_strdup (macro_name + 12);
}
+static void
+odf_control_property (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+ char const *property_name = NULL;
+ char const *value = NULL;
+
+ if (state->cur_control == NULL)
+ return;
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+ OO_NS_FORM, "property-name"))
+ property_name = CXML2C (attrs[1]);
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+ OO_NS_OFFICE, "string-value"))
+ value = CXML2C (attrs[1]);
+
+ if (0 == strcmp (property_name, "gnm:label") &&
+ NULL != value)
+ state->cur_control->label = g_strdup (value);
+}
+
/****************************************************************************/
/******************************** settings.xml ******************************/
@@ -6922,9 +6960,9 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (TABLE, FORMS, OO_NS_OFFICE, "forms", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (FORMS, FORM, OO_NS_FORM, "form", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (FORM, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_PROPERTY, OO_NS_FORM, "property", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_PROPERTY, OO_NS_FORM, "property", GSF_XML_NO_CONTENT, &odf_control_property, NULL),
GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_LIST_PROPERTY, OO_NS_FORM, "list-property", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (FORM, FORM_BUTTON, OO_NS_FORM, "button", GSF_XML_NO_CONTENT, &odf_form_button, &odf_form_button_end),
+ GSF_XML_IN_NODE (FORM, FORM_BUTTON, OO_NS_FORM, "button", GSF_XML_NO_CONTENT, &odf_form_button, &odf_form_control_end),
GSF_XML_IN_NODE (FORM_BUTTON, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (FORM_BUTTON, BUTTON_OFFICE_EVENT_LISTENERS, OO_NS_OFFICE, "event-listeners", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (BUTTON_OFFICE_EVENT_LISTENERS, BUTTON_EVENT_LISTENER, OO_NS_SCRIPT, "event-listener", GSF_XML_NO_CONTENT, &odf_button_event_listener, NULL),
@@ -6938,7 +6976,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (FORM_LISTBOX, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (FORM, FORM_COMBOBOX, OO_NS_FORM, "combobox", GSF_XML_NO_CONTENT, &odf_form_combobox, NULL),
GSF_XML_IN_NODE (FORM_COMBOBOX, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
- GSF_XML_IN_NODE (FORM, FORM_GENERIC, OO_NS_FORM, "generic-control", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (FORM, FORM_GENERIC, OO_NS_FORM, "generic-control", GSF_XML_NO_CONTENT, &odf_form_generic, &odf_form_control_end),
GSF_XML_IN_NODE (FORM_GENERIC, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (TABLE, TABLE_ROWS, OO_NS_TABLE, "table-rows", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TABLE, TABLE_COL, OO_NS_TABLE, "table-column", GSF_XML_NO_CONTENT, &oo_col_start, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]