Hi Kohei,
This patch makes the bounds checking of the initial tab count more
consistent with the actual limits.
/Albert
From f15fe62c41aa85b5698141e3d004648a36c642dc Mon Sep 17 00:00:00 2001
From: Albert Thuswaldner <albert.thuswald...@gmail.com>
Date: Wed, 18 Apr 2012 00:31:02 +0200
Subject: [PATCH] Use global constants for initial tab count bounds checking

---
 sc/inc/address.hxx                  |    1 +
 sc/source/ui/optdlg/tpdefaults.cxx  |   11 ++++-------
 sc/source/ui/vba/vbaapplication.cxx |    4 ++--
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 6c45311..8038d6e 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -89,6 +89,7 @@ const SCROW       MAXROWCOUNT    = MAXROWCOUNT_DEFINE;
 const SCCOL       MAXCOLCOUNT    = MAXCOLCOUNT_DEFINE;
 // limiting to 10000 for now, problem with 32 bit builds for now
 const SCTAB       MAXTABCOUNT    = 10000;
+const SCTAB       MINTABCOUNT    = 1;
 const SCCOLROW    MAXCOLROWCOUNT = MAXROWCOUNT;
 // Maximum values
 const SCROW       MAXROW         = MAXROWCOUNT - 1;
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index bc5b988..5f75567 100644
--- a/sc/source/ui/optdlg/tpdefaults.cxx
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -36,9 +36,6 @@
 #include "defaultsoptions.hxx"
 #include "document.hxx"
 
-#define INIT_SHEETS_MIN 1
-#define INIT_SHEETS_MAX 1024
-
 using ::rtl::OUString;
 
 ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCoreSet) :
@@ -119,10 +116,10 @@ int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
 void ScTpDefaultsOptions::CheckNumSheets()
 {
     sal_Int64 nVal = aEdNSheets.GetValue();
-    if (nVal > INIT_SHEETS_MAX)
-        aEdNSheets.SetValue(INIT_SHEETS_MAX);
-    if (nVal < INIT_SHEETS_MIN)
-        aEdNSheets.SetValue(INIT_SHEETS_MIN);
+    if (nVal > MAXTABCOUNT)
+        aEdNSheets.SetValue(MAXTABCOUNT);
+    if (nVal < MINTABCOUNT)
+        aEdNSheets.SetValue(MINTABCOUNT);
 }
 
 void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 478e8f4..0d8ac31 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -945,9 +945,9 @@ sal_Int32 SAL_CALL ScVbaApplication::getSheetsInNewWorkbook() throw (uno::Runtim
 
 void SAL_CALL ScVbaApplication::setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (script::BasicErrorException, uno::RuntimeException)
 {
-    if ( SheetsInNewWorkbook < 1 || SheetsInNewWorkbook > MAXTAB )
+    if ( SheetsInNewWorkbook < MINTABCOUNT || SheetsInNewWorkbook > MAXTABCOUNT )
     {
-        DebugHelper::exception( OUString(RTL_CONSTASCII_USTRINGPARAM("The number must be between 1 and 255")),
+        DebugHelper::exception( OUString(RTL_CONSTASCII_USTRINGPARAM("The number must be between 1 and 10000")),
             uno::Exception(), SbERR_METHOD_FAILED, OUString() );
     }
     else
-- 
1.7.3.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to