[gnumeric] Fix legend placement in ODF import. [#698535]



commit 2275db23664bfdef528866b6854ea8f066c1240a
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun Apr 21 23:57:48 2013 -0600

    Fix legend placement in ODF import. [#698535]
    
    2013-04-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_chart_title_end): fix typo
        (oo_legend): read location specifier

 NEWS                                 |  1 +
 plugins/openoffice/ChangeLog         |  5 +++++
 plugins/openoffice/openoffice-read.c | 22 +++++++++++++++++++---
 3 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 25a6748..35b883b 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Andreas:
        * Fix angle import of ODF graphs. [#698389]
        * Don't insert ODF local tables as sheets. [#698388]
        * Improve import of header/footer info from ODF.
+       * Fix legend placement in ODF import. [#698535]
 
 Dominique Leuenberger:
        * Fix locale directory.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 45d501a..3c7212f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_chart_title_end): fix typo
+       (oo_legend): read location specifier
+
 2013-04-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (df_hf_item_start): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 7be6eba..3e1a059 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -7944,7 +7944,7 @@ oo_chart_title_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
                              "is-position-manual", state->chart.title_manual_pos,
                              NULL);
                if (state->chart.title_manual_pos) {
-                       if (go_finite (state->chart.width) && (state->chart.height)) {
+                       if (go_finite (state->chart.width) && go_finite (state->chart.height)) {
                                GogViewAllocation alloc;
                                alloc.x = state->chart.title_x / state->chart.width;
                                alloc.w = 0;
@@ -8916,6 +8916,7 @@ oo_legend (GsfXMLIn *xin, xmlChar const **attrs)
        GogObject *legend;
        int tmp;
        char const *style_name = NULL;
+       double x = go_nan, y = go_nan;
 
        for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
                if (oo_attr_enum (xin, attrs, OO_NS_CHART, "legend-position", positions, &tmp))
@@ -8924,12 +8925,14 @@ oo_legend (GsfXMLIn *xin, xmlChar const **attrs)
                        align = tmp;
                else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "style-name"))
                        style_name = CXML2C (attrs[1]);
+               else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_SVG, "x"))
+                       oo_parse_distance (xin, attrs[1], "x", &x);
+               else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_SVG, "y"))
+                       oo_parse_distance (xin, attrs[1], "y", &y);
 
        legend = gog_object_add_by_name ((GogObject *)state->chart.chart, "Legend", NULL);
        state->chart.legend = legend;
        if (legend != NULL) {
-               gog_object_set_position_flags (legend, pos | align,
-                                              GOG_POSITION_COMPASS | GOG_POSITION_ALIGNMENT);
                if (style_name) {
                        GOStyle *style = NULL;
                        g_object_get (G_OBJECT (legend), "style", &style, NULL);
@@ -8940,6 +8943,19 @@ oo_legend (GsfXMLIn *xin, xmlChar const **attrs)
                                g_object_unref (style);
                        }
                }
+               if (go_finite (x) && go_finite (y) && go_finite (state->chart.width) && go_finite 
(state->chart.height)) {
+                       GogViewAllocation alloc;
+                       alloc.x = x / state->chart.width;
+                       alloc.w = 0;
+                       alloc.y = y / state->chart.height;
+                       alloc.h = 0;
+                       
+                       gog_object_set_position_flags (legend, GOG_POSITION_MANUAL, GOG_POSITION_ANY_MANUAL);
+                       gog_object_set_manual_position (legend, &alloc);                        
+               } else
+                       gog_object_set_position_flags (legend, pos | align,
+                                                      GOG_POSITION_COMPASS | GOG_POSITION_ALIGNMENT);
+                       
        }
 }
 


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