diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 22:24:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-12 12:42:15 +0200 |
commit | cbaf1fbaa6e707d939f815eda360fad68a492aca (patch) | |
tree | 20b3dfeac257130afb01572b2c117b7840d07007 | |
parent | f751417b77e6573a0c639778e76ec943449f4573 (diff) |
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 <noel.grandin@collabora.co.uk>
87 files changed, 252 insertions, 163 deletions
diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx index 7418b80a8d5a..55fe31cda1a7 100644 --- a/chart2/qa/extras/chart2dump/chart2dump.cxx +++ b/chart2/qa/extras/chart2dump/chart2dump.cxx @@ -203,15 +203,15 @@ protected: // Convert string back to a transformation; drawing::HomogenMatrix3 aExpectedTransform; sal_Int32 nIdx {0}; - aExpectedTransform.Line1.Column1 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line1.Column2 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line1.Column3 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line2.Column1 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line2.Column2 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line2.Column3 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line3.Column1 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line3.Column2 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); - aExpectedTransform.Line3.Column3 = rExpectedTransform.getToken(0, ';', nIdx).toDouble(); + aExpectedTransform.Line1.Column1 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line1.Column2 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line1.Column3 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line2.Column1 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line2.Column2 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line2.Column3 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line3.Column1 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line3.Column2 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); + aExpectedTransform.Line3.Column3 = o3tl::toDouble(o3tl::getToken(rExpectedTransform, 0, ';', nIdx)); // Check the equality of the two transformation return (std::abs(aExpectedTransform.Line1.Column1 - rTransform.Line1.Column1) < fEPS && diff --git a/comphelper/source/misc/sequenceashashmap.cxx b/comphelper/source/misc/sequenceashashmap.cxx index b2021e7b85fa..21a7f0971b94 100644 --- a/comphelper/source/misc/sequenceashashmap.cxx +++ b/comphelper/source/misc/sequenceashashmap.cxx @@ -88,7 +88,7 @@ uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree) else if (aTypeClass == uno::TypeClass_FLOAT) aAny <<= OString(rValue.c_str()).toFloat(); else if (aTypeClass == uno::TypeClass_DOUBLE) - aAny <<= OString(rValue.c_str()).toDouble(); + aAny <<= o3tl::toDouble(rValue); else if (aTypeClass == uno::TypeClass_STRING) aAny <<= OUString::fromUtf8(rValue.c_str()); } diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index e706f4b397da..bcb8b79eded6 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -47,7 +47,12 @@ public: loplugin::isSamePathname(fn, SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx") || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx") || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx") - || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/oustring/rtl_OUString2.cxx")); + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/oustring/rtl_OUString2.cxx") + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx") + || loplugin::isSamePathname(fn, + SRCDIR "/sal/qa/rtl/strings/test_oustring_startswith.cxx") + || loplugin::isSamePathname(fn, SRCDIR + "/sal/qa/rtl/strings/test_strings_defaultstringview.cxx")); } virtual void run() override @@ -371,7 +376,10 @@ bool StringView::VisitCXXMemberCallExpr(CXXMemberCallExpr const* expr) || tc.Class("OString").Namespace("rtl").GlobalNamespace()) { auto const dc = loplugin::DeclCheck(expr->getMethodDecl()); - if (dc.Function("toInt32") || dc.Function("toInt64")) + if (dc.Function("toInt32") || dc.Function("toInt64") || dc.Function("toDouble") + || dc.Function("equalsIgnoreAsciiCase") || dc.Function("compareToIgnoreAsciiCase") + || dc.Function("trim") || dc.Function("startsWith") || dc.Function("endsWith") + || dc.Function("match")) { handleSubExprThatCouldBeView(expr->getImplicitObjectArgument()); } diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx index 9b75d69ba46c..ef8c14e5a9eb 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.cxx +++ b/connectivity/source/drivers/postgresql/pq_tools.cxx @@ -37,6 +37,7 @@ #include <sal/config.h> #include <o3tl/any.hxx> +#include <o3tl/string_view.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> @@ -361,7 +362,7 @@ OUString extractTableFromInsert( const OUString & sql ) } } } - ret = sql.copy(start, i - start ).trim(); + ret = o3tl::trim(sql.subView(start, i - start )); // printf( "pq_statement: parsed table name %s from insert\n" , // OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US).getStr() ); } diff --git a/dbaccess/source/filter/hsqldb/createparser.cxx b/dbaccess/source/filter/hsqldb/createparser.cxx index 67607ac8aae2..c62640e8bc3f 100644 --- a/dbaccess/source/filter/hsqldb/createparser.cxx +++ b/dbaccess/source/filter/hsqldb/createparser.cxx @@ -19,6 +19,7 @@ #include <comphelper/string.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include "createparser.hxx" #include "utils.hxx" #include <com/sun/star/sdbc/DataType.hpp> @@ -79,17 +80,21 @@ sal_Int32 lcl_getAutoIncrementDefault(std::u16string_view sColumnDef) return -1; } -OUString lcl_getDefaultValue(const OUString& sColumnDef) +OUString lcl_getDefaultValue(std::u16string_view sColumnDef) { - constexpr char DEFAULT_KW[] = "DEFAULT"; - auto nDefPos = sColumnDef.indexOf(DEFAULT_KW); - if (nDefPos > 0 && lcl_getAutoIncrementDefault(sColumnDef) < 0) + constexpr std::u16string_view DEFAULT_KW = u"DEFAULT"; + auto nDefPos = sColumnDef.find(DEFAULT_KW); + if (nDefPos > 0 && nDefPos != std::u16string_view::npos + && lcl_getAutoIncrementDefault(sColumnDef) < 0) { - const OUString& fromDefault = sColumnDef.copy(nDefPos + sizeof(DEFAULT_KW)).trim(); + std::u16string_view fromDefault + = o3tl::trim(sColumnDef.substr(nDefPos + DEFAULT_KW.size())); // next word is the value - auto nNextSpace = fromDefault.indexOf(" "); - return nNextSpace > 0 ? fromDefault.copy(0, fromDefault.indexOf(" ")) : fromDefault; + auto nNextSpace = fromDefault.find(' '); + return OUString((nNextSpace > 0 && nNextSpace != std::u16string_view::npos) + ? fromDefault.substr(0, nNextSpace) + : fromDefault); } return OUString{}; } @@ -176,7 +181,7 @@ ColumnTypeParts lcl_getColumnTypeParts(const OUString& sFullTypeName) auto nParenPos = sFullTypeName.indexOf("("); if (nParenPos > 0) { - parts.typeName = sFullTypeName.copy(0, nParenPos).trim(); + parts.typeName = o3tl::trim(sFullTypeName.subView(0, nParenPos)); OUString sParamStr = sFullTypeName.copy(nParenPos + 1, sFullTypeName.indexOf(")") - nParenPos - 1); auto sParams = string::split(sParamStr, sal_Unicode(u',')); @@ -239,7 +244,7 @@ void CreateStmtParser::parseColumnPart(std::u16string_view sColumnPart) = bIsQuoteUsedForColumnName ? sColumn.indexOf("\"", 1) + 1 : sColumn.indexOf(" "); OUString rColumnName = sColumn.copy(0, nEndColumnName); - const OUString& sFromTypeName = sColumn.copy(nEndColumnName).trim(); + const OUString sFromTypeName(o3tl::trim(sColumn.subView(nEndColumnName))); // Now let's manage the column type // search next space to get the whole type name 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 <rtl/ustring.hxx> #include <sal/types.h> #include <ucbhelper/content.hxx> +#include <o3tl/string_view.hxx> 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 <rtl/instance.hxx> #include <rtl/bootstrap.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> 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 <xmlscript/xml_helper.hxx> #include <svl/inettype.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/deployment/DeploymentException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -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 <xmlscript/xml_helper.hxx> #include <comphelper/lok.hxx> #include <svl/inettype.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/configuration/Update.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -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 <cppuhelper/supportsservice.hxx> #include <sal/log.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> using namespace css::bridge; using namespace css::connection; @@ -151,7 +152,7 @@ void Acceptor::initialize( const Sequence<Any>& 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 )); } } } diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 5ba35cec81a5..d55a636fcc14 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -112,7 +112,7 @@ static SfxObjectShell* findShellForUrl( const OUString& sMacroURLOrPath ) uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); xProps->getPropertyValue("Title") >>= aName; - aName = aName.getToken(0, '-').trim(); + aName = o3tl::trim(o3tl::getToken(aName, 0, '-')); if( sMacroURLOrPath.lastIndexOf( aName ) >= 0 ) { pFoundShell = pShell; @@ -727,7 +727,7 @@ void applyShortCutKeyBinding ( const uno::Reference< frame::XModel >& rxModel, c { OUString aMacroName = MacroName.trim(); if( aMacroName.startsWith("!") ) - aMacroName = aMacroName.copy(1).trim(); + aMacroName = o3tl::trim(aMacroName.subView(1)); SfxObjectShell* pShell = nullptr; if ( rxModel.is() ) { diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 72b3b7733062..4090189a3cf6 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -70,6 +70,7 @@ #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include "fpinteraction.hxx" #include <osl/process.h> +#include <o3tl/string_view.hxx> #include <officecfg/Office/Common.hxx> @@ -133,7 +134,7 @@ namespace { if ( !rLastFilterExt.isEmpty() ) { - if ( rFile.copy( nDotPos + 1 ).equalsIgnoreAsciiCase( rLastFilterExt ) ) + if ( o3tl::equalsIgnoreAsciiCase(rFile.subView( nDotPos + 1 ), rLastFilterExt ) ) return rLastFilterExt; } else diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index cb63ed31d232..c1d2eda94b60 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -673,7 +673,7 @@ bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescrip } } - if (aURL.isEmpty() || aURL.copy(0,8).equalsIgnoreAsciiCase("private:")) + if (aURL.isEmpty() || o3tl::equalsIgnoreAsciiCase(aURL.subView(0,8), u"private:")) return false; // TODO : Type must be set to be generic_Text (or any other type that diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index 5d3c7fcc43e2..dec21bd70338 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -17,6 +17,7 @@ #include <string_view> #include <rtl/ustring.h> +#include <rtl/math.h> namespace o3tl { @@ -31,6 +32,16 @@ inline bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2 == 0; }; +inline bool equalsIgnoreAsciiCase(std::string_view s1, std::string_view s2) +{ + if (s1.size() != s2.size()) + return false; + if (s1.data() == s2.data()) + return true; + return rtl_str_compareIgnoreAsciiCase_WithLength(s1.data(), s1.size(), s2.data(), s2.size()) + == 0; +}; + // Like OUString::compareToIgnoreAsciiCase, but for two std::u16string_view: inline int compareToIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2) { @@ -404,6 +415,16 @@ inline sal_Int64 toInt64(std::string_view str, sal_Int16 radix = 10) { return rtl_str_toInt64_WithLength(str.data(), radix, str.size()); } + +// Like OString::toDouble, but for std::string_view: +inline double toDouble(std::u16string_view str) +{ + return rtl_math_uStringToDouble(str.data(), str.data() + str.size(), '.', 0, nullptr, nullptr); +} +inline double toDouble(std::string_view str) +{ + return rtl_math_stringToDouble(str.data(), str.data() + str.size(), '.', 0, nullptr, nullptr); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/oox/ole/vbahelper.hxx b/include/oox/ole/vbahelper.hxx index 89a513d510cf..248d09810d3e 100644 --- a/include/oox/ole/vbahelper.hxx +++ b/include/oox/ole/vbahelper.hxx @@ -80,7 +80,7 @@ namespace VbaHelper bool extractKeyValue( OUString& rKey, OUString& rValue, - const OUString& rKeyValue ); + std::u16string_view rKeyValue ); } diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx index 78a2b7f27578..29d726a2bdba 100644 --- a/include/oox/vml/vmlformatting.hxx +++ b/include/oox/vml/vmlformatting.hxx @@ -58,7 +58,7 @@ namespace ConversionHelper */ OOX_DLLPUBLIC bool separatePair( OUString& orValue1, OUString& orValue2, - const OUString& rValue, sal_Unicode cSep ); + std::u16string_view rValue, sal_Unicode cSep ); /** Returns the boolean value from the passed string of a VML attribute. Supported values: 'f', 't', 'false', 'true'. False for anything else. diff --git a/include/oox/vml/vmlshapecontext.hxx b/include/oox/vml/vmlshapecontext.hxx index 49fc6826ae5a..5d7004ef59e0 100644 --- a/include/oox/vml/vmlshapecontext.hxx +++ b/include/oox/vml/vmlshapecontext.hxx @@ -106,7 +106,7 @@ public: private: /** Processes the 'style' attribute. */ - void setStyle( const OUString& rStyle ); + void setStyle( std::u16string_view rStyle ); /** Resolve a relation identifier to a fragment path. */ OptValue< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const; diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx index 0f5a547e6ff3..15720b2423b2 100644 --- a/io/source/connector/connector.cxx +++ b/io/source/connector/connector.cxx @@ -25,6 +25,7 @@ #include <cppuhelper/unourl.hxx> #include <rtl/malformeduriexception.hxx> #include <rtl/ref.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/connection/ConnectionSetupException.hpp> @@ -139,7 +140,7 @@ Reference< XConnection > SAL_CALL OConnector::connect( const OUString& sConnecti sal_Int32 index = sConnectionDescription.indexOf(','); - r = xConnector->connect(sConnectionDescription.copy(index + 1).trim()); + r = xConnector->connect(OUString(o3tl::trim(sConnectionDescription.subView(index + 1)))); } return r; } diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx index bb5df10a9c4d..225437011fdd 100644 --- a/jvmfwk/source/fwkbase.cxx +++ b/jvmfwk/source/fwkbase.cxx @@ -23,6 +23,7 @@ #include <libxml/xpathInternals.h> #include <osl/file.hxx> #include <osl/thread.hxx> +#include <o3tl/string_view.hxx> #include "framework.hxx" #include <fwkutil.hxx> #include <elements.hxx> @@ -429,7 +430,7 @@ OUString getApplicationClassPath() sal_Int32 index = 0; do { - OUString token( sParams.getToken( 0, ' ', index ).trim() ); + OUString token( o3tl::trim(o3tl::getToken(sParams, 0, ' ', index )) ); if (!token.isEmpty()) { OUString systemPathElement; diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index f8dc6fc3c478..31bf50fc9126 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -36,7 +36,9 @@ bool lcl_isNextGroup(OString &sGroup_out, std::string_view sLineTrim) { if (o3tl::starts_with(sLineTrim, "[") && o3tl::ends_with(sLineTrim, "]")) { - sGroup_out = OString(sLineTrim).getToken(1, '[').getToken(0, ']').trim(); + sLineTrim = o3tl::getToken(sLineTrim, 1, '['); + sLineTrim = o3tl::getToken(sLineTrim, 0, ']'); + sGroup_out = OString(o3tl::trim(sLineTrim)); return true; } return false; @@ -137,7 +139,7 @@ void LngParser::ReadLine(const OString &rLine_in, { if (!rLine_in.match(" *") && !rLine_in.match("/*")) { - OString sLang(rLine_in.getToken(0, '=').trim()); + OString sLang(o3tl::trim(o3tl::getToken(rLine_in, 0, '='))); if (!sLang.isEmpty()) { OString sText(rLine_in.getToken(1, '"')); rText_inout[sLang] = sText; diff --git a/l10ntools/source/propmerge.cxx b/l10ntools/source/propmerge.cxx index 0fa81e4fb5ac..7b74ab4d3cf8 100644 --- a/l10ntools/source/propmerge.cxx +++ b/l10ntools/source/propmerge.cxx @@ -8,6 +8,7 @@ */ #include <rtl/ustring.hxx> +#include <o3tl/string_view.hxx> #include <memory> #include <cstdlib> @@ -142,12 +143,12 @@ void PropParser::Extract( const OString& rPOFile ) const sal_Int32 nEqualSign = sLine.indexOf('='); if( nEqualSign != -1 ) { - OString sID = sLine.copy( 0, nEqualSign ).trim(); - OString sText = lcl_ConvertToUTF8( sLine.copy( nEqualSign + 1 ).trim() ); + std::string_view sID = o3tl::trim(sLine.subView( 0, nEqualSign )); + OString sText = lcl_ConvertToUTF8( OString(o3tl::trim(sLine.subView( nEqualSign + 1 ))) ); common::writePoEntry( "Propex", aPOStream, m_sSource, "property", - sID, OString(), OString(), sText); + OString(sID), OString(), OString(), sText); } } @@ -191,13 +192,13 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil if( !sLine.startsWith(" *") && !sLine.startsWith("/*") && nEqualSign != -1 ) { - const OString sID( sLine.copy( 0, sLine.indexOf('=') ).trim() ); + const OString sID( o3tl::trim(sLine.subView( 0, sLine.indexOf('=') )) ); ResData aResData( sID, m_sSource ); aResData.sResTyp = "property"; OString sNewText; if( m_sLang == "qtz" ) { - const OString sOriginText = lcl_ConvertToUTF8(sLine.copy( nEqualSign + 1 ).trim()); + const OString sOriginText = lcl_ConvertToUTF8(OString(o3tl::trim(sLine.subView( nEqualSign + 1 )))); sNewText = MergeEntrys::GetQTZText(aResData, sOriginText); } else if( pMergeDataFile ) diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx index c7e68a88165a..cd4efc2d4c93 100644 --- a/oox/source/drawingml/customshapepresetdata.cxx +++ b/oox/source/drawingml/customshapepresetdata.cxx @@ -29,13 +29,13 @@ namespace // Parses a string like: Value = (any) { (long) 19098 }, State = (com.sun.star.beans.PropertyState) DIRECT_VALUE, Name = "adj" void lcl_parseAdjustmentValue( std::vector<drawing::EnhancedCustomShapeAdjustmentValue>& rAdjustmentValues, - const OString& rValue) + std::string_view rValue) { sal_Int32 nIndex = 0; drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue; do { - OString aToken = rValue.getToken(0, ',', nIndex).trim(); + OString aToken(o3tl::trim(o3tl::getToken(rValue, 0, ',', nIndex))); static const char aNamePrefix[] = "Name = \""; static const char aValuePrefix[] = "Value = (any) { (long) "; if (aToken.startsWith(aNamePrefix)) @@ -78,7 +78,7 @@ void lcl_parseAdjustmentValues( { lcl_parseAdjustmentValue( rAdjustmentValues, - rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },"))); + rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },"))); } } } diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx index 6b48055aa679..e5377568a563 100644 --- a/oox/source/ole/vbahelper.cxx +++ b/oox/source/ole/vbahelper.cxx @@ -19,6 +19,7 @@ #include <oox/ole/vbahelper.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <oox/helper/binaryinputstream.hxx> namespace oox::ole { @@ -41,13 +42,13 @@ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData return !rInStrm.isEof() && (rInStrm.readData( rRecData, nRecSize ) == nRecSize); } -bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, const OUString& rKeyValue ) +bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, std::u16string_view rKeyValue ) { - sal_Int32 nEqSignPos = rKeyValue.indexOf( '=' ); - if( nEqSignPos > 0 ) + size_t nEqSignPos = rKeyValue.find( '=' ); + if( nEqSignPos > 0 && nEqSignPos != std::u16string_view::npos ) { - rKey = rKeyValue.copy( 0, nEqSignPos ).trim(); - rValue = rKeyValue.copy( nEqSignPos + 1 ).trim(); + rKey = o3tl::trim(rKeyValue.substr( 0, nEqSignPos )); + rValue = o3tl::trim(rKeyValue.substr( nEqSignPos + 1 )); return !rKey.isEmpty() && !rValue.isEmpty(); } return false; diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index d53e525989e6..21a2af75caed 100644 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/awt/KeyEvent.hpp> #include <osl/diagnose.h> #include <rtl/character.hxx> +#include <o3tl/string_view.hxx> #include <filter/msfilter/msvbahelper.hxx> #include <oox/helper/binaryinputstream.hxx> #include <oox/helper/storagebase.hxx> @@ -237,7 +238,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) procInfo.nPos = aSourceCode.getLength(); } } - else if ( mbExecutable && aCodeLine.trim().match("End Sub") ) + else if ( mbExecutable && o3tl::starts_with(o3tl::trim(aCodeLine), u"End Sub") ) { // un-matched End Sub if ( !procInfo.bInProcedure ) diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 2143647edec1..e195a1e94183 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -76,17 +76,17 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r } // namespace bool ConversionHelper::separatePair( OUString& orValue1, OUString& orValue2, - const OUString& rValue, sal_Unicode cSep ) + std::u16string_view rValue, sal_Unicode cSep ) { - sal_Int32 nSepPos = rValue.indexOf( cSep ); - if( nSepPos >= 0 ) + size_t nSepPos = rValue.find( cSep ); + if( nSepPos != std::u16string_view::npos ) { - orValue1 = rValue.copy( 0, nSepPos ).trim(); - orValue2 = rValue.copy( nSepPos + 1 ).trim(); + orValue1 = o3tl::trim(rValue.substr( 0, nSepPos )); + orValue2 = o3tl::trim(rValue.substr( nSepPos + 1 )); } else { - orValue1 = rValue.trim(); + orValue1 = o3tl::trim(rValue); } return !orValue1.isEmpty() && !orValue2.isEmpty(); } @@ -951,7 +951,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen while( nIndex >= 0 ) { OUString aName, aValue; - if (ConversionHelper::separatePair(aName, aValue, aStyle.getToken(0, ';', nIndex), ':')) + if (ConversionHelper::separatePair(aName, aValue, o3tl::getToken(aStyle, 0, ';', nIndex), ':')) { if (aName == "font-family") { diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index d5e7996cbada..a4d87bb0e9c9 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -157,9 +157,9 @@ ContextHandlerRef ShapeLayoutContext::onCreateContext( sal_Int32 nElement, const sal_Int32 nIndex = 0; while( nIndex >= 0 ) { - OUString aToken = aBlockIds.getToken( 0, ' ', nIndex ).trim(); - if( !aToken.isEmpty() ) - mrDrawing.registerBlockId( aToken.toInt32() ); + std::u16string_view aToken = o3tl::trim(o3tl::getToken(aBlockIds, 0, ' ', nIndex )); + if( !aToken.empty() ) + mrDrawing.registerBlockId( o3tl::toInt32(aToken) ); } } break; @@ -459,13 +459,13 @@ OptValue< OUString > ShapeTypeContext::decodeFragmentPath( const AttributeList& return oFragmentPath; } -void ShapeTypeContext::setStyle( const OUString& rStyle ) +void ShapeTypeContext::setStyle( std::u16string_view rStyle ) { sal_Int32 nIndex = 0; while( nIndex >= 0 ) { OUString aName, aValue; - if( ConversionHelper::separatePair( aName, aValue, rStyle.getToken( 0, ';', nIndex ), ':' ) ) + if( ConversionHelper::separatePair( aName, aValue, o3tl::getToken(rStyle, 0, ';', nIndex ), ':' ) ) { if( aName == "position" ) mrTypeModel.maPosition = aValue; else if( aName == "z-index" ) mrTypeModel.maZIndex = aValue; diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 2cf5ebfaf40d..00c56092ed2e 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -25,6 +25,7 @@ #include <oox/token/tokens.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> namespace oox::vml { @@ -213,7 +214,7 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper const & rParent, TextBox& while( nIndex >= 0 ) { OUString aName, aValue; - if( ConversionHelper::separatePair( aName, aValue, sStyle.getToken( 0, ';', nIndex ), ':' ) ) + if( ConversionHelper::separatePair( aName, aValue, o3tl::getToken(sStyle, 0, ';', nIndex ), ':' ) ) { if( aName == "layout-flow" ) rTextBox.maLayoutFlow = aValue; else if (aName == "mso-fit-shape-to-text") diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index a25bc615c382..a0de8b92102b 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -241,14 +241,14 @@ static OUString & getIniFileName_Impl() // get rid of a potential executable extension OUString progExt = ".bin"; if (fileName.getLength() > progExt.getLength() - && fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt)) + && o3tl::equalsIgnoreAsciiCase(fileName.subView(fileName.getLength() - progExt.getLength()), progExt)) { fileName = fileName.copy(0, fileName.getLength() - progExt.getLength()); } progExt = ".exe"; if (fileName.getLength() > progExt.getLength() - && fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt)) + && o3tl::equalsIgnoreAsciiCase(fileName.subView(fileName.getLength() - progExt.getLength()), progExt)) { fileName = fileName.copy(0, fileName.getLength() - progExt.getLength()); } diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index fb72699ea98b..068178d9dd07 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -25,6 +25,7 @@ #include <o3tl/unit_conversion.hxx> #include <rtl/math.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <com/sun/star/script/ArrayWrapper.hpp> #include <com/sun/star/script/XTypeConverter.hpp> @@ -866,7 +867,7 @@ protected: // always compile it in that grammar. Perhaps // css.sheet.FormulaParser should be used in future to directly // pass formula tokens when that API stabilizes. - if ( m_eGrammar != formula::FormulaGrammar::GRAM_API && ( sFormula.trim().startsWith("=") ) ) + if ( m_eGrammar != formula::FormulaGrammar::GRAM_API && ( o3tl::starts_with(o3tl::trim(sFormula), u"=") ) ) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 5fac35ea1833..9cf7968fbbba 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <rtl/character.hxx> +#include <o3tl/string_view.hxx> using namespace css; using namespace css::animations; @@ -709,7 +710,7 @@ void SdOOXMLExportTest2::testPresetShapesExport() size_t i = 0; while(i < SAL_N_ELEMENTS( sShapeTypeAndValues )) { OString sType( sShapeTypeAndValues[ i++ ] ); - for ( size_t j = 1 ; i < SAL_N_ELEMENTS( sShapeTypeAndValues ) && OString(sShapeTypeAndValues[i]).startsWith("adj") ; ++j ) { + for ( size_t j = 1 ; i < SAL_N_ELEMENTS( sShapeTypeAndValues ) && o3tl::starts_with(sShapeTypeAndValues[i], "adj") ; ++j ) { OString sXPath= sPattern.replaceFirst( sT, sType).replaceFirst( sN, OString::number(j) ); assertXPath(pXmlDocCT, sXPath, sPropertyName , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) ); assertXPath(pXmlDocCT, sXPath, sPropertyFmla , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) ); diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx index 3b80cacc985a..45af5f0e8f95 100644 --- a/sd/source/filter/ppt/pptinanimations.cxx +++ b/sd/source/filter/ppt/pptinanimations.cxx @@ -59,6 +59,7 @@ #include <sal/log.hxx> #include <tools/debug.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <svx/svdotext.hxx> #include <editeng/outlobj.hxx> @@ -859,8 +860,8 @@ void AnimationImporter::fillNode( Reference< XAnimationNode > const & xNode, con sal_Int32 nPos = aToken.indexOf( ',' ); if( nPos >= 0 ) { - pValues->Time = aToken.copy( 0, nPos ).toDouble(); - pValues->Progress = aToken.copy( nPos+1 ).toDouble(); + pValues->Time = o3tl::toDouble(aToken.subView( 0, nPos )); + pValues->Progress = o3tl::toDouble(aToken.subView( nPos+1 )); } pValues++; } diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 664d6c42b479..56700a223fbb 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -34,6 +34,7 @@ #include <tools/diagnose_ex.h> #include <sal/log.hxx> #include <vcl/EnumContext.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/ui/XSidebarPanel.hpp> @@ -495,7 +496,7 @@ void ResourceManager::ReadContextList ( for (const OUString& sValue : std::as_const(aValues)) { sal_Int32 nCharacterIndex (0); - const OUString sApplicationName (sValue.getToken(0, ',', nCharacterIndex).trim()); + const OUString sApplicationName (o3tl::trim(o3tl::getToken(sValue, 0, ',', nCharacterIndex))); if (nCharacterIndex < 0) { if (sApplicationName.getLength() == 0) @@ -512,20 +513,20 @@ void ResourceManager::ReadContextList ( } } - const OUString sContextName(sValue.getToken(0, ',', nCharacterIndex).trim()); + const OUString sContextName(o3tl::trim(o3tl::getToken(sValue, 0, ',', nCharacterIndex))); if (nCharacterIndex < 0) { OSL_FAIL("expecting three or four values per ContextList entry, separated by comma"); continue; } - const OUString sInitialState(sValue.getToken(0, ',', nCharacterIndex).trim()); + const OUString sInitialState(o3tl::trim(o3tl::getToken(sValue, 0, ',', nCharacterIndex))); // The fourth argument is optional. const OUString sMenuCommandOverride( nCharacterIndex < 0 ? OUString() - : sValue.getToken(0, ',', nCharacterIndex).trim()); + : OUString(o3tl::trim(o3tl::getToken(sValue, 0, ',', nCharacterIndex)))); const OUString sMenuCommand( sMenuCommandOverride.getLength() > 0 diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 8fa8bdd831cd..1799f9c8c2a5 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -55,7 +55,7 @@ static sal_Int32 makeMask( sal_Int32 n = 0; do { - OUString item( items.getToken( 0, ',', n ).trim() ); + OUString item( o3tl::trim(o3tl::getToken(items, 0, ',', n )) ); if ( item.isEmpty()) continue; sal_Int32 nPos = 0; diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx index 925bfc4d1944..3b341eea3d40 100644 --- a/svgio/source/svgreader/svgtextpathnode.cxx +++ b/svgio/source/svgreader/svgtextpathnode.cxx @@ -27,6 +27,7 @@ #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <basegfx/curve/b2dcubicbezier.hxx> #include <basegfx/curve/b2dbeziertools.hxx> +#include <o3tl/string_view.hxx> namespace svgio::svgreader { @@ -149,7 +150,7 @@ namespace svgio::svgreader if(basegfx::fTools::more(fSnippetWidth, 0.0)) { const OUString aText(getSource().getText()); - const OUString aTrimmedChars(aText.copy(nIndex, nLength).trim()); + const OUString aTrimmedChars(o3tl::trim(aText.subView(nIndex, nLength))); const double fEndPos(mfPosition + fSnippetWidth); if(!aTrimmedChars.isEmpty() && (mfPosition < mfBasegfxPathLength || fEndPos > 0.0)) diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 5dd32843d0dd..dd5b9fe00429 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -919,7 +919,7 @@ SvNumberformat::SvNumberformat(OUString& rString, sal_Int32 nSpacePos = sStr.indexOf(' '); if (nSpacePos >= 0) { - sParams = sStr.copy(nSpacePos+1).trim(); + sParams = o3tl::trim(sStr.subView(nSpacePos+1)); } //! eSymbolType is negative sal_uInt8 nNum = static_cast<sal_uInt8>(0 - (eSymbolType - BRACKET_SYMBOLTYPE_NATNUM0)); diff --git a/svx/source/gallery2/galini.cxx b/svx/source/gallery2/galini.cxx index d825fd1471d2..8cdfb23ae1a2 100644 --- a/svx/source/gallery2/galini.cxx +++ b/svx/source/gallery2/galini.cxx @@ -61,10 +61,10 @@ OUString GalleryBinaryEngineEntry::ReadStrFromIni(std::u16string_view aKeyName ) if( ( n = aKey.indexOf( '[' ) ) >= 1 ) { - aLocale = aKey.copy( n + 1 ).trim(); - aKey = aKey.copy( 0, n ).trim(); + aLocale = o3tl::trim(aKey.subView( n + 1 )); + aKey = o3tl::trim(aKey.subView( 0, n )); if( (n = aLocale.indexOf( ']' ) ) >= 1 ) - aLocale = aLocale.copy( 0, n ).trim(); + aLocale = o3tl::trim(aLocale.subView( 0, n )); } } SAL_INFO("svx", "ini file has '" << aKey << "' [ '" << aLocale << "' ] = '" << aValue << "'"); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9a4964dcbaf2..f8e597b8e1d2 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -123,6 +123,7 @@ #include <svx/scene3d.hxx> #include <rtl/character.hxx> #include <tools/UnitConversion.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -3156,7 +3157,7 @@ void SdrObject::MakeNameUnique(std::unordered_set<OUString>& rNameSet) { sal_Int32 nPos(sName.getLength() - 1); while (nPos > 0 && rtl::isAsciiDigit(sName[--nPos])); - sRootName = sName.copy(0, nPos + 1).trim(); + sRootName = o3tl::trim(sName.subView(0, nPos + 1)); } else sName += " 1"; diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index 4d6e56db37c0..85892826ed99 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -43,6 +43,7 @@ #include <svx/svxids.hrc> #include <svx/svdobjkind.hxx> #include <svx/strings.hrc> +#include <o3tl/string_view.hxx> #include <strings.hxx> #include "shapeimpl.hxx" @@ -1962,7 +1963,7 @@ static bool SvxUnoConvertResourceStringBuiltInToApi(const TranslateId* pSourceRe break; nLength--; } - OUString sStr = rString.copy(0, nLength).trim(); + std::u16string_view sStr = o3tl::trim(rString.subView(0, nLength)); for(int i = 0; i < nCount; ++i ) { @@ -1990,11 +1991,11 @@ static bool SvxUnoConvertResourceStringBuiltInFromApi(rtl::OUStringConstExpr con break; nLength--; } - OUString sStr = rString.copy(0, nLength).trim(); + std::u16string_view sStr = o3tl::trim(rString.subView(0, nLength)); for(int i = 0; i < nCount; ++i ) { - if( sStr == pSourceResIds[i] ) + if( sStr == pSourceResIds[i].asView() ) { OUString aReplace = SvxResId(pDestResIds[i]); rString = rString.replaceAt( 0, OUString(pSourceResIds[i]).getLength(), aReplace ); diff --git a/sw/qa/extras/fodfexport/fodfexport.cxx b/sw/qa/extras/fodfexport/fodfexport.cxx index 9fd8e3c82afc..53297da28c53 100644 --- a/sw/qa/extras/fodfexport/fodfexport.cxx +++ b/sw/qa/extras/fodfexport/fodfexport.cxx @@ -8,6 +8,7 @@ */ #include <swmodeltestbase.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -23,7 +24,7 @@ public: bool mustTestImportOf(const char* filename) const override { // Only test import of .fodt document - return OString(filename).endsWith(".odt") || OString(filename).endsWith(".fodt"); + return o3tl::ends_with(filename, ".odt") || o3tl::ends_with(filename, ".fodt"); } }; diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 5ba0fa510589..b5b4c8e012a3 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -42,6 +42,7 @@ #include <comphelper/processfactory.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/dibtools.hxx> +#include <o3tl/string_view.hxx> #include <swmodule.hxx> #include <swdll.hxx> @@ -237,7 +238,7 @@ private: setFilterOptions("XHTML"); else if (getTestName().indexOf("ReqIf") != -1) { - if (OString(filename).endsWith(".xhtml")) + if (o3tl::ends_with(filename, ".xhtml")) { setImportFilterOptions("xhtmlns=reqif-xhtml"); // Bypass filter detect. diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 9b3159fd347a..8db40efda7bf 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -62,6 +62,7 @@ #include <docsh.hxx> #include <IDocumentLayoutAccess.hxx> #include <rootfrm.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -73,7 +74,7 @@ public: */ bool mustTestImportOf(const char* filename) const override { // Only test import of .odt document - return OString(filename).endsWith(".odt"); + return o3tl::ends_with(filename, ".odt"); } bool mustValidate(const char* /*filename*/) const override diff --git a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx index 24a1b2ded86c..2472a7bd3969 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx @@ -8,6 +8,7 @@ */ #include <swmodeltestbase.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -20,7 +21,7 @@ public: protected: bool mustTestImportOf(const char* filename) const override { - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index b35377cdfc31..844eb014de18 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -39,6 +39,7 @@ #include <comphelper/propertysequence.hxx> #include <svx/svdpage.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <o3tl/string_view.hxx> #include <drawdoc.hxx> #include <IDocumentDrawModelAccess.hxx> @@ -71,7 +72,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } protected: diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 8af29d6d7683..7bb652701d7a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -26,6 +26,7 @@ #include <unotxdoc.hxx> #include <docsh.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -38,7 +39,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index 16ac47ce8a9a..fcdede363837 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -18,6 +18,7 @@ #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -34,7 +35,7 @@ protected: bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 2bfe6c68a0f7..9f02523807c0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -27,6 +27,7 @@ #include <frameformats.hxx> #include <unotxdoc.hxx> #include <docsh.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -39,7 +40,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx") + return o3tl::ends_with(filename, ".docx") || filename == std::string_view("ooo39250-1-min.rtf"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index ebc1cbfd02ab..e808abfc3f97 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -31,6 +31,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <unotools/fltrcfg.hxx> +#include <o3tl/string_view.hxx> using namespace com::sun::star; @@ -47,7 +48,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 6f23998495ab..1a9bddbfbd67 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -18,6 +18,7 @@ #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XTextField.hpp> +#include <o3tl/string_view.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/"; @@ -32,7 +33,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 53db9cfccf3b..43acadba38f1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -29,6 +29,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <unotools/fltrcfg.hxx> #include <unoprnms.hxx> +#include <o3tl/string_view.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/"; @@ -61,7 +62,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 3df56e2489ce..75b483e7d239 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -18,6 +18,7 @@ #include <comphelper/scopeguard.hxx> #include <officecfg/Office/Common.hxx> +#include <o3tl/string_view.hxx> #include <queue> #include <swmodeltestbase.hxx> @@ -35,7 +36,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 33c347661233..c949f59b34ca 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -35,6 +35,7 @@ #include <oox/drawingml/drawingmltypes.hxx> #include <xmloff/odffields.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <o3tl/string_view.hxx> #include <IDocumentMarkAccess.hxx> #include <bordertest.hxx> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index e9b2c0a1ef39..3681b9d55834 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -35,6 +35,7 @@ #include <sfx2/docfilt.hxx> #include <comphelper/processfactory.hxx> #include <tools/UnitConversion.hxx> +#include <o3tl/string_view.hxx> #include <docsh.hxx> #include <ftninfo.hxx> @@ -51,7 +52,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport_template.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport_template.cxx index 7d09765db1b9..42b5e165bb54 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport_template.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport_template.cxx @@ -8,6 +8,7 @@ */ #include <swmodeltestbase.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -20,7 +21,7 @@ public: protected: bool mustTestImportOf(const char* filename) const override { - return OString(filename).endsWith(".dotx"); + return o3tl::ends_with(filename, ".dotx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 42b743aabccc..e3628f721ccd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/text/XTextField.hpp> #include <xmloff/odffields.hxx> +#include <o3tl/string_view.hxx> #include <IDocumentMarkAccess.hxx> #include <IMark.hxx> @@ -32,7 +33,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index 0446427e0b03..03e53c0e5c81 100644 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -11,6 +11,7 @@ #include <unotools/tempfile.hxx> #include <tools/urlobj.hxx> #include <officecfg/Office/Common.hxx> +#include <o3tl/string_view.hxx> // This file contains tests to check relative/absolute hyperlinks handling @@ -107,7 +108,7 @@ protected: bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlw14export.cxx b/sw/qa/extras/ooxmlexport/ooxmlw14export.cxx index 602ef048f5ca..bc896ae5f638 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlw14export.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlw14export.cxx @@ -8,6 +8,7 @@ */ #include <swmodeltestbase.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -20,7 +21,7 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx"); + return o3tl::ends_with(filename, ".docx"); } }; diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 298bdbaa8e02..8351541224bc 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -58,6 +58,7 @@ #include <IDocumentSettingAccess.hxx> #include <docsh.hxx> #include <unotxdoc.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -67,7 +68,7 @@ public: bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".doc"); + return o3tl::ends_with(filename, ".doc"); } /** @@ -100,7 +101,7 @@ public: }; // Don't bother with non-.doc files; weed out denylisted .doc files - return (OString(filename).endsWith(".doc") && std::find(aDenylist.begin(), aDenylist.end(), filename) == aDenylist.end()); + return (o3tl::ends_with(filename, ".doc") && std::find(aDenylist.begin(), aDenylist.end(), filename) == aDenylist.end()); } protected: diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index f46743d8b1e5..d6523f172f57 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -32,6 +32,7 @@ #include <IDocumentDrawModelAccess.hxx> #include <docsh.hxx> #include <unotxdoc.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -41,7 +42,7 @@ public: bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".doc"); + return o3tl::ends_with(filename, ".doc"); } }; diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index ccd850864b87..de913f30c451 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -35,6 +35,7 @@ #include <docsh.hxx> #include <unotxdoc.hxx> #include <formatlinebreak.hxx> +#include <o3tl/string_view.hxx> class Test : public SwModelTestBase { @@ -47,7 +48,7 @@ public: bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".doc"); + return o3tl::ends_with(filename, ".doc"); } }; diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index d72289bdbb36..90f20d09207e 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -57,6 +57,7 @@ #include <SwGrammarMarkUp.hxx> #include <docsh.hxx> #include <svtools/optionsdrawinglayer.hxx> +#include <o3tl/string_view.hxx> #include <cellfrm.hxx> #include <wrtsh.hxx> #include <textcontentcontrol.hxx> @@ -123,7 +124,7 @@ OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink) std::stringstream aStream; boost::property_tree::write_json(aStream, aTree, false); - return OString(aStream.str().c_str()).trim(); + return OString(o3tl::trim(aStream.str())); } } diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 0232dbe01e75..4906dc28cdca 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -24,6 +24,7 @@ #include <comphelper/string.hxx> #include <i18nlangtag/languagetag.hxx> #include <o3tl/any.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <tools/urlobj.hxx> #include <swtypes.hxx> @@ -500,7 +501,7 @@ OUString SwAuthorityField::ConditionalExpandAuthIdentifier( { OUString sIdentifier(m_xAuthEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER)); // tdf#107784 Use title if it's a ooxml citation - if (sIdentifier.trim().startsWith("CITATION")) + if (o3tl::starts_with(o3tl::trim(sIdentifier), u"CITATION")) return m_xAuthEntry->GetAuthorField(AUTH_FIELD_TITLE); else sRet += sIdentifier; diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 91fa6120eae2..222ac3e96589 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -22,6 +22,7 @@ #include <svtools/htmlkywd.hxx> #include <svtools/htmlout.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <fmtfld.hxx> #include <doc.hxx> #include <breakit.hxx> @@ -466,7 +467,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt ) bool bWritten = false; if( (rComment.getLength() >= 6 && rComment.startsWith("<") && rComment.endsWith(">") && - rComment.copy( 1, 4 ).equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_meta) ) || + o3tl::equalsIgnoreAsciiCase(rComment.subView( 1, 4 ), u"" OOO_STRING_SVTOOLS_HTML_meta) ) || (rComment.getLength() >= 7 && rComment.startsWith( "<!--" ) && rComment.endsWith( "-->" )) ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 44063c816d9e..032c302460c6 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1816,7 +1816,7 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType, break; case ww::eCITATION: eFieldType = ww::eQUOTE; - assert(rFieldCmd.trim().startsWith("CITATION")); + assert(o3tl::starts_with(o3tl::trim(rFieldCmd), u"CITATION")); sFieldCmd = rFieldCmd.replaceFirst(FieldString(ww::eCITATION), FieldString(ww::eQUOTE)); break; @@ -3060,7 +3060,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) // FIXME: DomainMapper_Impl::CloseFieldCommand() stuffs fully formed // field instructions in here, but if the field doesn't originate // from those filters it won't have that - if (!sRet.trim().startsWith("CITATION")) + if (!o3tl::starts_with(o3tl::trim(sRet), u"CITATION")) { sRet = FieldString(ww::eCITATION) + " \"" + sRet + "\""; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index cecad8f6d370..fd19f6c11630 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -631,7 +631,7 @@ sal_uInt16 SwWW8ImplReader::End_Field() } default: OUString aCode = m_aFieldStack.back().GetBookmarkCode(); - if (!aCode.isEmpty() && !aCode.trim().startsWith("SHAPE")) + if (!aCode.isEmpty() && !o3tl::starts_with(o3tl::trim(aCode), u"SHAPE")) { // Unhandled field with stored code SwPosition aEndPos = *m_pPaM->GetPoint(); diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 73a63255cc62..3293a6bc670d 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -153,7 +153,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if (nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index c3247352fe8a..50ce0548fd54 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -124,7 +124,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) sal_Int32 nSelEntryData = -1; const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { nSelEntryData = o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx)); } diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 25e77775a2ba..2e7c1c67dbc2 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -154,7 +154,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 874b8fe5e90f..017a4d19c6aa 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -144,7 +144,7 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if(sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 0c6c4ace6e11..5392df80463e 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -239,8 +239,8 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) { sal_Int32 nIdx{ 0 }; const OUString sUserData = GetUserData(); - if(!IsRefresh() && sUserData.getToken(0, ';', nIdx). - equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), + u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index e07117a3c737..af34366b2d36 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -33,6 +33,7 @@ #include <calc.hxx> #include <svl/numformat.hxx> #include <svl/zformat.hxx> +#include <o3tl/string_view.hxx> #include <strings.hrc> #define USER_DATA_VERSION_1 "1" @@ -157,7 +158,7 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) { OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if(!IsRefresh() && sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { OUString sVal = sUserData.getToken(0, ';', nIdx); sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(sVal.toInt32()); diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index c886c603953d..48260cd48f0b 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -442,7 +442,8 @@ void BookmarkTable::InsertBookmark(sw::mark::IMark* pMark) } bool bExceedsLength = nBookmarkTextLen > nMaxTextLen; nBookmarkTextLen = std::min<sal_Int32>(nMaxTextLen, nBookmarkTextLen); - sBookmarkNodeText = sBookmarkNodeText.copy(nBookmarkNodeTextPos, nBookmarkTextLen).trim(); + sBookmarkNodeText + = o3tl::trim(sBookmarkNodeText.subView(nBookmarkNodeTextPos, nBookmarkTextLen)); if (bExceedsLength) sBookmarkNodeText += "..."; else if (bPulling && !bPulledAll) diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 58121c6734e7..4e657a260d02 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -250,7 +250,7 @@ OUString getCurrentGlossary() const OUString sTemp{ ::GetCurrGlosGroup() }; // the zeroth path is not being recorded! - if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) + if (o3tl::starts_with(o3tl::getToken(sTemp, 1, GLOS_DELIM), u"0")) return sTemp.getToken(0, GLOS_DELIM); return sTemp; diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 61529cec2b18..dc612a8309eb 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -42,6 +42,7 @@ #include "vbacommandbars.hxx" #include <o3tl/hash_combine.hxx> +#include <o3tl/string_view.hxx> #include <unordered_map> using namespace ::com::sun::star; @@ -332,7 +333,7 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const OUString& MacroName, const uno: { OUString aMacroName = MacroName.trim(); if( aMacroName.startsWith("!") ) - aMacroName = aMacroName.copy(1).trim(); + aMacroName = o3tl::trim(aMacroName.subView(1)); uno::Reference< frame::XModel > xModel; SbMethod* pMeth = StarBASIC::GetActiveMethod(); diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx index 4c16bfc82e1b..1061b12fd2df 100644 --- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx +++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx @@ -19,6 +19,7 @@ #include <graphic/DetectorTools.hxx> #include <tools/stream.hxx> +#include <o3tl/string_view.hxx> using namespace css; @@ -344,24 +345,24 @@ void GraphicFormatDetectorTest::testMatchArray() pMatchPointer = vcl::matchArrayWithString(pCompleteStringPointer, nCheckSize, "<?xml"); CPPUNIT_ASSERT(pMatchPointer != nullptr); CPPUNIT_ASSERT_EQUAL(0, int(pMatchPointer - pCompleteStringPointer)); - CPPUNIT_ASSERT_EQUAL(true, OString(pMatchPointer).startsWith("<?xml")); + CPPUNIT_ASSERT_EQUAL(true, o3tl::starts_with(pMatchPointer, "<?xml")); // Check middle of the input string pMatchPointer = vcl::matchArrayWithString(aString.c_str(), nCheckSize, "version"); CPPUNIT_ASSERT(pMatchPointer != nullptr); CPPUNIT_ASSERT_EQUAL(6, int(pMatchPointer - pCompleteStringPointer)); - CPPUNIT_ASSERT_EQUAL(true, OString(pMatchPointer).startsWith("version")); + CPPUNIT_ASSERT_EQUAL(true, o3tl::starts_with(pMatchPointer, "version")); pMatchPointer = vcl::matchArrayWithString(aString.c_str(), nCheckSize, "<svg"); CPPUNIT_ASSERT(pMatchPointer != nullptr); CPPUNIT_ASSERT_EQUAL(38, int(pMatchPointer - pCompleteStringPointer)); - CPPUNIT_ASSERT_EQUAL(true, OString(pMatchPointer).startsWith("<svg")); + CPPUNIT_ASSERT_EQUAL(true, o3tl::starts_with(pMatchPointer, "<svg")); // Check end of the input string pMatchPointer = vcl::matchArrayWithString(aString.c_str(), nCheckSize, "/svg>"); CPPUNIT_ASSERT(pMatchPointer != nullptr); CPPUNIT_ASSERT_EQUAL(119, int(pMatchPointer - pCompleteStringPointer)); - CPPUNIT_ASSERT_EQUAL(true, OString(pMatchPointer).startsWith("/svg>")); + CPPUNIT_ASSERT_EQUAL(true, o3tl::starts_with(pMatchPointer, "/svg>")); // Check that non-existing search string pMatchPointer = vcl::matchArrayWithString(aString.c_str(), nCheckSize, "none"); diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index f903b30c6204..3e30cb74fce7 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -49,6 +49,7 @@ #include <font/FontSelectPattern.hxx> #include <font/PhysicalFontCollection.hxx> #include <font/PhysicalFontFace.hxx> +#include <o3tl/string_view.hxx> #include <sallayout.hxx> using namespace psp; @@ -427,7 +428,7 @@ void GenPspGraphics::AnnounceFonts( vcl::font::PhysicalFontCollection* pFontColl } if( pLangBoost ) - if( aFileName.copy( nPos+1, 3 ).equalsIgnoreAsciiCase( pLangBoost ) ) + if( o3tl::equalsIgnoreAsciiCase(aFileName.subView( nPos+1, 3 ), pLangBoost ) ) nQuality += 10; } diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx index 7ed5b677ec64..db9d929d4208 100644 --- a/vcl/unx/generic/printer/jobdata.cxx +++ b/vcl/unx/generic/printer/jobdata.cxx @@ -227,7 +227,7 @@ bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, Jo else if (aLine.startsWith(orientatationEquals)) { bOrientation = true; - rJobData.m_eOrientation = aLine.copy(RTL_CONSTASCII_LENGTH(orientatationEquals)).equalsIgnoreAsciiCase("landscape") ? orientation::Landscape : orientation::Portrait; + rJobData.m_eOrientation = o3tl::equalsIgnoreAsciiCase(aLine.subView(RTL_CONSTASCII_LENGTH(orientatationEquals)), "landscape") ? orientation::Landscape : orientation::Portrait; } else if (aLine.startsWith(copiesEquals)) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 58258a386c83..fbd75c2ef34d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -6358,7 +6358,7 @@ void DomainMapper_Impl::CloseFieldCommand() //merge Read_SubF_Ruby into filter/.../util.cxx and reuse that ? sal_Int32 nSpaceIndex = aCommand.indexOf(' '); if(nSpaceIndex > 0) - aCommand = aCommand.copy(nSpaceIndex).trim(); + aCommand = o3tl::trim(aCommand.subView(nSpaceIndex)); if (aCommand.startsWith("\\s")) { aCommand = aCommand.copy(2); diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 9393692b7656..5eb9e6420b00 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -27,6 +27,7 @@ #include <rtl/uri.hxx> #include <rtl/ref.hxx> #include <rtl/character.hxx> +#include <o3tl/string_view.hxx> #include <libxslt/transform.h> #include <libxslt/xsltutils.h> #include <libxslt/security.h> @@ -452,7 +453,7 @@ bool URLParameter::query() if( m_aExpr.isEmpty() ) return true; else if( m_aExpr[0] == '?' ) - query_ = m_aExpr.copy( 1 ).trim(); + query_ = o3tl::trim(m_aExpr.subView( 1 )); else return false; @@ -465,16 +466,16 @@ bool URLParameter::query() { delimIdx = query_.indexOf( '&' ); equalIdx = query_.indexOf( '=' ); - parameter = query_.copy( 0,equalIdx ).trim(); + parameter = o3tl::trim(query_.subView( 0,equalIdx )); if( delimIdx == -1 ) { - value = query_.copy( equalIdx + 1 ).trim(); + value = o3tl::trim(query_.subView( equalIdx + 1 )); query_.clear(); } else { - value = query_.copy( equalIdx+1,delimIdx - equalIdx - 1 ).trim(); - query_ = query_.copy( delimIdx+1 ).trim(); + value = o3tl::trim(query_.subView( equalIdx+1,delimIdx - equalIdx - 1 )); + query_ = o3tl::trim(query_.subView( delimIdx+1 )); } if( parameter == "Language" ) diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index cba8355785c5..236131ac8bb9 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -53,6 +53,7 @@ #include <rtl/math.h> #include <sal/log.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <sax/tools/converter.hxx> #include <vector> @@ -114,7 +115,7 @@ public: Any convertTarget( const OUString& rValue ); static Any convertPath( const OUString& rValue ); Any convertTiming( const OUString& rValue ); - static Sequence< double > convertKeyTimes( const OUString& rValue ); + static Sequence< double > convertKeyTimes( std::u16string_view rValue ); static Sequence< TimeFilterPair > convertTimeFilter( const OUString& rValue ); }; @@ -377,7 +378,7 @@ Any AnimationsImportHelperImpl::convertTiming( const OUString& rValue ) return aAny; } -Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString& rValue ) +Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( std::u16string_view rValue ) { const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') }; @@ -387,7 +388,7 @@ Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString& { double* pValues = aKeyTimes.getArray(); for (sal_Int32 nIndex = 0; nIndex >= 0; ) - *pValues++ = rValue.getToken( 0, ';', nIndex ).toDouble(); + *pValues++ = o3tl::toDouble(o3tl::getToken(rValue, 0, ';', nIndex )); } return aKeyTimes; diff --git a/xmloff/source/draw/eventimp.cxx b/xmloff/source/draw/eventimp.cxx index 41f9cf69a2e6..29fc94fda272 100644 --- a/xmloff/source/draw/eventimp.cxx +++ b/xmloff/source/draw/eventimp.cxx @@ -24,6 +24,7 @@ #include <tools/urlobj.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <sax/tools/converter.hxx> @@ -296,14 +297,14 @@ void SdXMLEventContextData::ApplyProperties() const OUString& rApp = GetXMLToken( XML_APPLICATION ); const OUString& rDoc = GetXMLToken( XML_DOCUMENT ); if( msMacroName.getLength() > rApp.getLength()+1 && - msMacroName.copy(0,rApp.getLength()).equalsIgnoreAsciiCase( rApp ) && + o3tl::equalsIgnoreAsciiCase(msMacroName.subView(0,rApp.getLength()), rApp) && ':' == msMacroName[rApp.getLength()] ) { sLibrary = "StarOffice"; msMacroName = msMacroName.copy( rApp.getLength()+1 ); } else if( msMacroName.getLength() > rDoc.getLength()+1 && - msMacroName.copy(0,rDoc.getLength()).equalsIgnoreAsciiCase( rDoc ) && + o3tl::equalsIgnoreAsciiCase(msMacroName.subView(0,rDoc.getLength()), rDoc) && ':' == msMacroName[rDoc.getLength()] ) { sLibrary = rDoc; diff --git a/xmloff/source/script/XMLStarBasicContextFactory.cxx b/xmloff/source/script/XMLStarBasicContextFactory.cxx index eec6ded9f207..e26198978596 100644 --- a/xmloff/source/script/XMLStarBasicContextFactory.cxx +++ b/xmloff/source/script/XMLStarBasicContextFactory.cxx @@ -24,6 +24,7 @@ #include <xmloff/namespacemap.hxx> #include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltoken.hxx> +#include <o3tl/string_view.hxx> using namespace ::xmloff::token; @@ -66,14 +67,14 @@ SvXMLImportContext* XMLStarBasicContextFactory::CreateContext( const OUString& rApp = GetXMLToken( XML_APPLICATION ); const OUString& rDoc = GetXMLToken( XML_DOCUMENT ); if( sMacroNameVal.getLength() > rApp.getLength()+1 && - sMacroNameVal.copy(0,rApp.getLength()).equalsIgnoreAsciiCase( rApp ) && + o3tl::equalsIgnoreAsciiCase(sMacroNameVal.subView(0,rApp.getLength()), rApp ) && ':' == sMacroNameVal[rApp.getLength()] ) { sLibraryVal = "StarOffice"; sMacroNameVal = sMacroNameVal.copy( rApp.getLength()+1 ); } else if( sMacroNameVal.getLength() > rDoc.getLength()+1 && - sMacroNameVal.copy(0,rDoc.getLength()).equalsIgnoreAsciiCase( rDoc ) && + o3tl::equalsIgnoreAsciiCase(sMacroNameVal.subView(0,rDoc.getLength()), rDoc ) && ':' == sMacroNameVal[rDoc.getLength()] ) { sLibraryVal = rDoc; diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx index bc24a16ceb03..06ac88fe8fa9 100644 --- a/xmloff/source/style/xmlbahdl.cxx +++ b/xmloff/source/style/xmlbahdl.cxx @@ -23,6 +23,7 @@ #include <sal/log.hxx> #include <o3tl/any.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmluconv.hxx> #include <com/sun/star/uno/Any.hxx> @@ -478,9 +479,9 @@ bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, cons Sequence< double > aHSL { - aTmp.getToken( 0, ',', nIndex ).toDouble(), - aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0, - aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0 + o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )), + o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0, + o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0 }; rValue <<= aHSL; bRet = true; diff --git a/xmloff/source/transform/EventOASISTContext.cxx b/xmloff/source/transform/EventOASISTContext.cxx index 21e3476ef8da..ea922b7ff074 100644 --- a/xmloff/source/transform/EventOASISTContext.cxx +++ b/xmloff/source/transform/EventOASISTContext.cxx @@ -27,6 +27,7 @@ #include "TransformerBase.hxx" #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> // Used to parse Scripting Framework URLs #include <com/sun/star/uri/UriReferenceFactory.hpp> @@ -287,16 +288,14 @@ void XMLEventOASISTransformerContext::StartElement( const OUString& rDoc = GetXMLToken( XML_DOCUMENT ); OUString aAttrValue; if( rAttrValue.getLength() > rApp.getLength()+1 && - rAttrValue.copy(0,rApp.getLength()). - equalsIgnoreAsciiCase( rApp ) && + o3tl::equalsIgnoreAsciiCase(rAttrValue.subView(0,rApp.getLength()), rApp) && ':' == rAttrValue[rApp.getLength()] ) { aLocation = rApp; aAttrValue = rAttrValue.copy( rApp.getLength()+1 ); } else if( rAttrValue.getLength() > rDoc.getLength()+1 && - rAttrValue.copy(0,rDoc.getLength()). - equalsIgnoreAsciiCase( rDoc ) && + o3tl::equalsIgnoreAsciiCase(rAttrValue.subView(0,rDoc.getLength()), rDoc) && ':' == rAttrValue[rDoc.getLength()] ) { aLocation= rDoc; |