From cbaf1fbaa6e707d939f815eda360fad68a492aca Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 11 Apr 2022 22:24:20 +0200 Subject: loplugin:stringview more o3tl conversion look for call sequences that can use string_view and the new o3tl functions in o3tl/string_view.hxx Also add a few more wrappers to said #include file Change-Id: I05d8752cc67a7b55b0b57e8eed803bd06bfcd9ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132840 Tested-by: Jenkins Reviewed-by: Noel Grandin --- desktop/source/deployment/inc/dp_platform.hxx | 2 +- desktop/source/deployment/misc/dp_descriptioninfoset.cxx | 7 ++++--- desktop/source/deployment/misc/dp_platform.cxx | 5 +++-- desktop/source/deployment/registry/component/dp_component.cxx | 5 +++-- .../deployment/registry/configuration/dp_configuration.cxx | 11 ++++++----- desktop/source/deployment/registry/package/dp_package.cxx | 2 +- desktop/source/migration/migration.cxx | 2 +- desktop/source/offacc/acceptor.cxx | 3 ++- desktop/source/splash/splash.cxx | 8 ++++---- 9 files changed, 25 insertions(+), 20 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/inc/dp_platform.hxx b/desktop/source/deployment/inc/dp_platform.hxx index 9547bc07df18..5e454700d276 100644 --- a/desktop/source/deployment/inc/dp_platform.hxx +++ b/desktop/source/deployment/inc/dp_platform.hxx @@ -29,7 +29,7 @@ namespace dp_misc DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString const& getPlatformString(); DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -bool platform_fits(OUString const& platform_string); +bool platform_fits(std::u16string_view platform_string); /** determines if the current platform corresponds to one of the platform strings. diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 00315cb3bad5..00b32c04f2c4 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -56,6 +56,7 @@ #include #include #include +#include namespace { @@ -473,7 +474,7 @@ css::uno::Sequence< OUString > DescriptionInfoset::getSupportedPlatforms() const sal_Int32 nIndex = 0; do { - const OUString aToken = value.getToken( 0, ',', nIndex ).trim(); + const OUString aToken( o3tl::trim(o3tl::getToken(value, 0, ',', nIndex )) ); if (!aToken.isEmpty()) vec.push_back(aToken); @@ -651,13 +652,13 @@ DescriptionInfoset::getSimpleLicenseAttributes() const ::std::optional< OUString > suppressOnUpdate = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-on-update"); if (suppressOnUpdate) - attributes.suppressOnUpdate = (*suppressOnUpdate).trim().equalsIgnoreAsciiCase("true"); + attributes.suppressOnUpdate = o3tl::equalsIgnoreAsciiCase(o3tl::trim(*suppressOnUpdate), u"true"); else attributes.suppressOnUpdate = false; ::std::optional< OUString > suppressIfRequired = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-if-required"); if (suppressIfRequired) - attributes.suppressIfRequired = (*suppressIfRequired).trim().equalsIgnoreAsciiCase("true"); + attributes.suppressIfRequired = o3tl::equalsIgnoreAsciiCase(o3tl::trim(*suppressIfRequired), u"true"); else attributes.suppressIfRequired = false; diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 79fb78c0b9ba..90dee4a6d1c2 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -23,6 +23,7 @@ #include #include #include +#include constexpr OUStringLiteral PLATFORM_ALL = u"all"; @@ -167,13 +168,13 @@ OUString const & getPlatformString() return StrPlatform::get(); } -bool platform_fits( OUString const & platform_string ) +bool platform_fits( std::u16string_view platform_string ) { sal_Int32 index = 0; for (;;) { const OUString token( - platform_string.getToken( 0, ',', index ).trim() ); + o3tl::trim(o3tl::getToken(platform_string, 0, ',', index )) ); // check if this platform: if (token.equalsIgnoreAsciiCase( StrPlatform::get() ) || (token.indexOf( '_' ) < 0 && /* check OS part only */ diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index d29229aa5a05..8bee3d4ee0b3 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -751,7 +752,7 @@ void BackendImpl::unorc_verify_init( { sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1; do { - OUString token( line.getToken( 0, ' ', index ).trim() ); + OUString token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) ); if (!token.isEmpty()) { if (create_ucb_content( @@ -772,7 +773,7 @@ void BackendImpl::unorc_verify_init( RTL_TEXTENCODING_UTF8 )) { sal_Int32 index = sizeof ("UNO_TYPES=") - 1; do { - OUString token( line.getToken( 0, ' ', index ).trim() ); + OUString token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) ); if (!token.isEmpty()) { if (token[ 0 ] == '?') diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index e2fb409c2f6a..62d5ab88fc68 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -385,7 +386,7 @@ void BackendImpl::configmgrini_verify_init( { sal_Int32 index = RTL_CONSTASCII_LENGTH("SCHEMA="); do { - OUString token( line.getToken( 0, ' ', index ).trim() ); + OUString token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) ); if (!token.isEmpty()) { //The file may not exist anymore if a shared or bundled //extension was removed, but it can still be in the configmgrini. @@ -400,16 +401,16 @@ void BackendImpl::configmgrini_verify_init( RTL_TEXTENCODING_UTF8 )) { sal_Int32 index = RTL_CONSTASCII_LENGTH("DATA="); do { - OUString token( line.getToken( 0, ' ', index ).trim() ); - if (!token.isEmpty()) + std::u16string_view token( o3tl::trim(o3tl::getToken(line, 0, ' ', index )) ); + if (!token.empty()) { if (token[ 0 ] == '?') - token = token.copy( 1 ); + token = token.substr( 1 ); //The file may not exist anymore if a shared or bundled //extension was removed, but it can still be in the configmgrini. //After running XExtensionManager::synchronize, the configmgrini is //cleaned up - m_xcu_files.push_back( token ); + m_xcu_files.push_back( OUString(token) ); } } while (index >= 0); diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 321db824f40c..2fc698467931 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -1487,7 +1487,7 @@ void BackendImpl::PackageImpl::scanLegacyBundle( // check for platform paths: const OUString title( StrTitle::getTitle( ucbContent ) ); if (title.endsWithIgnoreAsciiCase( ".plt" ) && - !platform_fits( title.copy( 0, title.getLength() - 4 ) )) { + !platform_fits( title.subView( 0, title.getLength() - 4 ) )) { return; } if (title.endsWithIgnoreAsciiCase("skip_registration") ) diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 7d3b272973be..42a02fa2cf76 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -941,7 +941,7 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat OUString sParentNodeName = elem.m_sParentNodeName; sal_Int32 nIndex = 0; do { - OUString sToken = sParentNodeName.getToken(0, '|', nIndex).trim(); + OUString sToken( o3tl::trim(o3tl::getToken(sParentNodeName, 0, '|', nIndex)) ); if (sToken.isEmpty()) break; diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index 7697c18b422f..8c6cdbff0461 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -26,6 +26,7 @@ #include #include #include +#include using namespace css::bridge; using namespace css::connection; @@ -151,7 +152,7 @@ void Acceptor::initialize( const Sequence& aArguments ) if (nIndex1 < 0) throw IllegalArgumentException( "Invalid accept-string format", m_rContext, 1); - m_aConnectString = m_aAcceptString.copy( 0 , nIndex1 ).trim(); + m_aConnectString = o3tl::trim(m_aAcceptString.subView( 0 , nIndex1 )); nIndex1++; sal_Int32 nIndex2 = m_aAcceptString.indexOf( ';' , nIndex1 ); if (nIndex2 < 0) nIndex2 = m_aAcceptString.getLength(); diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 7875d29829f8..2b557f7507f9 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -536,22 +536,22 @@ void SplashScreen::determineProgressRatioValues( if ( !sFullScreenProgressPos.isEmpty() ) { sal_Int32 idx = 0; - double temp = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble(); + double temp = o3tl::toDouble(o3tl::getToken(sFullScreenProgressPos, 0, ',', idx )); if ( idx != -1 ) { rXRelPos = temp; - rYRelPos = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble(); + rYRelPos = o3tl::toDouble(o3tl::getToken(sFullScreenProgressPos, 0, ',', idx )); } } if ( !sFullScreenProgressSize.isEmpty() ) { sal_Int32 idx = 0; - double temp = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble(); + double temp = o3tl::toDouble(o3tl::getToken(sFullScreenProgressSize, 0, ',', idx )); if ( idx != -1 ) { rRelWidth = temp; - rRelHeight = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble(); + rRelHeight = o3tl::toDouble(o3tl::getToken(sFullScreenProgressSize, 0, ',', idx )); } } } -- cgit