[gnumeric] Fix distributed-alignment export to ODF. [part of #726035]



commit 5d6311f065372f56cea9e04d43959547d6b19872
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Mar 12 01:07:48 2014 -0600

    Fix distributed-alignment export to ODF. [part of #726035]
    
    2014-03-12  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_style_set_align_h): repeat_content and
        gnm_halign take precedence
        * openoffice-write.c (odf_write_style_cell_properties): write LO's
        version of DISTRIBUTED

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    9 ++++++++-
 plugins/openoffice/openoffice-read.c  |    9 ++++++---
 plugins/openoffice/openoffice-write.c |   11 +++++++++--
 4 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index 75f9dc5..6f4cf2c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
        * Import invisible alignment characters in number formats from ODF.
          [part of #725852]
        * Fix fill-alignment export/import to and from ODF. [part of #726035]
+       * Fix distributed-alignment export to ODF. [part of #726035]
 
 Morten:
        * Support volatile functions.  [#305798]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 3a3baa4..34e721e 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,9 +1,16 @@
+2014-03-12  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (odf_style_set_align_h): repeat_content and
+       gnm_halign take precedence
+       * openoffice-write.c (odf_write_style_cell_properties): write LO's
+       version of DISTRIBUTED
+
 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
+       (oo_style_prop_cell): don't set the alignment here
        * openoffice-write.c (odf_write_cell): write a string-value
        if repeat-content will be set to true
 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 576b13f..8530bdf 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6162,9 +6162,12 @@ odf_style_set_align_h (GnmStyle *style, gboolean h_align_is_valid, gboolean repe
 
        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);
+       else if (h_align_is_valid) {
+               if (gnm_halign > -1)
+                       alignment = gnm_halign;
+               else
+                       alignment = ((text_align < 0) ? GNM_HALIGN_LEFT : text_align);
+       }
 
        gnm_style_set_align_h (style, alignment);
 }
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index ce6bee8..02ae8fc 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -103,6 +103,7 @@
 #define OOO      "ooo:"
 #define TABLEOOO "tableooo:"
 #define XML      "xml:"
+#define CSS      "css3t:"
 #define GNMSTYLE "gnm:"  /* We use this for attributes and elements not supported by ODF */
 
 typedef struct {
@@ -199,6 +200,7 @@ static struct {
        { "xmlns:xsd",          "http://www.w3.org/2001/XMLSchema"; },
        { "xmlns:xsi",          "http://www.w3.org/2001/XMLSchema-instance"; },
        { "xmlns:gnm",          "http://www.gnumeric.org/odf-extension/1.0"},
+       { "xmlns:css3t",        "http://www.w3.org/TR/css3-text/"},
 };
 
 /*****************************************************************************/
@@ -1311,6 +1313,7 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
                GnmHAlign align = gnm_style_get_align_h (style);
                char const *source = NULL;
                switch (align) {
+               case GNM_HALIGN_DISTRIBUTED:
                case GNM_HALIGN_LEFT:
                case GNM_HALIGN_RIGHT:
                case GNM_HALIGN_CENTER:
@@ -1321,7 +1324,6 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
                        rep_content = TRUE;
                case GNM_HALIGN_GENERAL:
                case GNM_HALIGN_CENTER_ACROSS_SELECTION:
-               case GNM_HALIGN_DISTRIBUTED:
                default:
                        /* Note that since source is value-type, alignment should be ignored */
                         /*(but isn't by OOo) */
@@ -1366,11 +1368,14 @@ odf_write_style_paragraph_properties (GnmOOExport *state, GnmStyle const *style)
                case GNM_HALIGN_JUSTIFY:
                        alignment = "justify";
                        break;
+               case GNM_HALIGN_DISTRIBUTED:
+                       alignment = "justify";
+                       gnum_specs = TRUE;
+                       break;
                case GNM_HALIGN_FILL:
                        break;
                case GNM_HALIGN_GENERAL:
                case GNM_HALIGN_CENTER_ACROSS_SELECTION:
-               case GNM_HALIGN_DISTRIBUTED:
                default:
                        /* Note that since source is value-type, alignment should be ignored */
                         /*(but isn't by OOo) */
@@ -1382,6 +1387,8 @@ odf_write_style_paragraph_properties (GnmOOExport *state, GnmStyle const *style)
                        gsf_xml_out_add_cstr (state->xml, FOSTYLE "text-align", alignment);
                if (gnum_specs && state->with_extension)
                        gsf_xml_out_add_int (state->xml, GNMSTYLE "GnmHAlign", align);
+               if (align == GNM_HALIGN_DISTRIBUTED)
+                       gsf_xml_out_add_cstr (state->xml, CSS "text-justify", "distribute");
        }
 
 /* Text Indent */


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