[gnumeric] Export frozen panes info to and import from ODF. [#725228]



commit be2de3aa0f501f9f3c8aad4344fbb820f8ad94ad
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Feb 27 09:06:26 2014 -0700

    Export frozen panes info to and import from ODF. [#725228]
    
    2014-02-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_config_item): read shorts
        (odf_apply_ooo_table_config): handle frozen panes info

 NEWS                                 |    2 +-
 plugins/openoffice/ChangeLog         |    5 +++
 plugins/openoffice/openoffice-read.c |   54 ++++++++++++++++++++++++---------
 3 files changed, 45 insertions(+), 16 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5dfe0e1..9c3c652 100644
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,7 @@ Andreas:
        * Fix ODF pagesetup roundtrip issue. [#724516]
        * Fix ODF pattern roundtrip issue. [#724898]
        * Export row and column visibility to ODF. [#725115]
-       * Export frozen panes info to ODF.
+       * Export frozen panes info to and import from ODF. [#725228]
 
 Jean:
        * Fix persistence of hyperlinks tips. [see #724108]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 4034255..3e74a38 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (odf_config_item): read shorts
+       (odf_apply_ooo_table_config): handle frozen panes info
+
 2014-02-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-write.c (odf_write_ooo_settings): write frozen panes
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index f662a8a..de0b931 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -10264,7 +10264,7 @@ odf_config_item (GsfXMLIn *xin, xmlChar const **attrs)
                {"double", G_TYPE_INVALID},
                {"int", G_TYPE_INT},
                {"long", G_TYPE_LONG},
-               {"short", G_TYPE_INVALID},
+               {"short", G_TYPE_INT},
                {"string", G_TYPE_STRING},
                { NULL, 0},
        };
@@ -10410,8 +10410,14 @@ odf_apply_ooo_table_config (char const *key, GValue *val, OOParseState *state)
        if (G_VALUE_HOLDS(val,G_TYPE_HASH_TABLE)) {
                GHashTable *hash = g_value_get_boxed (val);
                Sheet *sheet = workbook_sheet_by_name (state->pos.wb, key);
+
                if (hash != NULL && sheet != NULL) {
+                       SheetView *sv = sheet_get_view (sheet, state->wb_view);
+                       GnmCellPos pos;
                        GValue *item;
+                       int pos_left = 0, pos_bottom = 0;
+                       int vsm = 0, hsm = 0, vsp = -1, hsp = -1;
+
                        if (!odf_has_gnm_foreign (state)) {
                                item = g_hash_table_lookup (hash, "TabColor");
                                if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
@@ -10423,9 +10429,6 @@ odf_apply_ooo_table_config (char const *key, GValue *val, OOParseState *state)
                                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);
@@ -10440,19 +10443,40 @@ odf_apply_ooo_table_config (char const *key, GValue *val, OOParseState *state)
                                        }
                                }
                        }
-                       item = g_hash_table_lookup (hash, "PositionLeft");
-                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT)) {
-                               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;
-                                       pos.col = g_value_get_int (item);
-                                       pos.row = g_value_get_int (itemy);
-                                       sv_set_initial_top_left
-                                               (sv, pos.col, pos.row);
+
+                       item = g_hash_table_lookup (hash, "HorizontalSplitMode");
+                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                               vsm = g_value_get_int (item);
+                       item = g_hash_table_lookup (hash, "VerticalSplitMode");
+                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                               hsm = g_value_get_int (item);
+
+                       if (vsm > 0 || hsm > 0)  {
+                               item = g_hash_table_lookup (hash, "VerticalSplitPosition");
+                               if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                                       vsp = g_value_get_int (item);
+                               item = g_hash_table_lookup (hash, "HorizontalSplitPosition");
+                               if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                                       hsp = g_value_get_int (item);
+                               if (vsp > 0 || hsp > 0) {
+                                       GnmCellPos fpos = {0, 0};
+                                       pos.col = hsp;
+                                       pos.row = vsp;
+                                       sv_freeze_panes (sv, &fpos, &pos);
                                }
+                                       
+                               item = g_hash_table_lookup (hash, "PositionRight");
+                       } else {
+                               item = g_hash_table_lookup (hash, "PositionLeft");
                        }
-                       
+                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                               pos_left = g_value_get_int (item);
+
+                       item = g_hash_table_lookup (hash, "PositionBottom");
+                       if (item != NULL && G_VALUE_HOLDS(item, G_TYPE_INT))
+                               pos_bottom = g_value_get_int (item);
+
+                       sv_set_initial_top_left (sv, pos_left, pos_bottom);             
                }
        }
 }


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