diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-03-14 13:06:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-14 13:11:50 +0000 |
commit | 533be98148ff40f6205e2ac3b489748cae14ef0d (patch) | |
tree | 92ab00f8ad6ef0adb61f6792fc475c3913789970 | |
parent | eaa76b5b0a60548951d2e8428a5e1d18c17720a7 (diff) |
restore incrementing time fields by area cursor is in
regression from String->OUString conversion with
tricky unsigned xub_StrLen of 0xFFFF for not-found
> any found position, vs -1 for OUString for not-found
Change-Id: I4a2babae085916a86cd1e60b74b4ea839dd8b87a
-rw-r--r-- | vcl/source/control/field2.cxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 49ad88e13736..b988cb83cc11 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -2492,20 +2492,27 @@ void TimeField::ImplTimeSpinArea( sal_Bool bUp ) { if ( GetField() ) { - xub_StrLen nTimeArea = 0; + sal_Int32 nTimeArea = 0; Time aTime( GetTime() ); OUString aText( GetText() ); Selection aSelection( GetField()->GetSelection() ); - // Area suchen + // Area search if ( GetFormat() != TIMEF_SEC_CS ) { - for ( xub_StrLen i = 1, nPos = 0; i <= 4; i++ ) + //Which area is the cursor in of HH:MM:SS.TT + for ( sal_Int32 i = 1, nPos = 0; i <= 4; i++ ) { sal_Int32 nPos1 = aText.indexOf( ImplGetLocaleDataWrapper().getTimeSep(), nPos ); sal_Int32 nPos2 = aText.indexOf( ImplGetLocaleDataWrapper().getTime100SecSep(), nPos ); - nPos = nPos1 < nPos2 ? nPos1 : nPos2; - if ( nPos >= (xub_StrLen)aSelection.Max() ) + //which ever comes first, bearing in mind that one might not be there + if (nPos1 >= 0 && nPos2 >= 0) + nPos = nPos1 < nPos2 ? nPos1 : nPos2; + else if (nPos1 >= 0) + nPos = nPos1; + else + nPos = nPos2; + if ( nPos < 0 || nPos >= aSelection.Max() ) { nTimeArea = i; break; @@ -2517,7 +2524,7 @@ void TimeField::ImplTimeSpinArea( sal_Bool bUp ) else { sal_Int32 nPos = aText.indexOf( ImplGetLocaleDataWrapper().getTime100SecSep() ); - if ( nPos < 0 || nPos >= (xub_StrLen)aSelection.Max() ) + if ( nPos < 0 || nPos >= aSelection.Max() ) nTimeArea = 3; else nTimeArea = 4; |