summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-11-12 08:13:40 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-11-12 16:53:30 +0100
commitf34ac579fac16fff37bf00fe85d43ad6b938eca7 (patch)
tree0747c4d86bbf40a5093fb7a3215dd52a8e8586b2 /sc
parentc45753847dfc2b4645dc2f7500a18ec2c5d438df (diff)
New loplugin:stringviewparam
...to "Find functions that take rtl::O[U]String parameters that can be generalized to take std::[u16]string_view instead." (Which in turn can avoid costly O[U]String constructions, see e.g. loplugin:stringview and subView.) Some of those functions' call sites, passing plain char string literals, needed to be adapted when converting them. Change-Id: I644ab546d7a0ce9e470ab9b3196e3e60d1e812bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105622 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr1.cxx3
-rw-r--r--sc/source/filter/excel/xehelper.cxx4
-rw-r--r--sc/source/filter/oox/numberformatsbuffer.cxx10
-rw-r--r--sc/source/ui/Accessibility/AccessibleCell.cxx14
-rw-r--r--sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx5
5 files changed, 22 insertions, 14 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 52e07726daa1..507a7aeb2eef 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -76,6 +76,7 @@
#include <vector>
#include <memory>
#include <limits>
+#include <string_view>
const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48
@@ -9038,7 +9039,7 @@ static bool IsDBCS(sal_Unicode currentChar)
bRet = (i < SAL_N_ELEMENTS(scriptList) && block >= scriptList[i].from);
return bRet;
}
-static sal_Int32 lcl_getLengthB( const OUString &str, sal_Int32 nPos )
+static sal_Int32 lcl_getLengthB( std::u16string_view str, sal_Int32 nPos )
{
sal_Int32 index = 0;
sal_Int32 length = 0;
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index 532e9187f289..05c4b673d0fe 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -890,7 +890,7 @@ namespace {
/** Encodes special parts of the URL, i.e. directory separators and volume names.
@param pTableName Pointer to a table name to be encoded in this URL, or 0. */
OUString lclEncodeDosUrl(
- XclBiff eBiff, const OUString& rUrl, const OUString& rBase, const OUString* pTableName)
+ XclBiff eBiff, const OUString& rUrl, std::u16string_view rBase, const OUString* pTableName)
{
OUStringBuffer aBuf;
@@ -908,7 +908,7 @@ OUString lclEncodeDosUrl(
else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) )
{
// drive letter
- sal_Unicode cThisDrive = rBase.isEmpty() ? ' ' : rBase[0];
+ sal_Unicode cThisDrive = rBase.empty() ? ' ' : rBase[0];
sal_Unicode cDrive = aOldUrl[0];
if (cThisDrive == cDrive)
// This document and the referenced document are under the same drive.
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index 5ca24adb1b42..922b0ccb93a1 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <numberformatsbuffer.hxx>
#include <biffhelper.hxx>
@@ -1871,7 +1875,7 @@ NumberFormatFinalizer::NumberFormatFinalizer( const WorkbookHelper& rHelper ) :
OSL_ENSURE( mxNumFmts.is(), "NumberFormatFinalizer::NumberFormatFinalizer - cannot get number formats" );
}
-sal_Int32 lclPosToken ( const OUString& sFormat, const OUString& sSearch, sal_Int32 nStartPos )
+sal_Int32 lclPosToken ( const OUString& sFormat, std::u16string_view sSearch, sal_Int32 nStartPos )
{
sal_Int32 nLength = sFormat.getLength();
for ( sal_Int32 i = nStartPos; i < nLength && i >= 0 ; i++ )
@@ -1912,7 +1916,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode )
sal_Int32 nLastIndex = rFmtCode.getLength() - 1;
OUStringBuffer sFormat = rFmtCode;
- while ( ( nPosEscape = lclPosToken( rFmtCode, "\\ ", nPosEscape ) ) > 0 )
+ while ( ( nPosEscape = lclPosToken( rFmtCode, u"\\ ", nPosEscape ) ) > 0 )
{
sal_Int32 nPos = nPosEscape + 2;
while ( nPos < nLastIndex && ( rFmtCode[nPos] == '?' || rFmtCode[nPos] == '#' || rFmtCode[nPos] == '0' ) )
@@ -1922,7 +1926,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode )
sFormat.remove(nPosEscape - nErase, 1);
nErase ++;
} // tdf#81939 preserve other escape characters
- nPosEscape = lclPosToken( rFmtCode, ";", nPosEscape ); // skip to next format
+ nPosEscape = lclPosToken( rFmtCode, u";", nPosEscape ); // skip to next format
}
maModel.maFmtCode = sFormat.makeStringAndClear();
}
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx
index 61cb5a9b0f12..0ec73e1a95ad 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -18,6 +18,8 @@
*/
#include <memory>
+#include <string_view>
+
#include <sal/config.h>
#include <AccessibleCell.hxx>
@@ -461,7 +463,7 @@ void ScAccessibleCell::AddRelation(const ScRange& rRange,
pRelationSet->AddRelation(aRelation);
}
-static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr)
+static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, const OUString& replaceStr)
{
int iReplace = oldOUString.lastIndexOf(replacedChar);
OUString aRet = oldOUString;
@@ -475,11 +477,11 @@ static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& repl
static OUString ReplaceFourChar(const OUString& oldOUString)
{
- OUString aRet = ReplaceOneChar(oldOUString, "\\", "\\\\");
- aRet = ReplaceOneChar(aRet, ";", "\\;");
- aRet = ReplaceOneChar(aRet, "=", "\\=");
- aRet = ReplaceOneChar(aRet, ",", "\\,");
- aRet = ReplaceOneChar(aRet, ":", "\\:");
+ OUString aRet = ReplaceOneChar(oldOUString, u"\\", "\\\\");
+ aRet = ReplaceOneChar(aRet, u";", "\\;");
+ aRet = ReplaceOneChar(aRet, u"=", "\\=");
+ aRet = ReplaceOneChar(aRet, u",", "\\,");
+ aRet = ReplaceOneChar(aRet, u":", "\\:");
return aRet;
}
diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
index 37e580bfa403..8b83ff5eb952 100644
--- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
@@ -9,6 +9,7 @@
*/
#include <memory>
+#include <string_view>
#include <rangelst.hxx>
#include <reffact.hxx>
@@ -48,11 +49,11 @@ const char* lclAnovaLabels[] =
nullptr
};
-const char strWildcardRange[] = "%RANGE%";
+const OUStringLiteral strWildcardRange = u"%RANGE%";
OUString lclCreateMultiParameterFormula(
ScRangeList& aRangeList, const OUString& aFormulaTemplate,
- const OUString& aWildcard, const ScDocument& rDocument,
+ std::u16string_view aWildcard, const ScDocument& rDocument,
const ScAddress::Details& aAddressDetails)
{
OUStringBuffer aResult;