[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 6 09:45:37 PST 2012


 sc/source/ui/inc/tpdefaults.hxx    |    4 ++++
 sc/source/ui/optdlg/tpdefaults.cxx |   21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

New commits:
commit a687d554774eba1c4bf5a4825e8730cb0114bd3c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Jan 6 12:43:20 2012 -0500

    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.

diff --git a/sc/source/ui/inc/tpdefaults.hxx b/sc/source/ui/inc/tpdefaults.hxx
index 622a310..374d0bc 100644
--- a/sc/source/ui/inc/tpdefaults.hxx
+++ b/sc/source/ui/inc/tpdefaults.hxx
@@ -52,6 +52,10 @@ private:
     explicit ScTpDefaultsOptions(Window* pParent, const SfxItemSet& rCoreAttrs);
     virtual ~ScTpDefaultsOptions();
 
+    void CheckNumSheets();
+
+    DECL_LINK( NumModifiedHdl, NumericField* );
+
 private:
     FixedLine     aFLInitSpreadSheet;
     FixedText     aFtNSheets;
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index ae88b2e..bd1cc68 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<const ScTpCalcItem&>(
         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<sal_uInt16>(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: */


More information about the Libreoffice-commits mailing list