summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-10-01 09:09:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-10-11 14:22:22 +0200
commit4f5b3e4bd53d6d61df1f65f496f7bc8dc525c8a1 (patch)
treee0ac44b8f22f944f3303bac8e494da41d6c7b164 /sc/source
parent5f84c44e3d5ff19b800b6358e61228546e318d4f (diff)
In O[U]StringBuffer, make string_view params replacements for OUString ones
...for LIBO_INTERNAL_ONLY, instead of having them as additional overloads. That way, loplugin:bufferadd and loplugin:stringviewparam found many further opportunities for simplification (all addressed here). Some notes: * There is no longer an implicit conversion from O[U]String to O[U]StringBuffer (as that goes via user-defined conversions through string_view now), which was most noticeable in copy initializations like OStringBuffer buf = someStr; that had to be changed to direct initialization, OStringBuffer buf(someStr); But then again, it wasn't too many places that were affected and I think we can live with that. * I made the O[U]StringBuffer ctors taking string_view non-explicit, mainly to get them in line with their counterparts taking O[U]String. * I added an OUStringBuffer::lastIndexOf string_view overload that was missing (relative to OUStringBuffer::indexOf). * loplugin:stringconstant needed some addition to keep the compilerplugins/clang/test/stringconstant.cxx checks related to OStringBuffer::append and OStringBuffer::insert working. * loplugin:stringviewparam no longer needs the special O[U]StringBuffer-related code that had been introduced in 1250aecd71fabde4dba990bfceb61bbe8e06b8ea "loplugin:stringviewparam extend to new.." Change-Id: Ib1bb8c4632d99b744e742605a9fef6eae959fd72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122904 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/dputil.cxx4
-rw-r--r--sc/source/core/data/global.cxx4
-rw-r--r--sc/source/core/data/postit.cxx4
-rw-r--r--sc/source/core/data/validat.cxx6
-rw-r--r--sc/source/core/tool/chartarr.cxx5
-rw-r--r--sc/source/core/tool/chgtrack.cxx12
-rw-r--r--sc/source/core/tool/interpr1.cxx9
-rw-r--r--sc/source/filter/excel/xiescher.cxx2
-rw-r--r--sc/source/filter/excel/xltools.cxx8
-rw-r--r--sc/source/filter/oox/numberformatsbuffer.cxx2
-rw-r--r--sc/source/filter/oox/worksheetbuffer.cxx6
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx2
-rw-r--r--sc/source/ui/dataprovider/datatransformation.cxx2
-rw-r--r--sc/source/ui/view/output2.cxx8
14 files changed, 29 insertions, 45 deletions
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index 0f5083f810df..ac1dcca65eeb 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -140,9 +140,7 @@ OUString ScDPUtil::getDateGroupName(
case sheet::DataPilotFieldGroupBy::MINUTES:
case sheet::DataPilotFieldGroupBy::SECONDS:
{
- OUStringBuffer aBuf(ScGlobal::getLocaleData().getTimeSep());
- aBuf.append(getTwoDigitString(nValue));
- return aBuf.makeStringAndClear();
+ return ScGlobal::getLocaleData().getTimeSep() + getTwoDigitString(nValue);
}
break;
default:
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index e795912dd2e3..8706a0017c1b 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -654,11 +654,11 @@ const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr,
return nullptr;
}
-OUString ScGlobal::addToken(const OUString& rTokenList, std::u16string_view rToken,
+OUString ScGlobal::addToken(std::u16string_view rTokenList, std::u16string_view rToken,
sal_Unicode cSep, sal_Int32 nSepCount, bool bForceSep)
{
OUStringBuffer aBuf(rTokenList);
- if( bForceSep || (!rToken.empty() && !rTokenList.isEmpty()) )
+ if( bForceSep || (!rToken.empty() && !rTokenList.empty()) )
comphelper::string::padToLength(aBuf, aBuf.getLength() + nSepCount, cSep);
aBuf.append(rToken);
return aBuf.makeStringAndClear();
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 12b5778aead2..ef7ff3bc4725 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -1160,7 +1160,7 @@ void ScPostIt::RemoveCaption()
ScCaptionPtr ScNoteUtil::CreateTempCaption(
ScDocument& rDoc, const ScAddress& rPos, SdrPage& rDrawPage,
- const OUString& rUserText, const tools::Rectangle& rVisRect, bool bTailFront )
+ std::u16string_view rUserText, const tools::Rectangle& rVisRect, bool bTailFront )
{
OUStringBuffer aBuffer( rUserText );
// add plain text of invisible (!) cell note (no formatting etc.)
@@ -1193,7 +1193,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
SdrCaptionObj* pCaption = aCreator.GetCaption().get(); // just for ease of use
// clone the edit text object, unless user text is present, then set this text
- if( pNoteCaption && rUserText.isEmpty() )
+ if( pNoteCaption && rUserText.empty() )
{
if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() )
pCaption->SetOutlinerParaObject( *pOPO );
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 2fe2fa211e85..150a5d187d2a 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -297,8 +297,8 @@ bool ScValidationData::DoMacro( const ScAddress& rPos, const OUString& rInput,
{
SbModule* pModule = pMethod->GetModule();
SbxObject* pObject = pModule->GetParent();
- OUStringBuffer aMacroStr = pObject->GetName();
- aMacroStr.append('.').append(pModule->GetName()).append('.').append(pMethod->GetName());
+ OUString aMacroStr(
+ pObject->GetName() + "." + pModule->GetName() + "." + pMethod->GetName());
OUString aBasicStr;
// the distinction between document- and app-basic has to be done
@@ -344,7 +344,7 @@ bool ScValidationData::DoMacro( const ScAddress& rPos, const OUString& rInput,
if ( pCell )
pDocument->LockTable( rPos.Tab() );
SbxVariableRef refRes = new SbxVariable;
- ErrCode eRet = pDocSh->CallBasic( aMacroStr.makeStringAndClear(), aBasicStr, refPar.get(), refRes.get() );
+ ErrCode eRet = pDocSh->CallBasic( aMacroStr, aBasicStr, refPar.get(), refRes.get() );
if ( pCell )
pDocument->UnlockTable( rPos.Tab() );
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index 242b4b539bc4..13e5df2501ad 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -340,15 +340,12 @@ std::unique_ptr<ScMemChart> ScChartArray::CreateMemChartMulti()
if (aString.isEmpty())
{
- OUStringBuffer aBuf(ScResId(STR_COLUMN));
- aBuf.append(' ');
if ( pPos )
nPosCol = pPos->Col() + 1;
else
nPosCol++;
ScAddress aPos( nPosCol - 1, 0, 0 );
- aBuf.append(aPos.Format(ScRefFlags::COL_VALID));
- aString = aBuf.makeStringAndClear();
+ aString = ScResId(STR_COLUMN) + " " + aPos.Format(ScRefFlags::COL_VALID);
}
pMemChart->SetColText( nCol, aString);
}
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index b3a1a64e8653..3583fb28f549 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -2079,11 +2079,7 @@ void ScChangeTrack::Init()
bTimeNanoSeconds = true;
const SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions();
- OUStringBuffer aBuf;
- aBuf.append(rUserOpt.GetFirstName());
- aBuf.append(' ');
- aBuf.append(rUserOpt.GetLastName());
- maUser = aBuf.makeStringAndClear();
+ maUser = rUserOpt.GetFirstName() + " " + rUserOpt.GetLastName();
maUserCollection.insert(maUser);
}
@@ -2184,11 +2180,7 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config
const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions();
size_t nOldCount = maUserCollection.size();
- OUStringBuffer aBuf;
- aBuf.append(rUserOptions.GetFirstName());
- aBuf.append(' ');
- aBuf.append(rUserOptions.GetLastName());
- SetUser(aBuf.makeStringAndClear());
+ SetUser(rUserOptions.GetFirstName() + " " + rUserOptions.GetLastName());
if ( maUserCollection.size() != nOldCount )
{
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1477eaaab424..e7030950030f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2307,15 +2307,12 @@ void ScInterpreter::ScCell()
SfxObjectShell* pShell = mrDoc.GetDocumentShell();
if( pShell && pShell->GetMedium() )
{
- OUStringBuffer aBuf;
- aBuf.append('\'');
const INetURLObject& rURLObj = pShell->GetMedium()->GetURLObject();
- aBuf.append(rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous));
- aBuf.append("'#$");
OUString aTabName;
mrDoc.GetName( nTab, aTabName );
- aBuf.append(aTabName);
- aFuncResult = aBuf.makeStringAndClear();
+ aFuncResult = "'"
+ + rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous)
+ + "'#$" + aTabName;
}
}
}
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 0cf6fb125971..883c77beaf0c 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -4276,7 +4276,7 @@ void XclImpSheetDrawing::ReadNote3( XclImpStream& rStrm )
return;
sal_uInt16 nPartLen = ::std::min( nTotalLen, static_cast< sal_uInt16 >( rStrm.GetRecLeft() ) );
- OUStringBuffer aNoteText = rStrm.ReadRawByteString( nPartLen );
+ OUStringBuffer aNoteText(rStrm.ReadRawByteString( nPartLen ));
nTotalLen = nTotalLen - nPartLen;
while (true)
{
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index 82c5c0449b25..3c6989af81fd 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -494,16 +494,12 @@ OUString XclTools::GetXclBuiltInDefName( sal_Unicode cBuiltIn )
OUString XclTools::GetBuiltInDefName( sal_Unicode cBuiltIn )
{
- OUStringBuffer aBuf(maDefNamePrefix);
- aBuf.append(GetXclBuiltInDefName(cBuiltIn));
- return aBuf.makeStringAndClear();
+ return maDefNamePrefix + GetXclBuiltInDefName(cBuiltIn);
}
OUString XclTools::GetBuiltInDefNameXml( sal_Unicode cBuiltIn )
{
- OUStringBuffer aBuf(maDefNamePrefixXml);
- aBuf.append(GetXclBuiltInDefName(cBuiltIn));
- return aBuf.makeStringAndClear();
+ return maDefNamePrefixXml + GetXclBuiltInDefName(cBuiltIn);
}
sal_Unicode XclTools::GetBuiltInDefNameIndex( const OUString& rDefName )
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index a219fdfcbcd1..af8230604b75 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1915,7 +1915,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode )
sal_Int32 nPosEscape = 0;
sal_Int32 nErase = 0;
sal_Int32 nLastIndex = rFmtCode.getLength() - 1;
- OUStringBuffer sFormat = rFmtCode;
+ OUStringBuffer sFormat(rFmtCode);
while ( ( nPosEscape = lclPosToken( rFmtCode, u"\\ ", nPosEscape ) ) > 0 )
{
diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx
index 94e93dbfd1a1..c4daa9cd98bd 100644
--- a/sc/source/filter/oox/worksheetbuffer.cxx
+++ b/sc/source/filter/oox/worksheetbuffer.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <worksheetbuffer.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
@@ -159,7 +163,7 @@ OUString WorksheetBuffer::getCalcSheetName( const OUString& rWorksheetName ) con
namespace {
-OUString lclQuoteName( const OUString& rName )
+OUString lclQuoteName( std::u16string_view rName )
{
OUStringBuffer aBuffer( rName );
// duplicate all quote characters
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 4fd91a3451ce..7556ac5e4737 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1344,7 +1344,7 @@ void ScCheckListMenuControl::getResult(ResultType& rResult)
{
if ( maMembers[i].mbLeaf )
{
- OUStringBuffer aLabel = maMembers[i].maName;
+ OUStringBuffer aLabel(maMembers[i].maName);
if (aLabel.isEmpty())
aLabel = ScResId(STR_EMPTYDATA);
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx
index 4039f336be80..14351d7c2004 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -131,7 +131,7 @@ void MergeColumnTransformation::Transform(ScDocument& rDoc) const
for (SCROW nRow = 0; nRow <= nMaxRow; ++nRow)
{
- OUStringBuffer aStr = rDoc.GetString(nTargetCol, nRow, 0);
+ OUStringBuffer aStr(rDoc.GetString(nTargetCol, nRow, 0));
for (auto& itr : maColumns)
{
if (itr != nTargetCol)
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index f33098bbb353..8f4a0c14eb36 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1830,7 +1830,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
if ( nRepeatCount > 1 )
{
OUString aCellStr = aVars.GetString();
- OUStringBuffer aRepeated = aCellStr;
+ OUStringBuffer aRepeated(aCellStr);
for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
aRepeated.append(aCellStr);
aVars.SetAutoText( aRepeated.makeStringAndClear() );
@@ -2998,7 +2998,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
tools::Long nRepeatCount = nAvailable / nRepeatSize;
if ( nRepeatCount > 1 )
{
- OUStringBuffer aRepeated = aCellStr;
+ OUStringBuffer aRepeated(aCellStr);
for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
aRepeated.append(aCellStr);
@@ -3376,7 +3376,7 @@ void ScOutputData::DrawEditBottomTop(DrawEditParam& rParam)
const tools::Long nRepeatCount = nAvailable / nRepeatSize;
if ( nRepeatCount > 1 )
{
- OUStringBuffer aRepeated = aCellStr;
+ OUStringBuffer aRepeated(aCellStr);
for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
aRepeated.append(aCellStr);
@@ -3620,7 +3620,7 @@ void ScOutputData::DrawEditTopBottom(DrawEditParam& rParam)
const tools::Long nRepeatCount = nAvailable / nRepeatSize;
if ( nRepeatCount > 1 )
{
- OUStringBuffer aRepeated = aCellStr;
+ OUStringBuffer aRepeated(aCellStr);
for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
aRepeated.append(aCellStr);