[gnumeric] ods: export colour of graph titles etc.



commit 5bf775ba43a56a9c7f904c8cd3e0f19c66212cb3
Author: Morten Welinder <terra gnome org>
Date:   Fri May 9 11:42:10 2014 -0400

    ods: export colour of graph titles etc.

 plugins/openoffice/ChangeLog          |    5 +
 plugins/openoffice/openoffice-write.c |  230 +++++++++++++++++----------------
 2 files changed, 124 insertions(+), 111 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index cafaf61..9c18300 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-09  Morten Welinder  <terra gnome org>
+
+       * openoffice-write.c (odf_write_gog_style_text): Write text colour
+       as appropriate.
+
 2014-05-07  Morten Welinder  <terra gnome org>
 
        * openoffice-read.c (odf_number): Remove escaped debug code.
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 941fe5e..1709cd6 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1473,7 +1473,7 @@ odf_find_style (GnmOOExport *state, GnmStyle const *style)
        }
 
        if (found == NULL) {
-               g_print ("Could not find style %p\n", style);
+               g_printerr ("Could not find style %p\n", style);
                return NULL;
        }
 
@@ -6904,6 +6904,7 @@ odf_write_title (GnmOOExport *state, GogObject const *title,
                                char *formula;
                                char *name;
                                gboolean pp = TRUE;
+                               GnmValue const *v;
 
                                g_object_get (G_OBJECT (state->xml), "pretty-print", &pp, NULL);
 
@@ -6916,7 +6917,7 @@ odf_write_title (GnmOOExport *state, GogObject const *title,
 
                                if (name != NULL) {
                                        gsf_xml_out_add_cstr (state->xml, CHART "style-name",
-                                                                     name);
+                                                             name);
                                        g_free (name);
                                }
 
@@ -6929,16 +6930,15 @@ odf_write_title (GnmOOExport *state, GogObject const *title,
                                                              TABLE "cell-address", f);
                                        gsf_xml_out_add_cstr (state->xml,
                                                              TABLE "cell-range", f);
-                               } else if (GNM_EXPR_GET_OPER (texpr->expr)
-                                          == GNM_EXPR_OP_CONSTANT
-                                          && texpr->expr->constant.value->type == VALUE_STRING
-                                          && allow_content) {
+                               } else if (allow_content &&
+                                          (v = gnm_expr_top_get_constant (texpr)) &&
+                                          VALUE_IS_STRING (v)) {
                                        gboolean white_written = TRUE;
                                        char const *str;
                                        GogText *text;
                                        g_object_set (G_OBJECT (state->xml), "pretty-print", FALSE, NULL);
                                        gsf_xml_out_start_element (state->xml, TEXT "p");
-                                       str = value_peek_string (texpr->expr->constant.value);
+                                       str = value_peek_string (v);
                                        if (GOG_IS_TEXT (title) &&
                                            (text = GOG_TEXT (title))->allow_markup) {
                                                PangoAttrList *attr_list = NULL;
@@ -7096,116 +7096,118 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
        char const *image_types[] =
                {"stretch", "repeat", "no-repeat"};
        
-       if (style != NULL) {
-               if (state->with_extension && style->fill.auto_type) {
-                       odf_add_bool (state->xml, GNMSTYLE "auto-type", TRUE);
-               } else
-                       switch (style->fill.type) {
-                       case GO_STYLE_FILL_NONE:
-                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
-                               break;
-                       case GO_STYLE_FILL_PATTERN:
-                               if (style->fill.pattern.pattern == GO_PATTERN_SOLID) {
-                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
-                                       if (!style->fill.auto_back) {
-                                               char *color = odf_go_color_to_string 
(style->fill.pattern.back);
-                                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
-                                               odf_add_percent (state->xml, DRAW "opacity",
-                                                                odf_go_color_opacity 
(style->fill.pattern.back));
-                                               g_free (color);
-                                       }
-                               } else if (style->fill.pattern.pattern == GO_PATTERN_FOREGROUND_SOLID) {
-                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
-                                       if (!style->fill.auto_fore) {
-                                               char *color = odf_go_color_to_string 
(style->fill.pattern.fore);
-                                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
-                                               odf_add_percent (state->xml, DRAW "opacity",
-                                                                odf_go_color_opacity 
(style->fill.pattern.fore));
-                                               g_free (color);
-                                       }
-                               } else {
-                                       gchar *hatch = odf_get_pattern_name (state, style);
-                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "hatch");
-                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-hatch-name",
-                                                             hatch);
-                                       if (!style->fill.auto_back) {
-                                               char *color = odf_go_color_to_string 
(style->fill.pattern.back);
-                                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
-                                               odf_add_percent (state->xml, DRAW "opacity",
-                                                                odf_go_color_opacity 
(style->fill.pattern.back));
-                                               g_free (color);
-                                       }
-                                       g_free (hatch);
-                                       odf_add_bool (state->xml, DRAW "fill-hatch-solid", TRUE);
-                                       if (state->with_extension)
-                                               gsf_xml_out_add_int
-                                                       (state->xml,
-                                                        GNMSTYLE "pattern",
-                                                        style->fill.pattern.pattern);
+       if (!style)
+               return;
+
+       if (state->with_extension && style->fill.auto_type) {
+               odf_add_bool (state->xml, GNMSTYLE "auto-type", TRUE);
+       } else {
+               switch (style->fill.type) {
+               case GO_STYLE_FILL_NONE:
+                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
+                       break;
+               case GO_STYLE_FILL_PATTERN:
+                       if (style->fill.pattern.pattern == GO_PATTERN_SOLID) {
+                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
+                               if (!style->fill.auto_back) {
+                                       char *color = odf_go_color_to_string (style->fill.pattern.back);
+                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
+                                       odf_add_percent (state->xml, DRAW "opacity",
+                                                        odf_go_color_opacity (style->fill.pattern.back));
+                                       g_free (color);
                                }
-                               break;
-                       case GO_STYLE_FILL_GRADIENT: {
-                               gchar *grad = odf_get_gradient_name (state, style);
-                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "gradient");
-                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-gradient-name", grad);
-                               g_free (grad);
-                               break;
-                       }
-                       case GO_STYLE_FILL_IMAGE: {
-                               gchar *image = odf_get_image_name (state, style);
-                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "bitmap");
-                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-image-name", image);
-                               g_free (image);
-                               if (style->fill.image.type < G_N_ELEMENTS (image_types))
-                                       gsf_xml_out_add_cstr (state->xml, STYLE "repeat",
-                                                             image_types [style->fill.image.type]);
-                               else g_warning ("Unexpected GOImageType value");
-                               break;
-                       }
+                       } else if (style->fill.pattern.pattern == GO_PATTERN_FOREGROUND_SOLID) {
+                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
+                               if (!style->fill.auto_fore) {
+                                       char *color = odf_go_color_to_string (style->fill.pattern.fore);
+                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
+                                       odf_add_percent (state->xml, DRAW "opacity",
+                                                        odf_go_color_opacity (style->fill.pattern.fore));
+                                       g_free (color);
+                               }
+                       } else {
+                               gchar *hatch = odf_get_pattern_name (state, style);
+                               gsf_xml_out_add_cstr (state->xml, DRAW "fill", "hatch");
+                               gsf_xml_out_add_cstr (state->xml, DRAW "fill-hatch-name",
+                                                     hatch);
+                               if (!style->fill.auto_back) {
+                                       char *color = odf_go_color_to_string (style->fill.pattern.back);
+                                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
+                                       odf_add_percent (state->xml, DRAW "opacity",
+                                                        odf_go_color_opacity (style->fill.pattern.back));
+                                       g_free (color);
+                               }
+                               g_free (hatch);
+                               odf_add_bool (state->xml, DRAW "fill-hatch-solid", TRUE);
+                               if (state->with_extension)
+                                       gsf_xml_out_add_int
+                                               (state->xml,
+                                                GNMSTYLE "pattern",
+                                                style->fill.pattern.pattern);
                        }
+                       break;
+               case GO_STYLE_FILL_GRADIENT: {
+                       gchar *grad = odf_get_gradient_name (state, style);
+                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "gradient");
+                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-gradient-name", grad);
+                       g_free (grad);
+                       break;
+               }
+               case GO_STYLE_FILL_IMAGE: {
+                       gchar *image = odf_get_image_name (state, style);
+                       gsf_xml_out_add_cstr (state->xml, DRAW "fill", "bitmap");
+                       gsf_xml_out_add_cstr (state->xml, DRAW "fill-image-name", image);
+                       g_free (image);
+                       if (style->fill.image.type < G_N_ELEMENTS (image_types))
+                               gsf_xml_out_add_cstr (state->xml, STYLE "repeat",
+                                                     image_types [style->fill.image.type]);
+                       else g_warning ("Unexpected GOImageType value");
+                       break;
+               }
+               }
+       }
 
-               if (go_style_is_line_visible (style)) {
-                       GOLineDashType dash_type = style->line.dash_type;
+       if (go_style_is_line_visible (style)) {
+               GOLineDashType dash_type = style->line.dash_type;
 
-                       if (dash_type == GO_LINE_SOLID)
-                               gsf_xml_out_add_cstr (state->xml,
-                                                     DRAW "stroke", "solid");
-                       else {
-                               char const *dash = go_line_dash_as_str (dash_type);
-                               gsf_xml_out_add_cstr (state->xml,
-                                                     DRAW "stroke", "dash");
-                               gsf_xml_out_add_cstr
-                                       (state->xml,
-                                        DRAW "stroke-dash", dash);
-                               g_hash_table_insert (state->graph_dashes, g_strdup (dash),
-                                                    GINT_TO_POINTER (dash_type));
-                       }
-                       if (style->line.auto_dash && state->with_extension)
-                               odf_add_bool (state->xml, GNMSTYLE "auto-dash", TRUE);
-                       if (style->line.width == 0.0) {
-                               odf_add_pt (state->xml, SVG "stroke-width", 1.);
-                               if (state->with_extension)
-                                       odf_add_pt (state->xml, GNMSTYLE "stroke-width", 0.);
-                       } else if (style->line.width > 0.0)
-                               odf_add_pt (state->xml, SVG "stroke-width",
-                                           style->line.width);
-                       if (!style->line.auto_color) {
-                               char *color = odf_go_color_to_string (style->line.color);
-                               gsf_xml_out_add_cstr (state->xml, SVG "stroke-color",
-                                                     color);
-                               g_free (color);
-                       } else if (state->with_extension)
-                               odf_add_bool (state->xml, GNMSTYLE "auto-color", TRUE);         
-               } else {
-                       gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
+               if (dash_type == GO_LINE_SOLID)
+                       gsf_xml_out_add_cstr (state->xml,
+                                             DRAW "stroke", "solid");
+               else {
+                       char const *dash = go_line_dash_as_str (dash_type);
+                       gsf_xml_out_add_cstr (state->xml,
+                                             DRAW "stroke", "dash");
+                       gsf_xml_out_add_cstr
+                               (state->xml,
+                                DRAW "stroke-dash", dash);
+                       g_hash_table_insert (state->graph_dashes, g_strdup (dash),
+                                            GINT_TO_POINTER (dash_type));
                }
+               if (style->line.auto_dash && state->with_extension)
+                       odf_add_bool (state->xml, GNMSTYLE "auto-dash", TRUE);
+               if (style->line.width == 0.0) {
+                       odf_add_pt (state->xml, SVG "stroke-width", 1.);
+                       if (state->with_extension)
+                               odf_add_pt (state->xml, GNMSTYLE "stroke-width", 0.);
+               } else if (style->line.width > 0.0)
+                       odf_add_pt (state->xml, SVG "stroke-width",
+                                   style->line.width);
+               if (!style->line.auto_color) {
+                       char *color = odf_go_color_to_string (style->line.color);
+                       gsf_xml_out_add_cstr (state->xml, SVG "stroke-color",
+                                             color);
+                       g_free (color);
+               } else if (state->with_extension)
+                       odf_add_bool (state->xml, GNMSTYLE "auto-color", TRUE);         
+       } else {
+               gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
+       }
 
-               if (with_border && go_style_is_outline_visible (style)) {
-                       char *border = odf_get_border_info (state, style);
-                       if (strlen (border) > 0)
-                               gsf_xml_out_add_cstr (state->xml, FOSTYLE "border", border);
-                       g_free (border);
-               }
+       if (with_border && go_style_is_outline_visible (style)) {
+               char *border = odf_get_border_info (state, style);
+               if (strlen (border) > 0)
+                       gsf_xml_out_add_cstr (state->xml, FOSTYLE "border", border);
+               g_free (border);
        }
 }
 
@@ -7221,6 +7223,12 @@ odf_write_gog_style_text (GnmOOExport *state, GOStyle const *style)
                        odf_add_angle (state->xml, STYLE "text-rotation-angle", val);
                }
 
+               if (!style->font.auto_color) {
+                       char *color = odf_go_color_to_string (style->font.color);
+                       gsf_xml_out_add_cstr (state->xml, FOSTYLE "color", color);
+                       g_free (color);
+               }
+
                if (mask & PANGO_FONT_MASK_SIZE)
                        odf_add_pt (state->xml, FOSTYLE "font-size",
                                    pango_font_description_get_size


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]