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 /sfx2/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 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailviewitem.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 4 |
6 files changed, 10 insertions, 10 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index d44927415ed1..d6190e604c78 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -517,7 +517,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) OUString sURL(officecfg::Office::Common::Menus::SendFeedbackURL::get() + //officecfg/registry/data/org/openoffice/Office/Common.xcu => https://hub.libreoffice.org/send-feedback/ "?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() + "&LOlocale=" + utl::ConfigManager::getUILocale() + - "&LOmodule=" + module.copy(module.lastIndexOf('.') + 1 ) ); + "&LOmodule=" + module.subView(module.lastIndexOf('.') + 1 ) ); sfx2::openUriExternally(sURL, false); break; } diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 9cd627dd1f0c..06bb3fc5e454 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -707,7 +707,7 @@ static bool impl_showOnlineHelp( const OUString& rURL ) return false; OUString aHelpLink = officecfg::Office::Common::Help::HelpRootURL::get(); - OUString aTarget = "Target=" + rURL.copy(aInternal.getLength()); + OUString aTarget = OUString::Concat("Target=") + rURL.subView(aInternal.getLength()); aTarget = aTarget.replaceAll("%2F", "/").replaceAll("?", "&"); aHelpLink += aTarget; @@ -888,8 +888,8 @@ bool rewriteFlatpakHelpRootUrl(OUString * helpRootUrl) { << "\" doesn't contain files segment"); throw Failure(); } - path = path.copy(0, i1) + "/runtime/org.libreoffice.LibreOffice.Help/" - + path.copy(i2, i3 - i2) + sha + path.copy(i4); + path = path.subView(0, i1) + OUString::Concat("/runtime/org.libreoffice.LibreOffice.Help/") + + path.subView(i2, i3 - i2) + sha + path.subView(i4); // Turn <path> into a file URL: OUString url_; err = osl::FileBase::getFileURLFromSystemPath(path, url_); @@ -930,7 +930,7 @@ static bool impl_showOfflineHelp( const OUString& rURL ) } OUString aHelpLink( aBaseInstallPath + "/index.html?" ); - OUString aTarget = "Target=" + rURL.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.help://")); + OUString aTarget = OUString::Concat("Target=") + rURL.subView(RTL_CONSTASCII_LENGTH("vnd.sun.star.help://")); aTarget = aTarget.replaceAll("%2F","/").replaceAll("?","&"); aHelpLink += aTarget; diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index e858bb9f0834..3e6a083a98ee 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -248,7 +248,7 @@ void ThumbnailViewItem::addTextPrimitives (const OUString& rText, const Thumbnai --nLength; } - aText = aText.copy(0, nLineStart+nLength) + "..."; + aText = OUString::Concat(aText.subView(0, nLineStart+nLength)) + "..."; nLineLength = nLength + 3; } diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index a23b4d904dd5..d9577bc852e3 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -256,7 +256,7 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, QueryTooltipHdl, const weld::TreeIter&, const sal_Int32 nMaxLen = 80; if (sUsedBy.getLength() > nMaxLen) { - sUsedBy = sUsedBy.copy(0, nMaxLen) + "..."; + sUsedBy = OUString::Concat(sUsedBy.subView(0, nMaxLen)) + "..."; } OUString aMessage = SfxResId(STR_STYLEUSEDBY); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 6ca2de78fd8f..10be78bfe98d 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -798,7 +798,7 @@ OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const { const OUString aComplete( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); if( aComplete.getLength() > nMaxLength ) - return "..." + aComplete.copy( aComplete.getLength() - nMaxLength + 3, nMaxLength - 3 ); + return OUString::Concat("...") + aComplete.subView( aComplete.getLength() - nMaxLength + 3, nMaxLength - 3 ); return aComplete; } if ( nMaxLength == SFX_TITLE_FILENAME ) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 3076c58ea033..d525fa400859 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2600,7 +2600,7 @@ static void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines ) else nEndPos++; - rStr = rStr.copy( 0, nStartPos ) + rStr.copy( nEndPos ); + rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( nEndPos ); } // erase trailing lines if ( nStartPos != -1 ) @@ -2611,7 +2611,7 @@ static void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines ) n++; if ( n > nStartPos ) - rStr = rStr.copy( 0, nStartPos ) + rStr.copy( n ); + rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( n ); } } |