summaryrefslogtreecommitdiffstats
path: root/sw/source/ui/frmdlg/cption.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/frmdlg/cption.cxx')
-rw-r--r--sw/source/ui/frmdlg/cption.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 3645a9cc8f5a..201b1c7f4f51 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -508,13 +508,14 @@ long CategoryBox::PreNotify( NotifyEvent& rNEvt )
if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN
&& nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE)
{
- OUString sKey( pEvent->GetCharCode() );
- String sName( GetText() );
+ const OUString sText( GetText() );
Selection aSel( GetSelection() );
aSel.Justify();
- if( aSel.Len() )
- sName.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
- sName.Insert( sKey, (xub_StrLen)aSel.Min() );
+
+ const OUString sName = sText.copy(0, aSel.Min())
+ + OUString( pEvent->GetCharCode() )
+ + sText.copy(aSel.Max());
+
if( !SwCalc::IsValidVarName( sName ))
nHandled = 1;
}