diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 17:44:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 21:25:10 +0100 |
commit | 35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch) | |
tree | bb78f4f13f131f0cb206a9707cc3cfc495a3876a /sfx2 | |
parent | 0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff) |
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by
1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take
std::u16string_view parameters" because they did not match the multi-overload
pattern that was addressed there, but they nevertheless benefit from being
changed just as well (witness e.g. the various resulting changes from copy() to
subView()).
This showed a conversion from OStringChar to std::string_view to be missing
(while the corresponding conversion form OUStringChar to std::u16string_view was
already present).
The improvement to loplugin:stringadd became necessary to fix
> [CPT] compilerplugins/clang/test/stringadd.cxx
> error: 'error' diagnostics expected but not seen:
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd]
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd]
> 2 errors generated.
Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/bastyp/fltfnc.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/bastyp/mieclip.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/emojiview.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/DocumentMetadataAccess.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/docfilt.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/doc/doctempl.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/oleprops.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/oleprops.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 2 |
13 files changed, 32 insertions, 29 deletions
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index 39a4d8ff48a6..7d45c06ba176 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -788,9 +788,9 @@ IMPL_LINK( SfxFilterMatcher, MaybeFileHdl_Impl, OUString*, pString, bool ) { std::shared_ptr<const SfxFilter> pFilter = GetFilter4Extension( *pString ); return pFilter && - !pFilter->GetWildcard().Matches("") && - !pFilter->GetWildcard().Matches("*.*") && - !pFilter->GetWildcard().Matches("*"); + !pFilter->GetWildcard().Matches(u"") && + !pFilter->GetWildcard().Matches(u"*.*") && + !pFilter->GetWildcard().Matches(u"*"); } diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx index 83920a1752ad..ae3a2d5e5684 100644 --- a/sfx2/source/bastyp/mieclip.cxx +++ b/sfx2/source/bastyp/mieclip.cxx @@ -56,7 +56,7 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream ) else if (sTmp == "EndFragment") nFragEnd = sLine.copy(nIndex).toInt32(); else if (sTmp == "SourceURL") - sBaseURL = OStringToOUString( sLine.copy(nIndex), RTL_TEXTENCODING_UTF8 ); + sBaseURL = OStringToOUString( sLine.subView(nIndex), RTL_TEXTENCODING_UTF8 ); if (nEnd >= 0 && nStt >= 0 && (!sBaseURL.isEmpty() || rStream.Tell() >= o3tl::make_unsigned(nStt))) diff --git a/sfx2/source/control/emojiview.cxx b/sfx2/source/control/emojiview.cxx index 63aa9ac602c9..78b7dc96c19f 100644 --- a/sfx2/source/control/emojiview.cxx +++ b/sfx2/source/control/emojiview.cxx @@ -21,6 +21,7 @@ #include <orcus/config.hpp> #include <orcus/pstring.hpp> #include <string> +#include <string_view> #include <fstream> using namespace ::com::sun::star; @@ -66,7 +67,7 @@ EmojiView::EmojiView(std::unique_ptr<weld::ScrolledWindow> xWindow) // locate json data file OUString sPath("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/emojiconfig/emoji.json"); rtl::Bootstrap::expandMacros(sPath); - std::string strPath = OUStringToOString(sPath.copy(strlen("file://")), RTL_TEXTENCODING_UTF8).getStr(); + std::string strPath = OUStringToOString(sPath.subView(strlen("file://")), RTL_TEXTENCODING_UTF8).getStr(); std::ifstream file(strPath); if(!file.is_open()) @@ -139,15 +140,15 @@ void EmojiView::Populate() // get values of parameters in AppendItem() function if(emojiParam == "unicode") { - sTitle = OStringToOUString(OString( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); + sTitle = OStringToOUString(std::string_view( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); } else if(emojiParam == "category") { - sCategory = OStringToOUString(OString( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); + sCategory = OStringToOUString(std::string_view( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); } else if(emojiParam == "name") { - sName = OStringToOUString(OString( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); + sName = OStringToOUString(std::string_view( prop.string_value().get(), prop.string_value().size() ), RTL_TEXTENCODING_UTF8); } else if(emojiParam == "duplicate") { diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 730c64e28cb0..0a931f4088ef 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -75,7 +75,7 @@ using namespace ::com::sun::star; namespace sfx2 { -bool isValidNCName(OUString const & i_rIdref) +bool isValidNCName(std::u16string_view i_rIdref) { const OString id( OUStringToOString(i_rIdref, RTL_TEXTENCODING_UTF8) ); @@ -101,7 +101,7 @@ static bool isStylesFile (OUString const & i_rPath) } bool isValidXmlId(OUString const & i_rStreamName, - OUString const & i_rIdref) + std::u16string_view i_rIdref) { return isValidNCName(i_rIdref) && (isContentFile(i_rStreamName) || isStylesFile(i_rStreamName)); diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index 18f38d422ffe..696792ff8ece 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -43,7 +43,7 @@ SfxFilter::SfxFilter( const OUString& rProvider, const OUString &rFilterName ) : } SfxFilter::SfxFilter( const OUString &rName, - const OUString &rWildCard, + std::u16string_view rWildCard, SfxFilterFlags nType, SotClipboardFormatId lFmt, const OUString &rTypNm, @@ -71,7 +71,7 @@ SfxFilter::SfxFilter( const OUString &rName, // truncate to first empty extension if (aExts[0]==';') { - aWildCard.setGlob(""); + aWildCard.setGlob(u""); return; } const sal_Int32 nIdx{ aExts.indexOf(";;") }; @@ -80,7 +80,7 @@ SfxFilter::SfxFilter( const OUString &rName, else if (aExts[nLen-1]==';') --nLen; if (nLen<aExts.getLength()) - aWildCard.setGlob(aExts.copy(0, nLen)); + aWildCard.setGlob(aExts.subView(0, nLen)); } SfxFilter::~SfxFilter() diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index b57c11d98847..31aac23c905e 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -119,7 +119,7 @@ public: void SetTargetURL( const OUString& rURL ) { maTargetURL = rURL; } void SetHierarchyURL( const OUString& rURL) { maOwnURL = rURL; } - int Compare( const OUString& rTitle ) const; + int Compare( std::u16string_view rTitle ) const; }; } @@ -138,7 +138,7 @@ class RegionData_Impl OUString maOwnURL; private: - size_t GetEntryPos( const OUString& rTitle, + size_t GetEntryPos( std::u16string_view rTitle, bool& rFound ) const; public: @@ -148,7 +148,7 @@ public: void SetHierarchyURL( const OUString& rURL) { maOwnURL = rURL; } DocTempl_EntryData_Impl* GetEntry( size_t nIndex ) const; - DocTempl_EntryData_Impl* GetEntry( const OUString& rName ) const; + DocTempl_EntryData_Impl* GetEntry( std::u16string_view rName ) const; const OUString& GetTitle() const { return maTitle; } const OUString& GetHierarchyURL(); @@ -1090,7 +1090,7 @@ bool SfxDocumentTemplates::SetName( const OUString& rName, sal_uInt16 nRegion, s bool SfxDocumentTemplates::GetFull ( std::u16string_view rRegion, // Region Name - const OUString &rName, // Template Name + std::u16string_view rName, // Template Name OUString &rPath // Out: Path + File name ) @@ -1112,7 +1112,7 @@ bool SfxDocumentTemplates::GetFull DocTemplLocker_Impl aLocker( *pImp ); // We don't search for empty names! - if ( rName.isEmpty() ) + if ( rName.empty() ) return false; if ( ! pImp->Construct() ) @@ -1249,7 +1249,7 @@ DocTempl_EntryData_Impl::DocTempl_EntryData_Impl( RegionData_Impl* pParent, } -int DocTempl_EntryData_Impl::Compare( const OUString& rTitle ) const +int DocTempl_EntryData_Impl::Compare( std::u16string_view rTitle ) const { return maTitle.compareTo( rTitle ); } @@ -1301,7 +1301,7 @@ RegionData_Impl::RegionData_Impl( const SfxDocTemplate_Impl* pParent, } -size_t RegionData_Impl::GetEntryPos( const OUString& rTitle, bool& rFound ) const +size_t RegionData_Impl::GetEntryPos( std::u16string_view rTitle, bool& rFound ) const { const size_t nCount = maEntries.size(); @@ -1378,7 +1378,7 @@ const OUString& RegionData_Impl::GetHierarchyURL() } -DocTempl_EntryData_Impl* RegionData_Impl::GetEntry( const OUString& rName ) const +DocTempl_EntryData_Impl* RegionData_Impl::GetEntry( std::u16string_view rName ) const { bool bFound = false; tools::Long nPos = GetEntryPos( rName, bFound ); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index f94b66df540f..8e5fbd4df93d 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -963,7 +963,7 @@ void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteract { } - if ( aVersion.compareTo( ODFVER_012_TEXT ) < 0 ) + if ( aVersion.compareTo( u"" ODFVER_012_TEXT ) < 0 ) return; // this is ODF1.2 or later diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 226321744a26..d0af3586b80f 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1769,7 +1769,7 @@ bool SfxObjectShell::PrepareForSigning(weld::Window* pDialogParent) OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage())); if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() - || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion.compareTo(ODFVER_012_TEXT) < 0 && !bHasSign)) + || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion.compareTo(u"" ODFVER_012_TEXT) < 0 && !bHasSign)) { // the document might need saving ( new, modified or in ODF1.1 format without signature ) @@ -1951,7 +1951,7 @@ bool SfxObjectShell::SignDocumentContentUsingCertificate(const Reference<XCertif OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage())); if (IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() - || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion.compareTo(ODFVER_012_TEXT) < 0 && !bHasSign)) + || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion.compareTo(u"" ODFVER_012_TEXT) < 0 && !bHasSign)) { if (nVersion >= SvtSaveOptions::ODFSVER_012) { diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index d5803e1b0029..9bc9c17e4628 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1198,7 +1198,7 @@ bool SfxObjectShell::SaveTo_Impl // document, but technically this is not correct, so this prevents old // signatures to be copied over to a version 1.2 document bNoPreserveForOasis = ( - (0 <= aODFVersion.compareTo(ODFVER_012_TEXT) && nVersion < SvtSaveOptions::ODFSVER_012) || + (0 <= aODFVersion.compareTo(u"" ODFVER_012_TEXT) && nVersion < SvtSaveOptions::ODFSVER_012) || (aODFVersion.isEmpty() && nVersion >= SvtSaveOptions::ODFSVER_012) ); } diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx index 65145a21a96d..796ce0d5227a 100644 --- a/sfx2/source/doc/oleprops.cxx +++ b/sfx2/source/doc/oleprops.cxx @@ -303,7 +303,7 @@ OUString SfxOleStringHelper::ImplLoadString16( SvStream& rStrm ) return aValue; } -void SfxOleStringHelper::ImplSaveString8( SvStream& rStrm, const OUString& rValue ) const +void SfxOleStringHelper::ImplSaveString8( SvStream& rStrm, std::u16string_view rValue ) const { // encode to byte string OString aEncoded(OUStringToOString(rValue, GetTextEncoding())); diff --git a/sfx2/source/doc/oleprops.hxx b/sfx2/source/doc/oleprops.hxx index 66b4e1c7d1aa..81eb744eab89 100644 --- a/sfx2/source/doc/oleprops.hxx +++ b/sfx2/source/doc/oleprops.hxx @@ -22,6 +22,8 @@ #include <map> #include <memory> +#include <string_view> + #include <osl/thread.h> #include <rtl/ustring.hxx> #include <sot/storage.hxx> @@ -152,7 +154,7 @@ public: private: OUString ImplLoadString8( SvStream& rStrm ) const; static OUString ImplLoadString16( SvStream& rStrm ); - void ImplSaveString8( SvStream& rStrm, const OUString& rValue ) const; + void ImplSaveString8( SvStream& rStrm, std::u16string_view rValue ) const; static void ImplSaveString16( SvStream& rStrm, const OUString& rValue ); }; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 0bfbe7ba2484..fcf651bafb05 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -538,7 +538,7 @@ IMPL_LINK(SfxTemplateManagerDlg, MenuSelectHdl, const OString&, rIdent, void) DefaultTemplateMenuSelectHdl(rIdent); } -void SfxTemplateManagerDlg::DefaultTemplateMenuSelectHdl(const OString& rIdent) +void SfxTemplateManagerDlg::DefaultTemplateMenuSelectHdl(std::string_view rIdent) { OUString aServiceName = SfxObjectShell::GetServiceNameFromFactory(OUString::fromUtf8(rIdent)); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 38bd2445e747..44af64e02016 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -456,7 +456,7 @@ void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView, vcl::LOKWindowId nLOKWindowId, - const OUString& rAction, + std::u16string_view rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) { assert(pThisView != nullptr && "pThisView must be valid"); |