diff options
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 164c1185e1b8..d3b5829a5db8 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8901,23 +8901,15 @@ void ScInterpreter::ScRight() n = 1; OUString aStr = GetString().getString(); sal_Int32 nLen = aStr.getLength(); - sal_Int32 nIdx = 0; - sal_Int32 nCnt = 0; - while ( nIdx < nLen ) - { - aStr.iterateCodePoints( &nIdx ); - ++nCnt; - } - if ( nCnt <= n ) + if ( nLen <= n ) PushString( aStr ); else { - sal_Int32 nCLen = nCnt; - nIdx = 0; - nCnt = 0; - while ( nIdx < nLen && n < ( nCLen - nCnt ) ) + sal_Int32 nIdx = nLen; + sal_Int32 nCnt = 0; + while ( nIdx > 0 && n > nCnt ) { - aStr.iterateCodePoints( &nIdx ); + aStr.iterateCodePoints( &nIdx, -1 ); ++nCnt; } aStr = aStr.copy( nIdx, nLen - nIdx ); |