sw/source/core/access/acccell.cxx |   29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

New commits:
commit 318e8578fa5816070610f83b752b6dc5c1697f93
Author:     Julien Nabet <[email protected]>
AuthorDate: Sat Sep 3 13:59:58 2022 +0200
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Sep 3 21:55:54 2022 +0200

    Simplify by using replaceAll in a loop (sw/access/acccell)
    
    Change-Id: Iab310d0f0395fe36ee0db6ac5d242518b33516aa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139317
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/source/core/access/acccell.cxx 
b/sw/source/core/access/acccell.cxx
index b599e57ead4c..8b15fa095545 100644
--- a/sw/source/core/access/acccell.cxx
+++ b/sw/source/core/access/acccell.cxx
@@ -368,28 +368,6 @@ uno::Any SwAccessibleCell::getMinimumIncrement(  )
     return uno::Any();
 }
 
-static OUString ReplaceOneChar(const OUString& oldOUString, 
std::u16string_view replacedChar, std::u16string_view replaceStr)
-{
-    int iReplace = oldOUString.lastIndexOf(replacedChar);
-    OUString aRet = oldOUString;
-    while(iReplace > -1)
-    {
-        aRet = aRet.replaceAt(iReplace,1, replaceStr);
-        iReplace = aRet.lastIndexOf(replacedChar,iReplace);
-    }
-    return aRet;
-}
-
-static OUString ReplaceFourChar(const OUString& oldOUString)
-{
-    OUString aRet = ReplaceOneChar(oldOUString, u"\\", u"\\\\");
-    aRet = ReplaceOneChar(aRet, u";", u"\\;");
-    aRet = ReplaceOneChar(aRet, u"=", u"\\=");
-    aRet = ReplaceOneChar(aRet, u",", u"\\,");
-    aRet = ReplaceOneChar(aRet, u":", u"\\:");
-    return aRet;
-}
-
 css::uno::Any SAL_CALL SwAccessibleCell::getExtendedAttributes()
 {
     SolarMutexGuard g;
@@ -400,7 +378,12 @@ css::uno::Any SAL_CALL 
SwAccessibleCell::getExtendedAttributes()
 
     const SwTableBoxFormula& tbl_formula = pFrameFormat->GetTableBoxFormula();
 
-    OUString strFormula = ReplaceFourChar(tbl_formula.GetFormula());
+    OUString strFormula = tbl_formula.GetFormula()
+                              .replaceAll(u"\\", u"\\\\")
+                              .replaceAll(u";", u"\\;")
+                              .replaceAll(u"=", u"\\=")
+                              .replaceAll(u",", u"\\,")
+                              .replaceAll(u":", u"\\:");
     OUString strFor = "Formula:" + strFormula + ";";
     strRet <<= strFor;
 

Reply via email to