[Libreoffice-commits] .: 2 commits - sc/source

Noel Power noelp at kemper.freedesktop.org
Mon Feb 13 07:21:26 PST 2012


 sc/source/ui/inc/tpdefaults.hxx    |    7 ++++-
 sc/source/ui/optdlg/tpdefaults.cxx |   49 +++++++++++++++++++++++++++----------
 sc/source/ui/src/optdlg.src        |    6 ++--
 3 files changed, 46 insertions(+), 16 deletions(-)

New commits:
commit 0c998c462aa553f52b849a26e3ca8df077fb5622
Author: Noel Power <noel.power at novell.com>
Date:   Mon Feb 13 15:20:58 2012 +0000

    some very minor tweak(s) to "Improvment-of-Custom-Sheet-Prefix-Option"
    
    a) allow blank default prefix
    b) select the entire last good prefix is some illegal character used

diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index ec29550..ba294c5 100644
--- a/sc/source/ui/optdlg/tpdefaults.cxx
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -127,10 +127,12 @@ void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
 
     OUString aSheetPrefix = pEdit->GetText();
 
-    if ( !ScDocument::ValidTabName( aSheetPrefix ) )
+    if ( !aSheetPrefix.isEmpty() && !ScDocument::ValidTabName( aSheetPrefix ) )
     {
-        // Revert to last good Prefix
-        pEdit->SetText( maOldPrefixValue );
+        // Revert to last good Prefix and also select it to
+        // indicate something illegal was typed
+        Selection aSel( 0,  maOldPrefixValue.getLength() );
+        pEdit->SetText( maOldPrefixValue, aSel );
     }
     else
     {
commit afeb347c909fa2deb37694d4b9fd6509ec305366
Author: Albert Thuswaldner <albert.thuswaldner at gmail.com>
Date:   Thu Feb 9 15:26:27 2012 +0100

    Improvment of Custom Sheet Prefix Option

diff --git a/sc/source/ui/inc/tpdefaults.hxx b/sc/source/ui/inc/tpdefaults.hxx
index 606d174..7369988 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<ScDocOptions> mpOldOptions;
     ::boost::shared_ptr<ScDocOptions> mpNewOptions;
 };
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index 8c97c83..ec29550 100644
--- a/sc/source/ui/optdlg/tpdefaults.cxx
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -29,8 +29,6 @@
 
 #undef SC_DLLIMPLEMENTATION
 
-#include <vcl/msgbox.hxx>
-
 #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(pEdit);
+    return 0;
+}
+
+IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Edit*, pEdit )
 {
-    CheckPrefix();
+    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 edbf4b9..013c476 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 ) ;
     };
 };


More information about the Libreoffice-commits mailing list