diff --git a/sc/source/ui/inc/tpdefaults.hxx b/sc/source/ui/inc/tpdefaults.hxx index 606d174cdbb0..7369988ee4c1 100644 --- a/sc/source/ui/inc/tpdefaults.hxx +++ b/sc/source/ui/inc/tpdefaults.hxx @@ -53,10 +53,12 @@ private: virtual ~ScTpDefaultsOptions(); void CheckNumSheets(); - void CheckPrefix(); + void CheckPrefix(Edit* pEdit); + void OnFocusPrefixInput(Edit* pEdit); DECL_LINK( NumModifiedHdl, NumericField* ); DECL_LINK( PrefixModifiedHdl, Edit* ); + DECL_LINK( PrefixEditOnFocusHdl, Edit* ); private: FixedLine aFLInitSpreadSheet; @@ -65,6 +67,9 @@ private: FixedText aFtSheetPrefix; Edit aEdSheetPrefix; + // Stores old Sheet Prefix + ::rtl::OUString maOldPrefixValue; + ::boost::shared_ptr mpOldOptions; ::boost::shared_ptr mpNewOptions; }; diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx index 8c97c83eda5b..ec29550fa818 100644 --- a/sc/source/ui/optdlg/tpdefaults.cxx +++ b/sc/source/ui/optdlg/tpdefaults.cxx @@ -29,8 +29,6 @@ #undef SC_DLLIMPLEMENTATION -#include - #include "tpdefaults.hxx" #include "optdlg.hrc" #include "scresid.hxx" @@ -49,9 +47,9 @@ ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCor SfxTabPage(pParent, ScResId(RID_SCPAGE_DEFAULTS), rCoreAttrs), aFLInitSpreadSheet ( this, ScResId( FL_INIT_SPREADSHEET ) ), aFtNSheets ( this, ScResId( FT_NSHEETS ) ), - aEdNSheets ( this, ScResId( ED_NSHEETS ) ), - aFtSheetPrefix ( this, ScResId( FT_SHEETPREFIX ) ), - aEdSheetPrefix ( this, ScResId( ED_SHEETPREFIX ) ) + aEdNSheets ( this, ScResId( ED_NSHEETS ) ), + aFtSheetPrefix ( this, ScResId( FT_SHEETPREFIX ) ), + aEdSheetPrefix ( this, ScResId( ED_SHEETPREFIX ) ) { FreeResource(); @@ -70,9 +68,10 @@ ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCor Point aNewPoint = aEdNSheets.GetPosPixel(); aNewPoint.X() += ( nTxtW - nCtrlW ); aEdNSheets.SetPosPixel( aNewPoint ); - } + } aEdNSheets.SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) ); aEdSheetPrefix.SetModifyHdl( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) ); + aEdSheetPrefix.SetGetFocusHdl( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) ); } ScTpDefaultsOptions::~ScTpDefaultsOptions() @@ -121,14 +120,31 @@ void ScTpDefaultsOptions::CheckNumSheets() aEdNSheets.SetValue(INIT_SHEETS_MIN); } -void ScTpDefaultsOptions::CheckPrefix() +void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit) { - OUString aSheetPrefix = aEdSheetPrefix.GetText(); + if (!pEdit) + return; + + OUString aSheetPrefix = pEdit->GetText(); if ( !ScDocument::ValidTabName( aSheetPrefix ) ) { - ErrorBox(this,WinBits(WB_OK|WB_DEF_OK), ScGlobal::GetRscString(STR_INVALIDTABNAME) ).Execute(); + // Revert to last good Prefix + pEdit->SetText( maOldPrefixValue ); } + else + { + OnFocusPrefixInput(pEdit); + } +} + +void ScTpDefaultsOptions::OnFocusPrefixInput(Edit* pEdit) +{ + if (!pEdit) + return; + + // Store Prefix in case we need to revert + maOldPrefixValue = pEdit->GetText(); } @@ -138,10 +154,17 @@ IMPL_LINK( ScTpDefaultsOptions, NumModifiedHdl, NumericField*, EMPTYARG ) return 0; } -IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, EMPTYARG ) +IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, pEdit ) { - CheckPrefix(); + CheckPrefix(pEdit); return 0; } +IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Edit*, pEdit ) +{ + OnFocusPrefixInput(pEdit); + return 0; +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src index edbf4b978a11..013c4762248a 100644 --- a/sc/source/ui/src/optdlg.src +++ b/sc/source/ui/src/optdlg.src @@ -943,14 +943,14 @@ TabPage RID_SCPAGE_DEFAULTS FixedText FT_SHEETPREFIX { Pos = MAP_APPFONT ( 12 , 32 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 110 , 8 ) ; Text [ en-US ] = "Prefix name for new worksheet"; }; Edit ED_SHEETPREFIX { HelpID = "sc:Edit:RID_SCPAGE_CALC:ED_SHEETPREFIX"; Border = TRUE ; - Pos = MAP_APPFONT ( 130 , 32 ) ; - Size = MAP_APPFONT ( 45 , 12 ) ; + Pos = MAP_APPFONT ( 130 , 30 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; }; };