[Libreoffice-commits] core.git: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Feb 16 12:14:45 UTC 2019


 sc/source/ui/vba/vbanames.cxx |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit 097d76b110be2595e1c0bbd3fde171ae849bb361
Author:     Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Feb 10 18:10:40 2019 +0100
Commit:     Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sat Feb 16 13:14:26 2019 +0100

    Simplify name validation in ScVbaNames::Add
    
    Change-Id: Idd73659fdd76a1efd9ceb9fdc221622367d4922c
    Reviewed-on: https://gerrit.libreoffice.org/67652
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index 1ad4f824ec3c..4f2f774b1172 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -105,13 +105,9 @@ ScVbaNames::Add( const css::uno::Any& Name ,
     {
         if ( ScRangeData::IsNameValid( sName , getScDocument() )  != ScRangeData::NAME_VALID )
         {
-            sal_Int32 nIndex = 0;
-            OUString sResult = sName.getToken( 0 , '!' , nIndex );
-            if ( -1 == nIndex )
-                sResult = sName;
-            else
-                sResult = sName.copy( nIndex );
-            sName = sResult ;
+            const sal_Int32 nIndex{ sName.indexOf('!') };
+            if (nIndex>=0)
+                sName = sName.copy(nIndex+1);
             if ( ScRangeData::IsNameValid( sName , getScDocument() ) != ScRangeData::NAME_VALID )
                 throw uno::RuntimeException( "This Name is not valid ." );
         }


More information about the Libreoffice-commits mailing list