[gnumeric] Improve pattern fill round trip through ODF.



commit 5212ffa15f43ab300691c04559a9bfb538d65cb0
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Apr 12 12:29:37 2015 -0600

    Improve pattern fill round trip through ODF.
    
    2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * ods-ext-schema.patch: add gnm:foreground-solid
    
    2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_apply_style_props): read and obey the
        new foreground-solid flag
        * openoffice-write.c (odf_write_gog_style_graphic): write the
        new foreground-solid flag

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    7 +++++++
 plugins/openoffice/openoffice-read.c  |   29 +++++++++++++++++++++++------
 plugins/openoffice/openoffice-write.c |    2 ++
 samples/object-tests.gnumeric         |  Bin 8986 -> 2215 bytes
 test/ChangeLog                        |    4 ++++
 test/ods-ext-schema.patch             |   13 +++++++++----
 7 files changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index 11aa0b6..b430ddb 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Andreas:
        * Harden ODF import against fuzzed files. [#747447][#747448]
        * Fix ODF import/export of unlinked checkboxes and radio buttons.
        * Plug leak in ODF import and export. [#747590]
+       * Improve pattern fill round trip through ODF.
 
 Jean:
        * Fix signal handling while running Python. [#744638]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9bdd41a..def1b0e 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+       * openoffice-read.c (odf_apply_style_props): read and obey the
+       new foreground-solid flag
+       * openoffice-write.c (odf_write_gog_style_graphic): write the
+       new foreground-solid flag
+
+2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * openoffice-write.c (odf_write_image): don't keep image ref
 
 2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index bf7c535..ef30b76 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -554,6 +554,7 @@ static OOFormula odf_get_formula_type (GsfXMLIn *xin, char const **str);
 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);
 
 
 /* Implementations */
@@ -847,7 +848,9 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style, gboolean in
        char const *marker_fill_colour = NULL;
        gboolean gnm_auto_font_set = FALSE;
        gboolean gnm_auto_font = FALSE;
+       gboolean gnm_foreground_solid = FALSE;
 
+       oo_prop_list_has (props, &gnm_foreground_solid, "gnm-foreground-solid");
        style->line.auto_dash = TRUE;
 
        desc = pango_font_description_copy (style->font.font->desc);
@@ -858,7 +861,8 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style, gboolean in
                        if (0 == strcmp (val_string, "solid")) {
                                style->fill.type = GO_STYLE_FILL_PATTERN;
                                style->fill.auto_type = FALSE;
-                               style->fill.pattern.pattern = GO_PATTERN_SOLID;
+                               style->fill.pattern.pattern = (gnm_foreground_solid) ? 
+                                       GO_PATTERN_FOREGROUND_SOLID : GO_PATTERN_SOLID;
                                fill_type = OO_FILL_TYPE_SOLID;
                        } else if (0 == strcmp (val_string, "hatch")) {
                                style->fill.type = GO_STYLE_FILL_PATTERN;
@@ -881,12 +885,20 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style, gboolean in
                        GdkRGBA rgba;
                        gchar const *color = g_value_get_string (&prop->value);
                        if (gdk_rgba_parse (&rgba, color)) {
-                               guint a = GO_COLOR_UINT_A (style->fill.pattern.back);
-                               go_color_from_gdk_rgba (&rgba, &style->fill.pattern.back);
-                               style->fill.auto_back = FALSE;
-                               style->fill.pattern.back = GO_COLOR_CHANGE_A (style->fill.pattern.back, a);
+                               guint a; 
+                               if (gnm_foreground_solid) {
+                                       a = GO_COLOR_UINT_A (style->fill.pattern.fore);
+                                       go_color_from_gdk_rgba (&rgba, &style->fill.pattern.fore);
+                                       style->fill.auto_fore = FALSE;
+                                       style->fill.pattern.fore = GO_COLOR_CHANGE_A 
(style->fill.pattern.fore, a);
+                               } else {
+                                       a = GO_COLOR_UINT_A (style->fill.pattern.back);
+                                       go_color_from_gdk_rgba (&rgba, &style->fill.pattern.back);
+                                       style->fill.auto_back = FALSE;
+                                       style->fill.pattern.back = GO_COLOR_CHANGE_A 
(style->fill.pattern.back, a);
+                               }
                        }
-               } else if (0 == strcmp (prop->name, "opacity")) {
+               }else if (0 == strcmp (prop->name, "opacity")) {
                        guint a = 255 * g_value_get_double (&prop->value);
                        style->fill.pattern.back = GO_COLOR_CHANGE_A (style->fill.pattern.back, a);
                } else if (0 == strcmp (prop->name, "stroke-color")) {
@@ -1008,6 +1020,7 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style, gboolean in
                        gnm_auto_font = g_value_get_boolean (&prop->value);
                } 
        }
+
        if (desc_changed)
                go_style_set_font_desc  (style, desc);
        else
@@ -7311,6 +7324,10 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
                                (style->style_props,
                                 oo_prop_new_string ("fill",
                                                     CXML2C(attrs[1])));
+               else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "foreground-solid", &btmp))
+                       style->style_props = g_slist_prepend
+                               (style->style_props,
+                                oo_prop_new_bool ("gnm-foreground-solid", btmp));
                else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "auto-type", &btmp))
                        style->style_props = g_slist_prepend
                                (style->style_props,
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index a9461ec..915d4a2 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7455,6 +7455,8 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
                                        g_free (color);
                                }
                        } else if (style->fill.pattern.pattern == GO_PATTERN_FOREGROUND_SOLID) {
+                               if (state->with_extension)
+                                       odf_add_bool (state->xml, GNMSTYLE "foreground-solid", TRUE);
                                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);
diff --git a/samples/object-tests.gnumeric b/samples/object-tests.gnumeric
index d2c5a64..58fb1ca 100644
Binary files a/samples/object-tests.gnumeric and b/samples/object-tests.gnumeric differ
diff --git a/test/ChangeLog b/test/ChangeLog
index 7dd1d6f..04665d3 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-12  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * ods-ext-schema.patch: add gnm:foreground-solid
+
 2015-04-12  Morten Welinder  <terra gnome org>
 
        * t6150-ods-syntax.pl: Use default full corpos.
diff --git a/test/ods-ext-schema.patch b/test/ods-ext-schema.patch
index 7e205d6..5bcec03 100644
--- a/test/ods-ext-schema.patch
+++ b/test/ods-ext-schema.patch
@@ -1,5 +1,5 @@
---- ods-schema/OpenDocument-v1.2-os-schema.rng 2015-01-28 18:46:19.155715877 -0500
-+++ ods-schema/OpenDocument-v1.2-os-ext-schema.rng     2015-04-12 14:14:37.624042609 -0400
+--- ods-schema/OpenDocument-v1.2-os-schema.rng 2015-04-08 21:49:54.058918977 -0600
++++ ods-schema/OpenDocument-v1.2-os-ext-schema.rng     2015-04-12 12:20:51.420486277 -0600
 @@ -62,6 +62,9 @@
        xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
        xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
@@ -358,7 +358,7 @@
                                <attribute name="style:diagonal-tl-br">
                                        <ref name="string"/>
                                </attribute>
-@@ -17060,6 +17207,41 @@
+@@ -17060,6 +17207,46 @@
                                        <ref name="nonNegativeInteger"/>
                                </attribute>
                        </optional>
@@ -383,6 +383,11 @@
 +                              </attribute>
 +                      </optional>
 +                      <optional>
++                              <attribute name="gnm:foreground-solid">
++                                      <ref name="boolean"/>
++                              </attribute>
++                      </optional>
++                      <optional>
 +                              <attribute name="gnm:pattern">
 +                                      <ref name="integer"/>
 +                              </attribute>
@@ -400,7 +405,7 @@
                </interleave>
        </define>
        <define name="style-graphic-fill-properties-attlist">
-@@ -18124,4 +18306,78 @@
+@@ -18124,4 +18311,78 @@
                        </element>
                </zeroOrMore>
        </define>


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