diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-28 17:56:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-29 16:42:33 +0100 |
commit | 042033f1e6da22616cb76c8d950c20c9efecbad5 (patch) | |
tree | 26b3f1f42d067506f44550b410f3fb9640616a5b /comphelper | |
parent | ccfd8e9d09f9ac0a0ea92d0f378391006faaf934 (diff) |
loplugin:stringviewparam: operator +
Change-Id: I044dd21b63d7eb03224675584fa143009c6b6008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108418
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/DirectoryHelper.cxx | 7 | ||||
-rw-r--r-- | comphelper/source/misc/backupfilehelper.cxx | 95 | ||||
-rw-r--r-- | comphelper/source/misc/configuration.cxx | 7 | ||||
-rw-r--r-- | comphelper/source/property/propertystatecontainer.cxx | 8 | ||||
-rw-r--r-- | comphelper/source/xml/ofopxmlhelper.cxx | 4 |
5 files changed, 66 insertions, 55 deletions
diff --git a/comphelper/source/misc/DirectoryHelper.cxx b/comphelper/source/misc/DirectoryHelper.cxx index 5b0ffbf68465..4ac2dfe7e829 100644 --- a/comphelper/source/misc/DirectoryHelper.cxx +++ b/comphelper/source/misc/DirectoryHelper.cxx @@ -142,7 +142,8 @@ bool DirectoryHelper::deleteDirRecursively(const OUString& rDirURL) } // both exist, move content -bool DirectoryHelper::moveDirContent(const OUString& rSourceDirURL, const OUString& rTargetDirURL, +bool DirectoryHelper::moveDirContent(const OUString& rSourceDirURL, + std::u16string_view rTargetDirURL, const std::set<OUString>& rExcludeList) { std::set<OUString> aDirs; @@ -161,7 +162,7 @@ bool DirectoryHelper::moveDirContent(const OUString& rSourceDirURL, const OUStri if (dirExists(aNewSourceDirURL)) { - const OUString aNewTargetDirURL(rTargetDirURL + "/" + dir); + const OUString aNewTargetDirURL(OUString::Concat(rTargetDirURL) + "/" + dir); if (dirExists(aNewTargetDirURL)) { @@ -185,7 +186,7 @@ bool DirectoryHelper::moveDirContent(const OUString& rSourceDirURL, const OUStri if (fileExists(aSourceFileURL)) { - OUString aTargetFileURL(rTargetDirURL + "/" + file.first); + OUString aTargetFileURL(OUString::Concat(rTargetDirURL) + "/" + file.first); if (!file.second.isEmpty()) { diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index fcde7879255b..c7bcd4253ed0 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -18,6 +18,7 @@ #include <algorithm> #include <deque> #include <memory> +#include <string_view> #include <vector> #include <zlib.h> @@ -172,30 +173,31 @@ namespace return osl_File_E_None == osl_writeFile(rHandle, static_cast<const void*>(rSource.getStr()), nLength, &nBaseWritten) && nLength == nBaseWritten; } - OUString createFileURL(const OUString& rURL, const OUString& rName, const OUString& rExt) + OUString createFileURL( + std::u16string_view rURL, std::u16string_view rName, std::u16string_view rExt) { OUString aRetval; - if (!rURL.isEmpty() && !rName.isEmpty()) + if (!rURL.empty() && !rName.empty()) { - aRetval = rURL + "/" + rName; + aRetval = OUString::Concat(rURL) + "/" + rName; - if (!rExt.isEmpty()) + if (!rExt.empty()) { - aRetval += "." + rExt; + aRetval += OUString::Concat(".") + rExt; } } return aRetval; } - OUString createPackURL(const OUString& rURL, const OUString& rName) + OUString createPackURL(std::u16string_view rURL, std::u16string_view rName) { OUString aRetval; - if (!rURL.isEmpty() && !rName.isEmpty()) + if (!rURL.empty() && !rName.empty()) { - aRetval = rURL + "/" + rName + ".pack"; + aRetval = OUString::Concat(rURL) + "/" + rName + ".pack"; } return aRetval; @@ -479,21 +481,24 @@ namespace } public: - void createUserExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) + void createUserExtensionRegistryEntriesFromXML(std::u16string_view rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/uno_packages/cache" + gaRegPath); + const OUString aPath( + OUString::Concat(rUserConfigWorkURL) + "/uno_packages/cache" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } - void createSharedExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) + void createSharedExtensionRegistryEntriesFromXML(std::u16string_view rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/extensions/shared" + gaRegPath); + const OUString aPath( + OUString::Concat(rUserConfigWorkURL) + "/extensions/shared" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } - void createBundledExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) + void createBundledExtensionRegistryEntriesFromXML(std::u16string_view rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/extensions/bundled" + gaRegPath); + const OUString aPath( + OUString::Concat(rUserConfigWorkURL) + "/extensions/bundled" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } @@ -657,7 +662,7 @@ namespace public: static void changeEnableDisableStateInXML( - const OUString& rUserConfigWorkURL, + std::u16string_view rUserConfigWorkURL, const ExtensionInfoEntryVector& rToBeEnabled, const ExtensionInfoEntryVector& rToBeDisabled) { @@ -665,7 +670,7 @@ namespace const OUString aRegPathBack(".PackageRegistryBackend/backenddb.xml"); // first appearance to check { - const OUString aUnoPackagReg(rUserConfigWorkURL + aRegPathFront + "bundle" + aRegPathBack); + const OUString aUnoPackagReg(OUString::Concat(rUserConfigWorkURL) + aRegPathFront + "bundle" + aRegPathBack); visitNodesXMLChangeOneCase( aUnoPackagReg, @@ -676,7 +681,7 @@ namespace // second appearance to check { - const OUString aUnoPackagReg(rUserConfigWorkURL + aRegPathFront + "configuration" + aRegPathBack); + const OUString aUnoPackagReg(OUString::Concat(rUserConfigWorkURL) + aRegPathFront + "configuration" + aRegPathBack); visitNodesXMLChangeOneCase( aUnoPackagReg, @@ -687,7 +692,7 @@ namespace // third appearance to check { - const OUString aUnoPackagReg(rUserConfigWorkURL + aRegPathFront + "script" + aRegPathBack); + const OUString aUnoPackagReg(OUString::Concat(rUserConfigWorkURL) + aRegPathFront + "script" + aRegPathBack); visitNodesXMLChangeOneCase( aUnoPackagReg, @@ -2017,8 +2022,8 @@ namespace comphelper bool BackupFileHelper::tryPush_Files( const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, - const OUString& rSourceURL, // source dir without trailing '/' - const OUString& rTargetURL // target dir without trailing '/' + std::u16string_view rSourceURL, // source dir without trailing '/' + const OUString& rTargetURL // target dir without trailing '/' ) { bool bDidPush(false); @@ -2037,7 +2042,7 @@ namespace comphelper // process dirs for (const auto& dir : rDirs) { - OUString aNewSourceURL(rSourceURL + "/" + dir); + OUString aNewSourceURL(OUString::Concat(rSourceURL) + "/" + dir); OUString aNewTargetURL(rTargetURL + "/" + dir); std::set< OUString > aNewDirs; std::set< std::pair< OUString, OUString > > aNewFiles; @@ -2067,10 +2072,10 @@ namespace comphelper } bool BackupFileHelper::tryPush_file( - const OUString& rSourceURL, // source dir without trailing '/' - const OUString& rTargetURL, // target dir without trailing '/' - const OUString& rName, // filename - const OUString& rExt // extension (or empty) + std::u16string_view rSourceURL, // source dir without trailing '/' + std::u16string_view rTargetURL, // target dir without trailing '/' + std::u16string_view rName, // filename + std::u16string_view rExt // extension (or empty) ) { const OUString aFileURL(createFileURL(rSourceURL, rName, rExt)); @@ -2099,8 +2104,8 @@ namespace comphelper bool BackupFileHelper::isPopPossible_files( const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, - const OUString& rSourceURL, // source dir without trailing '/' - const OUString& rTargetURL // target dir without trailing '/' + std::u16string_view rSourceURL, // source dir without trailing '/' + std::u16string_view rTargetURL // target dir without trailing '/' ) { bool bPopPossible(false); @@ -2118,8 +2123,8 @@ namespace comphelper // process dirs for (const auto& dir : rDirs) { - OUString aNewSourceURL(rSourceURL + "/" + dir); - OUString aNewTargetURL(rTargetURL + "/" + dir); + OUString aNewSourceURL(OUString::Concat(rSourceURL) + "/" + dir); + OUString aNewTargetURL(OUString::Concat(rTargetURL) + "/" + dir); std::set< OUString > aNewDirs; std::set< std::pair< OUString, OUString > > aNewFiles; @@ -2142,10 +2147,10 @@ namespace comphelper } bool BackupFileHelper::isPopPossible_file( - const OUString& rSourceURL, // source dir without trailing '/' - const OUString& rTargetURL, // target dir without trailing '/' - const OUString& rName, // filename - const OUString& rExt // extension (or empty) + std::u16string_view rSourceURL, // source dir without trailing '/' + std::u16string_view rTargetURL, // target dir without trailing '/' + std::u16string_view rName, // filename + std::u16string_view rExt // extension (or empty) ) { const OUString aFileURL(createFileURL(rSourceURL, rName, rExt)); @@ -2166,7 +2171,7 @@ namespace comphelper bool BackupFileHelper::tryPop_files( const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, - const OUString& rSourceURL, // source dir without trailing '/' + std::u16string_view rSourceURL, // source dir without trailing '/' const OUString& rTargetURL // target dir without trailing '/' ) { @@ -2185,7 +2190,7 @@ namespace comphelper // process dirs for (const auto& dir : rDirs) { - OUString aNewSourceURL(rSourceURL + "/" + dir); + OUString aNewSourceURL(OUString::Concat(rSourceURL) + "/" + dir); OUString aNewTargetURL(rTargetURL + "/" + dir); std::set< OUString > aNewDirs; std::set< std::pair< OUString, OUString > > aNewFiles; @@ -2215,10 +2220,10 @@ namespace comphelper } bool BackupFileHelper::tryPop_file( - const OUString& rSourceURL, // source dir without trailing '/' - const OUString& rTargetURL, // target dir without trailing '/' - const OUString& rName, // filename - const OUString& rExt // extension (or empty) + std::u16string_view rSourceURL, // source dir without trailing '/' + std::u16string_view rTargetURL, // target dir without trailing '/' + std::u16string_view rName, // filename + std::u16string_view rExt // extension (or empty) ) { const OUString aFileURL(createFileURL(rSourceURL, rName, rExt)); @@ -2268,7 +2273,7 @@ namespace comphelper /////////////////// ExtensionInfo helpers /////////////////////// bool BackupFileHelper::tryPush_extensionInfo( - const OUString& rTargetURL // target dir without trailing '/' + std::u16string_view rTargetURL // target dir without trailing '/' ) { ExtensionInfo aExtensionInfo; @@ -2278,7 +2283,7 @@ namespace comphelper // create current configuration and write to temp file - it exists until deleted if (aExtensionInfo.createTempFile(aTempURL)) { - const OUString aPackURL(createPackURL(rTargetURL, "ExtensionInfo")); + const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo")); PackedFile aPackedFile(aPackURL); FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL); @@ -2297,22 +2302,22 @@ namespace comphelper } bool BackupFileHelper::isPopPossible_extensionInfo( - const OUString& rTargetURL // target dir without trailing '/' + std::u16string_view rTargetURL // target dir without trailing '/' ) { // extensionInfo always exists internally, no test needed - const OUString aPackURL(createPackURL(rTargetURL, "ExtensionInfo")); + const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo")); PackedFile aPackedFile(aPackURL); return !aPackedFile.empty(); } bool BackupFileHelper::tryPop_extensionInfo( - const OUString& rTargetURL // target dir without trailing '/' + std::u16string_view rTargetURL // target dir without trailing '/' ) { // extensionInfo always exists internally, no test needed - const OUString aPackURL(createPackURL(rTargetURL, "ExtensionInfo")); + const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo")); PackedFile aPackedFile(aPackURL); if (!aPackedFile.empty()) diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx index a4041de4bb54..56b186dea805 100644 --- a/comphelper/source/misc/configuration.cxx +++ b/comphelper/source/misc/configuration.cxx @@ -11,6 +11,7 @@ #include <cassert> #include <memory> +#include <string_view> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/configuration/ReadOnlyAccess.hpp> @@ -53,14 +54,14 @@ OUString getDefaultLocale( getLocale()).getBcp47(false); } -OUString extendLocalizedPath(OUString const & path, OUString const & locale) { +OUString extendLocalizedPath(std::u16string_view path, OUString const & locale) { SAL_WARN_IF( locale.match("*"), "comphelper", "Locale \"" << locale << "\" starts with \"*\""); assert(locale.indexOf('&') == -1); assert(locale.indexOf('"') == -1); assert(locale.indexOf('\'') == -1); - return path + "/['*" + locale + "']"; + return OUString::Concat(path) + "/['*" + locale + "']"; } } @@ -145,7 +146,7 @@ void comphelper::detail::ConfigurationWrapper::setPropertyValue( css::uno::Any comphelper::detail::ConfigurationWrapper::getLocalizedPropertyValue( - OUString const & path) const + std::u16string_view path) const { return access_->getByHierarchicalName( extendLocalizedPath(path, getDefaultLocale(context_))); diff --git a/comphelper/source/property/propertystatecontainer.cxx b/comphelper/source/property/propertystatecontainer.cxx index 35598b262a68..e19e78733689 100644 --- a/comphelper/source/property/propertystatecontainer.cxx +++ b/comphelper/source/property/propertystatecontainer.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <comphelper/propertystatecontainer.hxx> @@ -30,13 +34,13 @@ namespace comphelper namespace { - OUString lcl_getUnknownPropertyErrorMessage( const OUString& _rPropertyName ) + OUString lcl_getUnknownPropertyErrorMessage( std::u16string_view _rPropertyName ) { // TODO: perhaps it's time to think about resources in the comphelper module? // Would be nice to have localized exception strings (a simply resource file containing // strings only would suffice, and could be realized with a UNO service, so we do not // need the dependency to the Tools project) - return "The property \"" + _rPropertyName + "\" is unknown."; + return OUString::Concat("The property \"") + _rPropertyName + "\" is unknown."; } } diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx index 3bf5984f9d83..2da35bdd0a3a 100644 --- a/comphelper/source/xml/ofopxmlhelper.cxx +++ b/comphelper/source/xml/ofopxmlhelper.cxx @@ -79,10 +79,10 @@ static uno::Sequence<uno::Sequence< beans::StringPair>> ReadSequence_Impl( uno::Sequence< uno::Sequence< beans::StringPair > > ReadRelationsInfoSequence( const uno::Reference< io::XInputStream >& xInStream, - const OUString & aStreamName, + std::u16string_view aStreamName, const uno::Reference< uno::XComponentContext >& rContext ) { - OUString aStringID = "_rels/" + aStreamName; + OUString aStringID = OUString::Concat("_rels/") + aStreamName; return ReadSequence_Impl( xInStream, aStringID, RELATIONINFO_FORMAT, rContext ); } |