diff options
-rw-r--r-- | sc/inc/address.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpdefaults.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaapplication.cxx | 5 |
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 |