From ec1c4c49301758c54394f9943252e192ad54638b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 22 Nov 2021 14:08:27 +0200 Subject: O[U]String::replaceAt overloads that take string_view which results in lots of nice string_view improvements picked up by the plugins Change-Id: Ib0ec3887816b3d4436d003b739d9814f83e244b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125657 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/ui/Accessibility/AccessibleCell.cxx | 12 ++++++------ sc/source/ui/app/inputhdl.cxx | 4 ++-- sc/source/ui/docshell/docsh4.cxx | 8 ++++---- sc/source/ui/docshell/impex.cxx | 2 +- sc/source/ui/miscdlgs/acredlin.cxx | 2 +- sc/source/ui/navipi/content.cxx | 2 +- sc/source/ui/unoobj/addruno.cxx | 2 +- sc/source/ui/unoobj/chart2uno.cxx | 2 +- sc/source/ui/view/output2.cxx | 2 +- sc/source/ui/view/viewfunc.cxx | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index ed1dbd8ebeda..654dfe84ef67 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -457,7 +457,7 @@ void ScAccessibleCell::AddRelation(const ScRange& rRange, pRelationSet->AddRelation(aRelation); } -static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, const OUString& replaceStr) +static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, std::u16string_view replaceStr) { int iReplace = oldOUString.lastIndexOf(replacedChar); OUString aRet = oldOUString; @@ -471,11 +471,11 @@ static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view static OUString ReplaceFourChar(const OUString& oldOUString) { - OUString aRet = ReplaceOneChar(oldOUString, u"\\", "\\\\"); - aRet = ReplaceOneChar(aRet, u";", "\\;"); - aRet = ReplaceOneChar(aRet, u"=", "\\="); - aRet = ReplaceOneChar(aRet, u",", "\\,"); - aRet = ReplaceOneChar(aRet, u":", "\\:"); + 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; } diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 8c06ebfcc111..6466c30576f0 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -362,10 +362,10 @@ void ScInputHandler::InitRangeFinder( const OUString& rFormula ) sal_Int32 nColon = aDelimiters.indexOf( ':' ); if ( nColon != -1 ) - aDelimiters = aDelimiters.replaceAt( nColon, 1, ""); // Delimiter without colon + aDelimiters = aDelimiters.replaceAt( nColon, 1, u""); // Delimiter without colon sal_Int32 nDot = aDelimiters.indexOf(cSheetSep); if ( nDot != -1 ) - aDelimiters = aDelimiters.replaceAt( nDot, 1 , ""); // Delimiter without dot + aDelimiters = aDelimiters.replaceAt( nDot, 1 , u""); // Delimiter without dot const sal_Unicode* pChar = rFormula.getStr(); sal_Int32 nLen = rFormula.getLength(); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 289c66f756d9..a97a47ecc6ec 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1213,7 +1213,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) } else if ( (nPos = aLangText.indexOf(aDocLangPrefix)) != -1 ) { - aLangText = aLangText.replaceAt(nPos, aDocLangPrefix.getLength(), ""); + aLangText = aLangText.replaceAt(nPos, aDocLangPrefix.getLength(), u""); if ( aLangText == "LANGUAGE_NONE" ) { @@ -1243,12 +1243,12 @@ void ScDocShell::Execute( SfxRequest& rReq ) else if (-1 != (nPos = aLangText.indexOf( aSelectionLangPrefix ))) { bSelection = true; - aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" ); + aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), u"" ); } else if (-1 != (nPos = aLangText.indexOf( aParagraphLangPrefix ))) { bParagraph = true; - aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" ); + aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), u"" ); } if (bSelection || bParagraph) @@ -1345,7 +1345,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) sal_Int32 nPos = 0; if(-1 != (nPos = sApplyText.indexOf( sSpellingRule ))) { - sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), ""); + sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), u""); pEditView->InsertText( sApplyText ); } } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 72dad3cc6410..5d8e755c18f6 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -890,7 +890,7 @@ static void lcl_DoubleEscapeChar( OUString& rString, sal_Unicode cStr ) sal_Int32 n = 0; while( ( n = rString.indexOf( cStr, n ) ) != -1 ) { - rString = rString.replaceAt( n, 0, OUString(cStr) ); + rString = rString.replaceAt( n, 0, rtl::OUStringChar(cStr) ); n += 2; } } diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index 554bf801d1de..1d0ab68a3313 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -1680,7 +1680,7 @@ namespace { // cut out alignment string aStr = rExtraString.copy(nPos, n2 - nPos + 1); - rExtraString = rExtraString.replaceAt(nPos, n2 - nPos + 1, ""); + rExtraString = rExtraString.replaceAt(nPos, n2 - nPos + 1, u""); aStr = aStr.copy( n1-nPos+1 ); } } diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index c19c6b87a6fd..1b30df7f2406 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -943,7 +943,7 @@ static OUString lcl_NoteString( const ScPostIt& rNote ) OUString aText = rNote.GetText(); sal_Int32 nAt; while ( (nAt = aText.indexOf( '\n' )) != -1 ) - aText = aText.replaceAt( nAt, 1, " " ); + aText = aText.replaceAt( nAt, 1, u" " ); return aText; } diff --git a/sc/source/ui/unoobj/addruno.cxx b/sc/source/ui/unoobj/addruno.cxx index 0e307071d9ef..520f110a6f5d 100644 --- a/sc/source/ui/unoobj/addruno.cxx +++ b/sc/source/ui/unoobj/addruno.cxx @@ -196,7 +196,7 @@ void SAL_CALL ScAddressConversionObj::setPropertyValue( const OUString& aPropert sal_Int32 nColon = aUIString.lastIndexOf( ':' ); if ( nColon >= 0 && nColon < aUIString.getLength() - 1 && aUIString[nColon+1] == '.' ) - aUIString = aUIString.replaceAt( nColon+1, 1, "" ); + aUIString = aUIString.replaceAt( nColon+1, 1, u"" ); } // parse the rest like a UI string diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 6ec3a1e633d1..40e72bbfc8d9 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2261,7 +2261,7 @@ OUString SAL_CALL ScChart2DataProvider::convertRangeFromXML( const OUString& sXM sal_Int32 nIndex = ScRangeStringConverter::IndexOf( sToken, ':', 0 ); if ( nIndex >= 0 && nIndex < aUIString.getLength() - 1 && aUIString[nIndex + 1] == '.' ) - aUIString = aUIString.replaceAt( nIndex + 1, 1, "" ); + aUIString = aUIString.replaceAt( nIndex + 1, 1, u"" ); if ( aUIString[0] == '.' ) aUIString = aUIString.copy( 1 ); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 7c8758bb75e1..ba4a1b13a795 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -536,7 +536,7 @@ bool ScDrawStringsVars::SetText( const ScRefCellValue& rCell ) { nRepeatChar = aString[ nRepeatPos + 1 ]; // delete placeholder and char to repeat - aString = aString.replaceAt( nRepeatPos, 2, "" ); + aString = aString.replaceAt( nRepeatPos, 2, u"" ); // Do not cache/reuse a repeat-filled string, column // widths or fonts or sizes may differ. maLastCell.clear(); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 339c70d30aac..af151534c018 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -383,7 +383,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, { ++nIndex; } - OUString aString = rString.replaceAt( 1, nIndex - 1, "" ); + OUString aString = rString.replaceAt( 1, nIndex - 1, u"" ); // if the remaining part without the leading '+' or '-' character // is non-empty and not a number, handle as formula @@ -2745,7 +2745,7 @@ void ScViewFunc::ChangeNumFmtDecimals( bool bIncrement ) for ( sal_Int32 i=1 ; i= '1' && sExponentialStandardFormat[i] <= '9' ) - sExponentialStandardFormat = sExponentialStandardFormat.replaceAt( i, 1, "0" ); + sExponentialStandardFormat = sExponentialStandardFormat.replaceAt( i, 1, u"0" ); } aOut = aOut.copy( 0, nIndexE ); // remove exponential part } -- cgit