[gnumeric] Fix fill-alignment export/import to and from ODF. [part of #726035]



commit 0f33c9e28522ac5e61b72ef50e837fb3333599a1
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue Mar 11 23:44:21 2014 -0600

    Fix fill-alignment export/import to and from ODF. [part of #726035]
    
    2014-03-11  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_style_end): set alignment once
        (odf_style_set_align_h): use repeat_content even if the
        source is not set to 'fix'
        (oo_style_prop_cell): don't set teh alignment here
        * openoffice-write.c (odf_write_cell): write a string-value
        if repeat-content will be set to true

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    9 ++++++++
 plugins/openoffice/openoffice-read.c  |   35 +++++++++++++++++----------------
 plugins/openoffice/openoffice-write.c |    5 ++-
 4 files changed, 31 insertions(+), 19 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6a1684e..75f9dc5 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Andreas:
        * Fix export of help messages to ODF.
        * Import invisible alignment characters in number formats from ODF.
          [part of #725852]
+       * Fix fill-alignment export/import to and from ODF. [part of #726035]
 
 Morten:
        * Support volatile functions.  [#305798]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ed694f8..3a3baa4 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,12 @@
+2014-03-11  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_style_end): set alignment once
+       (odf_style_set_align_h): use repeat_content even if the
+       source is not set to 'fix'
+       (oo_style_prop_cell): don't set teh alignment here
+       * openoffice-write.c (odf_write_cell): write a string-value
+       if repeat-content will be set to true
+
 2014-03-10  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (oo_date_text_append_quoted): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 799280d..576b13f 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4556,6 +4556,9 @@ oo_style (GsfXMLIn *xin, xmlChar const **attrs)
        }
 }
 
+static void odf_style_set_align_h (GnmStyle *style, gboolean h_align_is_valid, gboolean repeat_content,
+                                  int text_align, int gnm_halign);
+
 static void
 oo_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
@@ -4564,6 +4567,10 @@ oo_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        switch (state->cur_style.type) {
        case OO_STYLE_CELL :
                if (state->cur_style.cells != NULL) {
+                       odf_style_set_align_h (state->cur_style.cells->style, 
+                                              state->h_align_is_valid, 
+                                              state->repeat_content,
+                                              state->text_align, state->gnm_halign);
                        odf_oo_cell_style_unref (state->cur_style.cells);
                        state->cur_style.cells = NULL;
                }
@@ -6152,10 +6159,12 @@ odf_style_set_align_h (GnmStyle *style, gboolean h_align_is_valid, gboolean repe
                       int text_align, int gnm_halign)
 {
        int alignment = GNM_HALIGN_GENERAL;
-       if (h_align_is_valid)
-               alignment = repeat_content ? GNM_HALIGN_FILL
-                       : ((text_align < 0) ? ((gnm_halign > -1) ? gnm_halign : GNM_HALIGN_LEFT)
-                          : text_align);
+
+       if (repeat_content)
+               alignment = GNM_HALIGN_FILL;
+       else if (h_align_is_valid)
+               alignment = ((text_align < 0) ? ((gnm_halign > -1) ? gnm_halign : GNM_HALIGN_LEFT)
+                            : text_align);
 
        gnm_style_set_align_h (style, alignment);
 }
@@ -6257,23 +6266,15 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
                        gnm_style_set_contents_hidden (style, (tmp & 1) != 0);
                } else if (oo_attr_enum (xin, attrs,
                                       (state->ver >= OOO_VER_OPENDOC) ? OO_NS_FO : OO_NS_STYLE,
-                                        "text-align", h_alignments, &(state->text_align)))
+                                        "text-align", h_alignments, &(state->text_align))) {
                        /* Note that style:text-align-source, style:text_align, style:repeat-content  */
                        /* and gnm:GnmHAlign interact but can appear in any order and arrive from different */
                        /* elements, so we can't use local variables                                  */
-                       odf_style_set_align_h (style, state->h_align_is_valid, state->repeat_content,
-                                              state->text_align, state->gnm_halign);
-               else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-align-source")) {
+               } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-align-source")) {
                        state->h_align_is_valid = attr_eq (attrs[1], "fix");
-                       odf_style_set_align_h (style, state->h_align_is_valid, state->repeat_content,
-                                              state->text_align, state->gnm_halign);
-               } else if (oo_attr_bool (xin, attrs, OO_NS_STYLE, "repeat-content", &(state->repeat_content)))
-                       odf_style_set_align_h (style, state->h_align_is_valid, state->repeat_content,
-                                              state->text_align, state->gnm_halign);
-               else if (oo_attr_int (xin,attrs, OO_GNUM_NS_EXT, "GnmHAlign", &(state->gnm_halign)))
-                       odf_style_set_align_h (style, state->h_align_is_valid, state->repeat_content,
-                                              state->text_align, state->gnm_halign);
-               else if (oo_attr_enum (xin, attrs,
+               } else if (oo_attr_bool (xin, attrs, OO_NS_STYLE, "repeat-content", 
&(state->repeat_content))) {
+               } else if (oo_attr_int (xin,attrs, OO_GNUM_NS_EXT, "GnmHAlign", &(state->gnm_halign))) {
+               }else if (oo_attr_enum (xin, attrs,
                                       (state->ver >= OOO_VER_OPENDOC) ? OO_NS_STYLE : OO_NS_FO,
                                       "vertical-align", v_alignments, &tmp)) {
                        if (tmp != -1) {
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index b8fef25..ce6bee8 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3432,8 +3432,9 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
                case VALUE_STRING:
                        gsf_xml_out_add_cstr_unchecked (state->xml,
                                                        OFFICE "value-type", "string");
-                       /*If this is a non-formula cell we show the real formatted content */
-                       if (NULL != cell->base.texpr)
+                       /* If this is a non-formula cell we show only the real formatted content */
+                       /* If the alignmnet type is 'FILL' we do need to give the string value!  */
+                       if (NULL != cell->base.texpr || gnm_style_get_align_h (style) == GNM_HALIGN_FILL)
                                gsf_xml_out_add_cstr (state->xml,
                                                      OFFICE "string-value",
                                                      value_peek_string (cell->value));


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