[gnumeric] Names: fix problem parsing global names.



commit 632b8ba4f86b420ee3552c6fa5f8db710d4a3bbc
Author: Morten Welinder <terra gnome org>
Date:   Sat Jul 4 16:52:28 2020 -0400

    Names: fix problem parsing global names.
    
    Only relevant if sheets are not uniformly sized.

 NEWS           |  1 +
 src/workbook.c | 28 +++++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 08e603dc5..878eefc8b 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Morten:
        * Fix format dialog issue.  [#503]
        * Re-tune style quad tree.  [#234]
        * Re-tune dependency bucket system.  [#502]
+       * Fix global name parsing problem with non-uniform sheet sizing.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.47
diff --git a/src/workbook.c b/src/workbook.c
index 07e9a63b8..d58dd1b62 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -1400,15 +1400,33 @@ workbook_set_1904 (Workbook *wb, gboolean base1904)
 GnmSheetSize const *
 workbook_get_sheet_size (Workbook const *wb)
 {
-       if (wb == NULL || workbook_sheet_count (wb) == 0) {
-               static const GnmSheetSize max_size = {
-                       GNM_MAX_COLS, GNM_MAX_ROWS
-               };
+       GnmSheetSize res;
+       static const GnmSheetSize max_size = {
+               GNM_MAX_COLS, GNM_MAX_ROWS
+       };
 
+       int i, n;
+       gboolean uniform = TRUE;
+
+       n = wb ? workbook_sheet_count (wb) : 0;
+       if (n == 0)
                return &max_size;
+
+       res = *gnm_sheet_get_size (workbook_sheet_by_index (wb, 0));
+       for (i = 1; i < n; i++) {
+               Sheet *sheet = workbook_sheet_by_index (wb, i);
+               GnmSheetSize const *ss = gnm_sheet_get_size (sheet);
+               if (ss->max_cols != res.max_cols ||
+                   ss->max_rows != res.max_rows) {
+                       uniform = FALSE;
+                       break;
+               }
        }
 
-       return gnm_sheet_get_size (workbook_sheet_by_index (wb, 0));
+       if (uniform)
+               return gnm_sheet_get_size (workbook_sheet_by_index (wb, 0));
+       else
+               return &max_size; // It's unclear what to do
 }
 
 /* ------------------------------------------------------------------------- */


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