[gnumeric] Fix ODF viewport roundtrip issue. [#724761]



commit 7e102e703332ea5a91d8f57756d7c21af573d6e8
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Feb 20 12:44:08 2014 -0700

    Fix ODF viewport roundtrip issue. [#724761]
    
    2014-02-20  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_apply_ooo_table_config): set viewport
        (openoffice_file_open): use some ooo configs even if we have
        foreign elements

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    6 +++
 plugins/openoffice/openoffice-read.c |   58 +++++++++++++++++++++------------
 3 files changed, 44 insertions(+), 21 deletions(-)
---
diff --git a/NEWS b/NEWS
index 038814e..a6a58fb 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
        * Fix ODF number roundtrip issue. [part of #724568]
        * Fix ODF error constant roundtrip issue. [part of #724568]
        * Fix import of underlines from LO-generated ODF files. [part of #724763]
+       * Fix ODF viewport roundtrip issue. [#724761]
 
 Jean:
        * Fix persistence of hyperlinks tips. [see #724108]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 7897497..6628d39 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
 2014-02-20  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+       * openoffice-read.c (odf_apply_ooo_table_config): set viewport
+       (openoffice_file_open): use some ooo configs even if we have
+       foreign elements
+
+2014-02-20  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * openoffice-write.c (odf_write_ooo_settings): write viewport (topleft)
        position
 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 89abad1..d7c97c5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -10400,37 +10400,52 @@ odf_apply_ooo_table_config (char const *key, GValue *val, OOParseState *state)
                GHashTable *hash = g_value_get_boxed (val);
                Sheet *sheet = workbook_sheet_by_name (state->pos.wb, key);
                if (hash != NULL && sheet != NULL) {
-                       GValue *item = g_hash_table_lookup (hash, "TabColor");
-                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
-                               GOColor color = g_value_get_int (item);
-                               color = color << 8;
-                               sheet->tab_color = gnm_color_new_go (color);
+                       GValue *item;
+                       if (!odf_has_gnm_foreign (state)) {
+                               item = g_hash_table_lookup (hash, "TabColor");
+                               if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
+                                       GOColor color = g_value_get_int (item);
+                                       color = color << 8;
+                                       sheet->tab_color = gnm_color_new_go (color);
+                               }
+                               item = g_hash_table_lookup (hash, "CursorPositionX");
+                               if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
+                                       GValue *itemy = g_hash_table_lookup (hash, "CursorPositionY");
+                                       if (itemy != NULL && G_VALUE_HOLDS(itemy, G_TYPE_INT)) {
+                                               GnmCellPos pos;
+                                               SheetView *sv
+                                                       = sheet_get_view (sheet, state->wb_view);
+                                               GnmRange r;
+                                               pos.col = g_value_get_int (item);
+                                               pos.row = g_value_get_int (itemy);
+                                               r.start = pos;
+                                               r.end = pos;
+
+                                               sv_selection_reset (sv);
+                                               sv_selection_add_range (sv, &r);
+                                               sv_set_edit_pos
+                                                       (sheet_get_view (sheet, state->wb_view),
+                                                        &pos);
+                                       }
+                               }
                        }
-                       item = g_hash_table_lookup (hash, "CursorPositionX");
+                       item = g_hash_table_lookup (hash, "PositionLeft");
                        if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
-                               GValue *itemy = g_hash_table_lookup (hash, "CursorPositionY");
+                               GValue *itemy = g_hash_table_lookup (hash, "PositionBottom");
                                if (itemy != NULL && G_VALUE_HOLDS(itemy, G_TYPE_INT)) {
+                                       SheetView *sv = sheet_get_view (sheet, state->wb_view);
                                        GnmCellPos pos;
-                                       SheetView *sv
-                                               = sheet_get_view (sheet, state->wb_view);
-                                       GnmRange r;
                                        pos.col = g_value_get_int (item);
                                        pos.row = g_value_get_int (itemy);
-                                       r.start = pos;
-                                       r.end = pos;
-
-                                       sv_selection_reset (sv);
-                                       sv_selection_add_range (sv, &r);
-                                       sv_set_edit_pos
-                                               (sheet_get_view (sheet, state->wb_view),
-                                                &pos);
+                                       sv_set_initial_top_left
+                                               (sv, pos.col, pos.row);
                                }
                        }
+                       
                }
        }
 }
 
-
 static void
 odf_apply_ooo_config (OOParseState *state)
 {
@@ -12730,12 +12745,13 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
                        g_hash_table_foreach (state.settings.settings,
                                              (GHFunc)dump_settings_hash, (char *)"");
                if (!odf_has_gnm_foreign (&state)) {
-                       odf_apply_ooo_config (&state);
                        filesaver = odf_created_by_gnumeric (&state) ?
                                "Gnumeric_OpenCalc:openoffice"
                                : "Gnumeric_OpenCalc:odf";
-               } else
+               } else {
                        filesaver = "Gnumeric_OpenCalc:odf";
+               }
+               odf_apply_ooo_config (&state);
                odf_apply_gnm_config (&state);
 
                workbook_set_saveinfo (state.pos.wb, GO_FILE_FL_AUTO,


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