diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-30 10:39:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-30 11:37:59 +0000 |
commit | db9912d824c1d621fdc409b9cdd6c79caefe1327 (patch) | |
tree | 5a3c905b93df25b5baf3c773927778c6f7fc4389 /unotools/source | |
parent | 6b19f32252f8ba5540ce3b1e38f8ac6112421906 (diff) |
loplugin:stringadd in ucbhelper..uui
when applying my upcoming patch to also consider O[U]StringBuffer
Change-Id: I49549347c1c041cc9ce103aed1fe1cc3bc1a780f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149751
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source')
-rw-r--r-- | unotools/source/config/docinfohelper.cxx | 9 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 110 | ||||
-rw-r--r-- | unotools/source/i18n/textsearch.cxx | 6 | ||||
-rw-r--r-- | unotools/source/misc/datetime.cxx | 12 |
4 files changed, 38 insertions, 99 deletions
diff --git a/unotools/source/config/docinfohelper.cxx b/unotools/source/config/docinfohelper.cxx index 6b36fb21b7e3..6674649eae3d 100644 --- a/unotools/source/config/docinfohelper.cxx +++ b/unotools/source/config/docinfohelper.cxx @@ -46,8 +46,7 @@ OUString DocInfoHelper::GetGeneratorString() OUString aValue( utl::ConfigManager::getProductName() ); if ( !aValue.isEmpty() ) { - aResult.append( aValue.replace( ' ', '_' ) ); - aResult.append( '/' ); + aResult.append( aValue.replace( ' ', '_' ) + "/" ); aValue = utl::ConfigManager::getProductVersion(); if ( !aValue.isEmpty() ) @@ -65,11 +64,7 @@ OUString DocInfoHelper::GetGeneratorString() OUString arch( "$_ARCH" ); ::rtl::Bootstrap::expandMacros(os); ::rtl::Bootstrap::expandMacros(arch); - aResult.append( '$' ); - aResult.append( os ); - aResult.append( '_' ); - aResult.append( arch ); - aResult.append( ' ' ); + aResult.append( "$" + os + "_" + arch + " " ); } // second product: LibreOffice_project/<build_information> diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 9e6fe8990979..56524372e21f 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -347,13 +347,13 @@ const std::vector< LanguageType >& LocaleDataWrapper::getInstalledLanguageTypes( // && aDebugLocale != "es-BR" // ?!? Brazil/es ) { - OUStringBuffer aMsg("ConvertIsoNamesToLanguage/ConvertLanguageToIsoNames: ambiguous locale (MS-LCID?)\n"); - aMsg.append(aDebugLocale); - aMsg.append(" -> 0x"); - aMsg.append(static_cast<sal_Int32>(static_cast<sal_uInt16>(eLang)), 16); - aMsg.append(" -> "); - aMsg.append(aBackLanguageTag.getBcp47()); - outputCheckMessage( aMsg ); + outputCheckMessage(Concat2View( + "ConvertIsoNamesToLanguage/ConvertLanguageToIsoNames: ambiguous locale (MS-LCID?)\n" + + aDebugLocale + + " -> 0x" + + OUString::number(static_cast<sal_Int32>(static_cast<sal_uInt16>(eLang)), 16) + + " -> " + + aBackLanguageTag.getBcp47() )); } eLang = LANGUAGE_DONTKNOW; } @@ -1234,8 +1234,7 @@ OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, // check if digits and separators will fit into fixed buffer or allocate size_t nGuess = ImplGetNumberStringLengthGuess( aLocaleDataItem, nDecimals ); - OUStringBuffer aNumBuf(int(nGuess + 16)); - OUStringBuffer aBuf(int(rCurrencySymbol.size() + nGuess + 20 )); + OUStringBuffer aNumBuf(sal_Int32(nGuess + 16)); bool bNeg; if ( nNumber < 0 ) @@ -1286,27 +1285,22 @@ OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, } } + OUString aCur; if ( !bNeg ) { switch( getCurrPositiveFormat() ) { case 0: - aBuf.append( rCurrencySymbol ); - aBuf.append( aNumBuf ); + aCur = rCurrencySymbol + aNumBuf; break; case 1: - aBuf.append( aNumBuf ); - aBuf.append( rCurrencySymbol ); + aCur = aNumBuf + rCurrencySymbol; break; case 2: - aBuf.append( rCurrencySymbol ); - aBuf.append( ' ' ); - aBuf.append( aNumBuf ); + aCur = OUString::Concat(rCurrencySymbol) + " " + aNumBuf; break; case 3: - aBuf.append( aNumBuf ); - aBuf.append( ' ' ); - aBuf.append( rCurrencySymbol ); + aCur = aNumBuf + " " + rCurrencySymbol; break; } } @@ -1315,101 +1309,57 @@ OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, switch( getCurrNegativeFormat() ) { case 0: - aBuf.append( '(' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( aNumBuf ); - aBuf.append( ')' ); + aCur = OUString::Concat("(") + rCurrencySymbol + aNumBuf + ")"; break; case 1: - aBuf.append( '-' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( aNumBuf ); + aCur = OUString::Concat("-") + rCurrencySymbol + aNumBuf; break; case 2: - aBuf.append( rCurrencySymbol ); - aBuf.append( '-' ); - aBuf.append( aNumBuf ); + aCur = OUString::Concat(rCurrencySymbol) + "-" + aNumBuf; break; case 3: - aBuf.append( rCurrencySymbol ); - aBuf.append( aNumBuf ); - aBuf.append( '-' ); + aCur = rCurrencySymbol + aNumBuf + "-"; break; case 4: - aBuf.append( '(' ); - aBuf.append( aNumBuf ); - aBuf.append( rCurrencySymbol ); - aBuf.append( ')' ); + aCur = "(" + aNumBuf + rCurrencySymbol + ")"; break; case 5: - aBuf.append( '-' ); - aBuf.append( aNumBuf ); - aBuf.append( rCurrencySymbol ); + aCur = "-" + aNumBuf + rCurrencySymbol; break; case 6: - aBuf.append( aNumBuf ); - aBuf.append( '-' ); - aBuf.append( rCurrencySymbol ); + aCur = aNumBuf + "-" + rCurrencySymbol; break; case 7: - aBuf.append( aNumBuf ); - aBuf.append( rCurrencySymbol ); - aBuf.append( '-' ); + aCur = aNumBuf + rCurrencySymbol + "-"; break; case 8: - aBuf.append( '-' ); - aBuf.append( aNumBuf ); - aBuf.append( ' ' ); - aBuf.append( rCurrencySymbol ); + aCur = "-" + aNumBuf + " " + rCurrencySymbol; break; case 9: - aBuf.append( '-' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( ' ' ); - aBuf.append( aNumBuf ); + aCur = OUString::Concat("-") + rCurrencySymbol + " " + aNumBuf; break; case 10: - aBuf.append( aNumBuf ); - aBuf.append( ' ' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( '-' ); + aCur = aNumBuf + " " + rCurrencySymbol + "-"; break; case 11: - aBuf.append( rCurrencySymbol ); - aBuf.append( ' ' ); - aBuf.append( '-' ); - aBuf.append( aNumBuf ); + aCur = OUString::Concat(rCurrencySymbol) + " -" + aNumBuf; break; case 12: - aBuf.append( rCurrencySymbol ); - aBuf.append( ' ' ); - aBuf.append( aNumBuf ); - aBuf.append( '-' ); + aCur = OUString::Concat(rCurrencySymbol) + " " + aNumBuf + "-"; break; case 13: - aBuf.append( aNumBuf ); - aBuf.append( '-' ); - aBuf.append( ' ' ); - aBuf.append( rCurrencySymbol ); + aCur = aNumBuf + "- " + rCurrencySymbol; break; case 14: - aBuf.append( '(' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( ' ' ); - aBuf.append( aNumBuf ); - aBuf.append( ')' ); + aCur = OUString::Concat("(") + rCurrencySymbol + " " + aNumBuf + ")"; break; case 15: - aBuf.append( '(' ); - aBuf.append( aNumBuf ); - aBuf.append( ' ' ); - aBuf.append( rCurrencySymbol ); - aBuf.append( ')' ); + aCur = "(" + aNumBuf + " " + rCurrencySymbol + ")"; break; } } - return aBuf.makeStringAndClear(); + return aCur; } // --- number parsing ------------------------------------------------- diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx index 91f70d2fb641..b7f104895f8c 100644 --- a/unotools/source/i18n/textsearch.cxx +++ b/unotools/source/i18n/textsearch.cxx @@ -357,8 +357,7 @@ void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, std::u16string_vi } break; default: - sBuff.append(rReplaceStr[i]); - sBuff.append(rReplaceStr[i+1]); + sBuff.append(OUStringChar(rReplaceStr[i]) + OUStringChar(rReplaceStr[i+1])); i += 1; break; } @@ -379,8 +378,7 @@ void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, std::u16string_vi i += 1; break; default: - sBuff.append(rReplaceStr[i]); - sBuff.append(rReplaceStr[i+1]); + sBuff.append(OUStringChar(rReplaceStr[i]) + OUStringChar(rReplaceStr[i+1])); i += 1; break; } diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index f95f39f92112..348dd0df4934 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -264,12 +264,10 @@ void typeConvert(const css::util::DateTime& _rDateTime, DateTime& _rOut) OUString toISO8601(const css::util::DateTime& rDateTime) { OUStringBuffer rBuffer(32); - rBuffer.append(static_cast<sal_Int32>(rDateTime.Year)); - rBuffer.append('-'); + rBuffer.append(OUString::number(static_cast<sal_Int32>(rDateTime.Year)) + "-"); if( rDateTime.Month < 10 ) rBuffer.append('0'); - rBuffer.append(static_cast<sal_Int32>(rDateTime.Month)); - rBuffer.append('-'); + rBuffer.append(OUString::number(static_cast<sal_Int32>(rDateTime.Month)) + "-"); if( rDateTime.Day < 10 ) rBuffer.append('0'); rBuffer.append(static_cast<sal_Int32>(rDateTime.Day)); @@ -282,12 +280,10 @@ OUString toISO8601(const css::util::DateTime& rDateTime) rBuffer.append('T'); if( rDateTime.Hours < 10 ) rBuffer.append('0'); - rBuffer.append(static_cast<sal_Int32>(rDateTime.Hours)); - rBuffer.append(':'); + rBuffer.append(OUString::number(static_cast<sal_Int32>(rDateTime.Hours)) + ":"); if( rDateTime.Minutes < 10 ) rBuffer.append('0'); - rBuffer.append(static_cast<sal_Int32>(rDateTime.Minutes)); - rBuffer.append(':'); + rBuffer.append(OUString::number(static_cast<sal_Int32>(rDateTime.Minutes)) + ":"); if( rDateTime.Seconds < 10 ) rBuffer.append('0'); rBuffer.append(static_cast<sal_Int32>(rDateTime.Seconds)); |