diff options
author | Noel <noelgrandin@gmail.com> | 2020-11-06 20:01:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-11 11:58:37 +0100 |
commit | 93c64a61f2c84e684050294a1391cd32425b7837 (patch) | |
tree | 00aad2cb8f3ee29ba4ac99e159e26fb8d71d2f33 /sd/source | |
parent | 1fde62018c8d3344a3408c7b6317120aefc778fb (diff) |
loplugin:stringview
Add new methods "subView" to O(U)String to return substring views
of the underlying data.
Add a clang plugin to warn when replacing existing calls to copy()
would be better to use subView().
Change-Id: I03a5732431ce60808946f2ce2c923b22845689ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105420
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 4 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptbase.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/dlg/custsdlg.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuconstr.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 6 |
6 files changed, 9 insertions, 9 deletions
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 8d6b3976cada..60fd4b939de3 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -1527,7 +1527,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, if(aOriginalNewLayoutName != aTargetNewLayoutName) { const sal_Int32 nPos(aName.indexOf(SD_LT_SEPARATOR)); - aName = aTargetNewLayoutName + aName.copy(nPos); + aName = aTargetNewLayoutName + aName.subView(nPos); } SfxStyleSheet* pMySheet = static_cast<SfxStyleSheet*>( mxStyleSheetPool->Find(aName, SfxStyleFamily::Page) ); @@ -1568,7 +1568,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, // this new style OUString aTemp(pMySheet->GetName()); const sal_Int32 nPos(aTemp.indexOf(SD_LT_SEPARATOR)); - aTemp = aOldLayoutName + aTemp.copy(nPos); + aTemp = aOldLayoutName + aTemp.subView(nPos); aReplData.aName = aTemp; aReplList.push_back(aReplData); } diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index 27870ec4bb43..6907389968d7 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -569,7 +569,7 @@ bool PPTWriterBase::GetStyleSheets() if ( nInstance == EPP_TEXTTYPE_Body ) { sal_Unicode cTemp = aStyle[aStyle.getLength() - 1]; - aStyle = aStyle.copy(0, aStyle.getLength() - 1) + OUStringChar(++cTemp); + aStyle = aStyle.subView(0, aStyle.getLength() - 1) + OUStringChar(++cTemp); if ( aXFamily->hasByName( aStyle ) ) { aXFamily->getByName( aStyle ) >>= xStyle; diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx index c18e8c117e61..dc0ad6b7f287 100644 --- a/sd/source/ui/dlg/custsdlg.cxx +++ b/sd/source/ui/dlg/custsdlg.cxx @@ -212,7 +212,7 @@ void SdCustomShowDlg::SelectHdl(void const *p) const CharClass* pCharClass = rDoc.GetCharClass(); while( pCharClass->isDigit( aStr, nStrPos ) ) aStr = aStr.replaceAt( nStrPos, 1, "" ); - aStr = aStr.copy( 0, nStrPos) + OUString::number( ++nNum ) + aStr.copy( nStrPos); + aStr = aStr.subView( 0, nStrPos) + OUString::number( ++nNum ) + aStr.subView( nStrPos); } } diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx index e4eb8b3eda5f..7bf915055b4b 100644 --- a/sd/source/ui/func/fuconstr.cxx +++ b/sd/source/ui/func/fuconstr.cxx @@ -316,7 +316,7 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj, ***********************************************/ OUString aName( pPage->GetLayoutName() ); sal_Int32 n = aName.indexOf(SD_LT_SEPARATOR) + strlen(SD_LT_SEPARATOR); - aName = aName.copy(0, n) + STR_LAYOUT_BACKGROUNDOBJECTS; + aName = OUString::Concat(aName.subView(0, n)) + STR_LAYOUT_BACKGROUNDOBJECTS; SfxStyleSheet* pSheet( static_cast< SfxStyleSheet* >( pPage->getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page))); diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 08684ae41a5a..028168b6a8e5 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -632,7 +632,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) { rDocliner.Insert( pOutliner->GetText(pSourcePara), nTargetPos, nDepth ); OUString aStyleSheetName( pStyleSheet->GetName() ); - aStyleSheetName = aStyleSheetName.copy( 0, aStyleSheetName.getLength()-1 ) + + aStyleSheetName = aStyleSheetName.subView( 0, aStyleSheetName.getLength()-1 ) + OUString::number( nDepth <= 0 ? 1 : nDepth+1 ); SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool(); SfxStyleSheet* pOutlStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) ); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 29ba9c20ee34..0ea67fbd7bcb 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2131,7 +2131,7 @@ OUString getPageApiNameFromUiName( const OUString& rUIName ) if( rUIName.startsWith( aDefPageName ) ) { - aApiName = sEmptyPageName + rUIName.copy( aDefPageName.getLength() ); + aApiName = OUString::Concat(sEmptyPageName) + rUIName.subView( aDefPageName.getLength() ); } else { @@ -2839,7 +2839,7 @@ void SdMasterPage::setBackground( const Any& rValue ) if(pSSPool) { OUString aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() ); - aLayoutName = aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4) + + aLayoutName = OUString::Concat(aLayoutName.subView(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4)) + STR_LAYOUT_BACKGROUND; SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page ); @@ -2885,7 +2885,7 @@ void SdMasterPage::getBackground( Any& rValue ) if(pSSPool) { OUString aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() ); - aLayoutName = aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4) + + aLayoutName = OUString::Concat(aLayoutName.subView(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4)) + STR_LAYOUT_BACKGROUND; SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page ); |