oox/source/drawingml/chart/chartconverter.cxx |   15 ++++-----------
 sc/source/filter/oox/formulabase.cxx          |   14 ++++----------
 2 files changed, 8 insertions(+), 21 deletions(-)

New commits:
commit 8be964f0386308a10d02ce4e214da29a77890507
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun Sep 4 15:33:15 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Sep 5 15:55:28 2022 +0200

    Simplify by using replace instead of replaceAt in 2 loops in oox/sc
    
    I grouped these because one has a reference with the other
    
    Change-Id: I9bbd87951e2f945dfd20d54d16ea7d9291d74f62
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139369
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/oox/source/drawingml/chart/chartconverter.cxx 
b/oox/source/drawingml/chart/chartconverter.cxx
index e215d1883e7b..725b28c3bfe2 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -44,16 +44,6 @@ const sal_Unicode API_TOKEN_ARRAY_OPEN      = '{';
 const sal_Unicode API_TOKEN_ARRAY_CLOSE     = '}';
 const sal_Unicode API_TOKEN_ARRAY_COLSEP    = ';';
 
-// Code similar to sc/source/filter/oox/formulabase.cxx
-static OUString lclGenerateApiString( const OUString& rString )
-{
-    OUString aRetString = rString;
-    sal_Int32 nQuotePos = aRetString.getLength();
-    while( (nQuotePos = aRetString.lastIndexOf( '"', nQuotePos )) >= 0 )
-        aRetString = aRetString.replaceAt( nQuotePos, 1, u"\"\"" );
-    return "\"" + aRetString + "\"";
-}
-
 static OUString lclGenerateApiArray(const std::vector<Any>& rRow, sal_Int32 
nStart, sal_Int32 nCount)
 {
     OSL_ENSURE( !rRow.empty(), "ChartConverter::lclGenerateApiArray - missing 
matrix values" );
@@ -68,7 +58,10 @@ static OUString lclGenerateApiArray(const std::vector<Any>& 
rRow, sal_Int32 nSta
         if( *aIt >>= fValue )
             aBuffer.append( fValue );
         else if( *aIt >>= aString )
-            aBuffer.append( lclGenerateApiString( aString ) );
+        {
+            // Code similar to sc/source/filter/oox/formulabase.cxx
+            aBuffer.append( "\"" + aString.replaceAll(u"\"", u"\"\"") + "\"" );
+        }
         else
             aBuffer.append( "\"\"" );
     }
diff --git a/sc/source/filter/oox/formulabase.cxx 
b/sc/source/filter/oox/formulabase.cxx
index f12f0f0402cd..1fe793a47f9e 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1562,15 +1562,6 @@ OUString FormulaProcessorBase::generateAddress2dString( 
const BinAddress& rAddre
     return aBuffer.makeStringAndClear();
 }
 
-OUString FormulaProcessorBase::generateApiString( const OUString& rString )
-{
-    OUString aRetString = rString;
-    sal_Int32 nQuotePos = aRetString.getLength();
-    while( (nQuotePos = aRetString.lastIndexOf( '"', nQuotePos )) >= 0 )
-        aRetString = aRetString.replaceAt( nQuotePos, 1, u"\"\"" );
-    return "\"" + aRetString + "\"";
-}
-
 OUString FormulaProcessorBase::generateApiArray( const Matrix< Any >& rMatrix )
 {
     OSL_ENSURE( !rMatrix.empty(), "FormulaProcessorBase::generateApiArray - 
missing matrix values" );
@@ -1589,7 +1580,10 @@ OUString FormulaProcessorBase::generateApiArray( const 
Matrix< Any >& rMatrix )
             if( *aIt >>= fValue )
                 aBuffer.append( fValue );
             else if( *aIt >>= aString )
-                aBuffer.append( generateApiString( aString ) );
+            {
+                // generate Api String
+                aBuffer.append( "\"" + aString.replaceAll(u"\"", u"\"\"") + 
"\"" );
+            }
             else
                 aBuffer.append( "\"\"" );
         }

Reply via email to