svtools/source/dialogs/insdlg.cxx |   27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

New commits:
commit 871f5e60047002238df907f4b9406bf205cf16fa
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sat Sep 3 09:06:41 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Sep 3 21:52:16 2022 +0200

    Simplify by using replaceAll instead of replaceAt in a loop
    
    Change-Id: I019d93a0937be6402c9749b72595354cf4b09b7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139281
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svtools/source/dialogs/insdlg.cxx 
b/svtools/source/dialogs/insdlg.cxx
index adaa1b905275..7c8703993e3b 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -127,12 +127,6 @@ void SvObjectServerList::FillInsertObjects()
         {
             const uno::Sequence< OUString > seqNames= 
xNameAccess->getElementNames();
 
-            OUString aStringProductName( "%PRODUCTNAME" );
-            sal_Int32 nStringProductNameLength = 
aStringProductName.getLength();
-
-            OUString aStringProductVersion( "%PRODUCTVERSION" );
-            sal_Int32 nStringProductVersionLength = 
aStringProductVersion.getLength();
-
             for( const auto& rName : seqNames )
             {
                 uno::Reference< container::XNameAccess > xEntry ;
@@ -146,25 +140,8 @@ void SvObjectServerList::FillInsertObjects()
 
                     if ( !aUIName.isEmpty() )
                     {
-                        // replace %PRODUCTNAME
-                        sal_Int32 nIndex = aUIName.indexOf( aStringProductName 
);
-                        while( nIndex != -1 )
-                        {
-                            aUIName = aUIName.replaceAt(
-                                nIndex, nStringProductNameLength,
-                                utl::ConfigManager::getProductName() );
-                            nIndex = aUIName.indexOf( aStringProductName );
-                        }
-
-                        // replace %PRODUCTVERSION
-                        nIndex = aUIName.indexOf( aStringProductVersion );
-                        while( nIndex != -1 )
-                        {
-                            aUIName = aUIName.replaceAt(
-                                nIndex, nStringProductVersionLength,
-                                utl::ConfigManager::getProductVersion() );
-                            nIndex = aUIName.indexOf( aStringProductVersion );
-                        }
+                        aUIName = aUIName.replaceAll("%PRODUCTNAME", 
utl::ConfigManager::getProductName());
+                        aUIName = aUIName.replaceAll("%PRODUCTVERSION", 
utl::ConfigManager::getProductVersion());
                     }
 
                     SvGlobalName aClassName;

Reply via email to