[gnumeric] Import [Red] and others in data formats from ODF
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Import [Red] and others in data formats from ODF
- Date: Tue, 2 Jun 2009 14:47:34 -0400 (EDT)
commit b0ce2633181aa8f29e32aee3942e6b92209afe30
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 2 12:46:55 2009 -0600
Import [Red] and others in data formats from ODF
2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (attr_eq_ncase): new
(odf_number_color): new
(styles_dtd): hook-up odf_number_color
(opendoc_content_dtd): ditto
---
plugins/openoffice/ChangeLog | 7 ++++
plugins/openoffice/openoffice-read.c | 55 +++++++++++++++++++++++++++------
2 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 835f82a..6ea8913 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (attr_eq_ncase): new
+ (odf_number_color): new
+ (styles_dtd): hook-up odf_number_color
+ (opendoc_content_dtd): ditto
+
+2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (oo_date_text_end): don't quote single ()
(odf_format_generate_number_str): delete (this is now handled by
go_format_generate_number_str
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 3d59774..fc24e7d 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1817,6 +1817,41 @@ odf_map (GsfXMLIn *xin, xmlChar const **attrs)
g_free (style_name);
}
+static inline gboolean
+attr_eq_ncase (xmlChar const *a, char const *s, int n)
+{
+ return !g_ascii_strncasecmp (CXML2C (a), s, n);
+}
+
+static void
+odf_number_color (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_FO, "color")){
+ char const *color = NULL;
+ if (attr_eq_ncase (attrs[1], "#ff0000", 7))
+ color = "[Red]";
+ else if (attr_eq_ncase (attrs[1], "#000000", 7))
+ color = "[Black]";
+ else if (attr_eq_ncase (attrs[1], "#0000ff", 7))
+ color = "[Blue]";
+ else if (attr_eq_ncase (attrs[1], "#00ffff", 7))
+ color = "[Cyan]";
+ else if (attr_eq_ncase (attrs[1], "#00ff00", 7))
+ color = "[Green]";
+ else if (attr_eq_ncase (attrs[1], "#ff00ff", 7))
+ color = "[Magenta]";
+ else if (attr_eq_ncase (attrs[1], "#ffffff", 7))
+ color = "[White]";
+ else if (attr_eq_ncase (attrs[1], "#ffff00", 7))
+ color = "[Yellow]";
+ if (color != NULL)
+ g_string_append (state->accum_fmt, color);
+ }
+}
+
static void
odf_number_style (GsfXMLIn *xin, xmlChar const **attrs)
{
@@ -3082,7 +3117,7 @@ GSF_XML_IN_NODE (START, OFFICE_STYLES, OO_NS_OFFICE, "styles", GSF_XML_NO_CONTEN
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_SCI_STYLE_PROP, OO_NS_NUMBER, "scientific-number", GSF_XML_NO_CONTENT, &odf_scientific, NULL),
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_STYLE_PROP, OO_NS_STYLE, "properties", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
- GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, DATE_STYLE, OO_NS_NUMBER, "date-style", GSF_XML_NO_CONTENT, &oo_date_style, &oo_date_style_end),
GSF_XML_IN_NODE (DATE_STYLE, DATE_DAY, OO_NS_NUMBER, "day", GSF_XML_NO_CONTENT, &oo_date_day, NULL),
@@ -3097,7 +3132,7 @@ GSF_XML_IN_NODE (START, OFFICE_STYLES, OO_NS_OFFICE, "styles", GSF_XML_NO_CONTEN
GSF_XML_IN_NODE (DATE_STYLE, DATE_SECONDS, OO_NS_NUMBER, "seconds", GSF_XML_NO_CONTENT, &oo_date_seconds, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_AM_PM, OO_NS_NUMBER, "am-pm", GSF_XML_NO_CONTENT, &oo_date_am_pm, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, TIME_STYLE, OO_NS_NUMBER, "time-style", GSF_XML_NO_CONTENT, &oo_date_style, &oo_date_style_end),
@@ -3106,7 +3141,7 @@ GSF_XML_IN_NODE (START, OFFICE_STYLES, OO_NS_OFFICE, "styles", GSF_XML_NO_CONTEN
GSF_XML_IN_NODE (TIME_STYLE, TIME_SECONDS, OO_NS_NUMBER, "seconds", GSF_XML_NO_CONTENT, &oo_date_seconds, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_AM_PM, OO_NS_NUMBER, "am-pm", GSF_XML_NO_CONTENT, &oo_date_am_pm, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_BOOL, OO_NS_NUMBER, "boolean-style", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -3118,13 +3153,13 @@ GSF_XML_IN_NODE (START, OFFICE_STYLES, OO_NS_OFFICE, "styles", GSF_XML_NO_CONTEN
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_SYMBOL, OO_NS_NUMBER, "currency-symbol", GSF_XML_CONTENT, NULL, &odf_currency_symbol_end),
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_PERCENTAGE, OO_NS_NUMBER, "percentage-style", GSF_XML_NO_CONTENT, &odf_number_style, &odf_number_style_end),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_STYLE_PROP, OO_NS_NUMBER, "number", GSF_XML_NO_CONTENT, &odf_number, NULL),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
- GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_TEXT, OO_NS_NUMBER, "text-style", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_CONTENT, OO_NS_NUMBER, "text-content", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -3288,8 +3323,8 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_STYLE_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_STYLE_FRACTION, OO_NS_NUMBER, "fraction", GSF_XML_NO_CONTENT, &odf_fraction, NULL),
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_SCI_STYLE_PROP, OO_NS_NUMBER, "scientific-number", GSF_XML_NO_CONTENT, &odf_scientific, NULL),
- GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_STYLE_PROP, OO_NS_STYLE, "properties", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
+ GSF_XML_IN_NODE (NUMBER_STYLE, NUMBER_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, DATE_STYLE, OO_NS_NUMBER, "date-style", GSF_XML_NO_CONTENT, &oo_date_style, &oo_date_style_end),
GSF_XML_IN_NODE (DATE_STYLE, DATE_DAY, OO_NS_NUMBER, "day", GSF_XML_NO_CONTENT, &oo_date_day, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_MONTH, OO_NS_NUMBER, "month", GSF_XML_NO_CONTENT, &oo_date_month, NULL),
@@ -3303,7 +3338,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (DATE_STYLE, DATE_SECONDS, OO_NS_NUMBER, "seconds", GSF_XML_NO_CONTENT, &oo_date_seconds, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_AM_PM, OO_NS_NUMBER, "am-pm", GSF_XML_NO_CONTENT, &oo_date_am_pm, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (DATE_STYLE, DATE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (DATE_STYLE, DATE_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, TIME_STYLE, OO_NS_NUMBER, "time-style", GSF_XML_NO_CONTENT, &oo_date_style, &oo_date_style_end),
GSF_XML_IN_NODE (TIME_STYLE, TIME_HOURS, OO_NS_NUMBER, "hours", GSF_XML_NO_CONTENT, &oo_date_hours, NULL),
@@ -3311,7 +3346,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (TIME_STYLE, TIME_SECONDS, OO_NS_NUMBER, "seconds", GSF_XML_NO_CONTENT, &oo_date_seconds, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_AM_PM, OO_NS_NUMBER, "am-pm", GSF_XML_NO_CONTENT, &oo_date_am_pm, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (TIME_STYLE, TIME_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (TIME_STYLE, TIME_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_BOOL, OO_NS_NUMBER, "boolean-style", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (STYLE_BOOL, BOOL_PROP, OO_NS_NUMBER, "boolean", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -3321,12 +3356,12 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_SYMBOL, OO_NS_NUMBER, "currency-symbol", GSF_XML_CONTENT, NULL, &odf_currency_symbol_end),
GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
- GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (STYLE_CURRENCY, CURRENCY_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_PERCENTAGE, OO_NS_NUMBER, "percentage-style", GSF_XML_NO_CONTENT, &odf_number_style, &odf_number_style_end),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_STYLE_PROP, OO_NS_NUMBER, "number", GSF_XML_NO_CONTENT, &odf_number, NULL),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT, OO_NS_NUMBER, "text", GSF_XML_CONTENT, NULL, &oo_date_text_end),
GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_MAP, OO_NS_STYLE, "map", GSF_XML_NO_CONTENT, &odf_map, NULL),
- GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (STYLE_PERCENTAGE, PERCENTAGE_TEXT_PROP, OO_NS_STYLE, "text-properties", GSF_XML_NO_CONTENT, &odf_number_color, NULL),
GSF_XML_IN_NODE (OFFICE_STYLES, STYLE_TEXT, OO_NS_NUMBER, "text-style", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_CONTENT, OO_NS_NUMBER, "text-content", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (STYLE_TEXT, STYLE_TEXT_PROP, OO_NS_NUMBER, "text", GSF_XML_NO_CONTENT, NULL, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]