From a687d554774eba1c4bf5a4825e8730cb0114bd3c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 6 Jan 2012 12:43:20 -0500 Subject: Limit the number of initial sheets to 1 to 1024 in the UI. Note that you can still have more than 1024 sheets afterwards. This only applies to new and empty documents. --- sc/source/ui/optdlg/tpdefaults.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sc/source/ui/optdlg') diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx index ae88b2e3b987..bd1cc6847d18 100644 --- a/sc/source/ui/optdlg/tpdefaults.cxx +++ b/sc/source/ui/optdlg/tpdefaults.cxx @@ -35,6 +35,9 @@ #include "scmod.hxx" #include "docoptio.hxx" +#define INIT_SHEETS_MIN 1 +#define INIT_SHEETS_MAX 1024 + ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCoreAttrs) : SfxTabPage(pParent, ScResId(RID_SCPAGE_DEFAULTS), rCoreAttrs), aFLInitSpreadSheet ( this, ScResId( FL_INIT_SPREADSHEET ) ), @@ -46,6 +49,8 @@ ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCor const ScTpCalcItem& rItem = static_cast( rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS))); mpLocalOptions.reset(new ScDocOptions(rItem.GetDocOptions())); + + aEdNSheets.SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) ); } ScTpDefaultsOptions::~ScTpDefaultsOptions() @@ -75,6 +80,7 @@ sal_Bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreAttrs) void ScTpDefaultsOptions::Reset(const SfxItemSet& /*rCoreAttrs*/) { aEdNSheets.SetValue( static_cast(mpLocalOptions->GetInitTabCount()) ); + CheckNumSheets(); } int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/) @@ -82,4 +88,19 @@ int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/) return KEEP_PAGE; } +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); +} + +IMPL_LINK( ScTpDefaultsOptions, NumModifiedHdl, NumericField*, EMPTYARG ) +{ + CheckNumSheets(); + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit