summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorAlbert Thuswaldner <albert.thuswaldner@gmail.com>2012-04-18 00:31:02 +0200
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-04-18 14:57:52 -0400
commit670db0daa2ed638ec9df0d5d569d7c43ae1bf786 (patch)
tree0e3f054fd3af26e99fd35e39797c65a9993c98e5 /sc
parentString & bool cleanup. (diff)
downloadcore-670db0daa2ed638ec9df0d5d569d7c43ae1bf786.tar.gz
core-670db0daa2ed638ec9df0d5d569d7c43ae1bf786.zip
Use global constants for initial tab count bounds checking
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx6
-rw-r--r--sc/source/ui/optdlg/tpdefaults.cxx11
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx5
3 files changed, 12 insertions, 10 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 6c453115c02c..182fba145263 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -95,7 +95,11 @@ const SCROW MAXROW = MAXROWCOUNT - 1;
const SCCOL MAXCOL = MAXCOLCOUNT - 1;
const SCTAB MAXTAB = MAXTABCOUNT - 1;
const SCCOLROW MAXCOLROW = MAXROW;
-
+// Limit the initial tab count to prevent users to set the count too high,
+// which could cause the memory usage of blank documents to exceed the
+// available system memory.
+const SCTAB MAXINITTAB = 1024;
+const SCTAB MININITTAB = 1;
// Special values
const SCTAB SC_TAB_APPEND = SCTAB_MAX;
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index bc5b988f3d6b..b67e87be20a3 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 > MAXINITTAB)
+ aEdNSheets.SetValue(MAXINITTAB);
+ if (nVal < MININITTAB)
+ aEdNSheets.SetValue(MININITTAB);
}
void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 478e8f4a51b9..4204ba0d662a 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -945,9 +945,10 @@ 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 < MININITTAB
+ || SheetsInNewWorkbook > MAXINITTAB )
{
- 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