[gnumeric] Fix ODF pattern roundtrip issue. [#724898]



commit a5c95078ecb21204413be1392baa3337ade07b30
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri Feb 21 23:59:32 2014 -0700

    Fix ODF pattern roundtrip issue. [#724898]
    
    2014-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_style_prop_cell): read new foreign elements
        * openoffice-write.c (odf_write_style_cell_properties): write
        foreign elements to describe pattern cell background fills

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    6 ++++++
 plugins/openoffice/openoffice-read.c  |   14 +++++++++++++-
 plugins/openoffice/openoffice-write.c |   17 +++++++++++++----
 4 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index c3d8f9e..248310d 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
        * Fix import of underlines from LO-generated ODF files. [part of #724763]
        * Fix ODF viewport roundtrip issue. [#724761]
        * Fix ODF pagesetup roundtrip issue. [#724516]
+       * Fix ODF pattern roundtrip issue. [#724898]
 
 Jean:
        * Fix persistence of hyperlinks tips. [see #724108]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ed20fcd..d3484c4 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_style_prop_cell): read new foreign elements
+       * openoffice-write.c (odf_write_style_cell_properties): write
+       foreign elements to describe pattern cell background fills
+
 2014-02-20  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-write.c (odf_render_date*): don't create an unnecessary
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d15e697..f662a8a 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6142,7 +6142,8 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
                { NULL, 0 },
        };
        OOParseState *state = (OOParseState *)xin->user_state;
-       GnmColor *color;
+       GnmColor *color, *gnm_b_color = NULL, *gnm_p_color = NULL;
+       int gnm_pattern = 0;
        GnmStyle *style = state->cur_style.cells->style;
        gboolean  btmp;
        int       tmp;
@@ -6162,6 +6163,11 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
                                gnm_style_set_pattern (style, 0);
                        else
                                gnm_style_set_pattern (style, 1);
+               } else if ((color = oo_attr_color (xin, attrs, OO_GNUM_NS_EXT, "background-colour"))) {
+                       gnm_b_color = color;
+               } else if ((color = oo_attr_color (xin, attrs, OO_GNUM_NS_EXT, "pattern-colour"))) {
+                       gnm_p_color = color;
+               } else if (oo_attr_int (xin, attrs, OO_GNUM_NS_EXT, "pattern", &gnm_pattern)) {
                } else if ((color = oo_attr_color (xin, attrs, OO_NS_FO, "color")))
                        gnm_style_set_font_color (style, color);
                else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "cell-protect", protections, &tmp)) {
@@ -6280,6 +6286,12 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
 
                gnm_style_set_font_uline (style, underline);
        }
+       
+       if (gnm_pattern > 0) {
+               gnm_style_set_pattern (style, gnm_pattern);
+               gnm_style_set_back_color (style, gnm_b_color);
+               gnm_style_set_pattern_color (style, gnm_p_color);
+       }
 }
 
 static OOPageBreakType
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 55176ee..bfb05fd 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1180,11 +1180,20 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
 
        gsf_xml_out_start_element (state->xml, STYLE "table-cell-properties");
 /* Background Color */
-       if (gnm_style_is_element_set (style, MSTYLE_COLOR_BACK))
+       if (gnm_style_is_element_set (style, MSTYLE_COLOR_BACK)) {
+               gboolean pattern_set = gnm_style_is_element_set (style, MSTYLE_PATTERN);
+               int pattern = pattern_set ? gnm_style_get_pattern (style) : 1;
+
                gnm_xml_out_add_hex_color (state->xml, FOSTYLE "background-color",
-                                          gnm_style_get_back_color (style),
-                                          gnm_style_is_element_set (style, MSTYLE_PATTERN) ?
-                                          gnm_style_get_pattern (style) : 1);
+                                          gnm_style_get_back_color (style), pattern);
+               if (state->with_extension && pattern_set && pattern != 0) {
+                       gnm_xml_out_add_hex_color (state->xml, GNMSTYLE "background-colour",
+                                                  gnm_style_get_back_color (style), 1);
+                       gnm_xml_out_add_hex_color (state->xml, GNMSTYLE "pattern-colour",
+                                                  gnm_style_get_pattern_color (style), 1);
+                       gsf_xml_out_add_int (state->xml, GNMSTYLE "pattern", pattern);
+               }
+       }
 /* Borders */
        BORDERSTYLE(MSTYLE_BORDER_TOP,FOSTYLE "border-top", STYLE "border-line-width-top", GNMSTYLE 
"border-line-style-top");
        BORDERSTYLE(MSTYLE_BORDER_BOTTOM,FOSTYLE "border-bottom", STYLE "border-line-width-bottom", GNMSTYLE 
"border-line-style-bottom");


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