[gnumeric] GnmColor: eliminate name field.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] GnmColor: eliminate name field.
- Date: Tue, 1 Sep 2009 13:26:06 +0000 (UTC)
commit d5d775c5e2a6eca4bee2f77396b494f0acb0cb38
Author: Morten Welinder <terra gnome org>
Date: Tue Sep 1 09:25:49 2009 -0400
GnmColor: eliminate name field.
ChangeLog | 5 ++++
plugins/openoffice/ChangeLog | 7 ++++++
plugins/openoffice/openoffice-read.c | 35 ++++++++++++++++++++-------------
src/style-color.c | 1 -
src/style-color.h | 1 -
5 files changed, 33 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7d4c24f..023ede7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-01 Morten Welinder <terra gnome org>
+
+ * src/style-color.h (struct _GnmColor): Eliminate
+ gdk_selected_color and name fields.
+
2009-09-01 Jean Brefort <jean brefort normalesup org>
* src/gnm-pane.c: renamed GOColor macros.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index cc43048..fc91de5 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-01 Morten Welinder <terra gnome org>
+
+ * openoffice-read.c (oo_parse_color): Don't change color fields we
+ do not own. Fix leak.
+ (go_plugin_init, go_plugin_shutdown): New functions.
+ (oo_style_prop_cell): Fix handling of transparent colours.
+
2009-09-01 Jean Brefort <jean brefort normalesup org>
* openoffice-write.c (gnm_xml_out_add_hex_color): renamed GOColor macros.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 9016450..6d3998d 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -376,24 +376,21 @@ oo_attr_float (GsfXMLIn *xin, xmlChar const * const *attrs,
return TRUE;
}
+static GnmColor *magic_transparent;
static GnmColor *
oo_parse_color (GsfXMLIn *xin, xmlChar const *str, char const *name)
{
guint r, g, b;
- GnmColor *no_color;
g_return_val_if_fail (str != NULL, NULL);
if (3 == sscanf (CXML2C (str), "#%2x%2x%2x", &r, &g, &b))
return style_color_new_i8 (r, g, b);
- if (0 == strcmp (CXML2C (str), "transparent")) {
- no_color = style_color_auto_back ();
- no_color->name = g_new (gchar, 1);
- no_color->name = g_strdup ("transparent");
- return no_color;
- }
+ if (0 == strcmp (CXML2C (str), "transparent"))
+ return style_color_ref (magic_transparent);
+
oo_warning (xin, "Invalid attribute '%s', expected color, received '%s'",
name, str);
return NULL;
@@ -2390,7 +2387,7 @@ oo_parse_border (GsfXMLIn *xin, GnmStyle *style,
border_style = GNM_STYLE_BORDER_DOTTED;
else
border_style = GNM_STYLE_BORDER_DOUBLE;
-
+
border = gnm_style_border_fetch (border_style, color,
gnm_style_border_get_orientation (loc));
border->width = pts;
@@ -2453,12 +2450,9 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if ((color = oo_attr_color (xin, attrs, OO_NS_FO, "background-color"))) {
gnm_style_set_back_color (style, color);
- if (color->name != NULL){
- if (!strcmp (color->name, "transparent")) {
- gnm_style_set_pattern (style, 0);
- g_free (color->name);
- }
- } else
+ if (color == magic_transparent)
+ gnm_style_set_pattern (style, 0);
+ else
gnm_style_set_pattern (style, 1);
} else if ((color = oo_attr_color (xin, attrs, OO_NS_FO, "color")))
gnm_style_set_font_color (style, color);
@@ -5322,3 +5316,16 @@ openoffice_file_probe (GOFileOpener const *fo, GsfInput *input, GOFileProbeLevel
return ver != OOO_VER_UNKNOWN;
}
+
+G_MODULE_EXPORT void
+go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
+{
+ magic_transparent = style_color_auto_back ();
+}
+
+G_MODULE_EXPORT void
+go_plugin_shutdown (GOPlugin *plugin, GOCmdContext *cc)
+{
+ style_color_unref (magic_transparent);
+ magic_transparent = NULL;
+}
diff --git a/src/style-color.c b/src/style-color.c
index 5776549..7a658af 100644
--- a/src/style-color.c
+++ b/src/style-color.c
@@ -45,7 +45,6 @@ style_color_new_uninterned (gushort red, gushort green, gushort blue,
sc->gdk_color.blue = blue;
sc->gdk_color.pixel = gs_white.pixel;
sc->go_color = GO_RGBA_TO_UINT (red>>8,green>>8,blue>>8,0xff);
- sc->name = NULL;
sc->is_auto = is_auto;
/* Make a contrasting selection color with an alpha of .5 */
diff --git a/src/style-color.h b/src/style-color.h
index 9b04e25..db712a4 100644
--- a/src/style-color.h
+++ b/src/style-color.h
@@ -15,7 +15,6 @@ GType gnm_style_color_get_type (void);
struct _GnmColor {
GdkColor gdk_color;
GOColor go_color;
- char *name;
int ref_count;
gboolean is_auto;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]