diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-11-12 08:13:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-11-12 16:53:30 +0100 |
commit | f34ac579fac16fff37bf00fe85d43ad6b938eca7 (patch) | |
tree | 0747c4d86bbf40a5093fb7a3215dd52a8e8586b2 | |
parent | c45753847dfc2b4645dc2f7500a18ec2c5d438df (diff) |
New loplugin:stringviewparam
...to "Find functions that take rtl::O[U]String parameters that can be
generalized to take std::[u16]string_view instead." (Which in turn can avoid
costly O[U]String constructions, see e.g. loplugin:stringview and subView.)
Some of those functions' call sites, passing plain char string literals, needed
to be adapted when converting them.
Change-Id: I644ab546d7a0ce9e470ab9b3196e3e60d1e812bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105622
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
68 files changed, 667 insertions, 153 deletions
diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx index 50631babe24c..5ddf9ec154b1 100644 --- a/basctl/source/dlged/propbrw.cxx +++ b/basctl/source/dlged/propbrw.cxx @@ -141,7 +141,7 @@ void PropBrw::ImplReCreateController() // create a property browser controller Reference< XMultiComponentFactory > xFactory( xInspectorContext->getServiceManager(), UNO_SET_THROW ); - static const char s_sControllerServiceName[] = "com.sun.star.awt.PropertyBrowserController"; + static const char16_t s_sControllerServiceName[] = u"com.sun.star.awt.PropertyBrowserController"; m_xBrowserController.set( xFactory->createInstanceWithContext( s_sControllerServiceName, xInspectorContext ), UNO_QUERY ); if ( !m_xBrowserController.is() ) { diff --git a/basegfx/source/inc/stringconversiontools.hxx b/basegfx/source/inc/stringconversiontools.hxx index 9b788bf3421e..fdf2f83e0f4e 100644 --- a/basegfx/source/inc/stringconversiontools.hxx +++ b/basegfx/source/inc/stringconversiontools.hxx @@ -19,13 +19,17 @@ #pragma once +#include <sal/config.h> + +#include <string_view> + #include <sal/types.h> #include <rtl/ustring.hxx> namespace basegfx::internal { void skipSpaces(sal_Int32& io_rPos, - const OUString& rStr, + std::u16string_view rStr, const sal_Int32 nLen); inline bool isOnNumberChar(const sal_Unicode aChar, @@ -39,7 +43,7 @@ namespace basegfx::internal return bPredicate; } - inline bool isOnNumberChar(const OUString& rStr, + inline bool isOnNumberChar(std::u16string_view rStr, const sal_Int32 nPos) { return isOnNumberChar(rStr[nPos], true/*bSignAllowed*/); @@ -52,7 +56,7 @@ namespace basegfx::internal bool importFlagAndSpaces(sal_Int32& o_nRetval, sal_Int32& io_rPos, - const OUString& rStr, + std::u16string_view rStr, const sal_Int32 nLen); } // namespace basegfx::internal diff --git a/basegfx/source/tools/stringconversiontools.cxx b/basegfx/source/tools/stringconversiontools.cxx index 079966b27557..d9f7df14cf50 100644 --- a/basegfx/source/tools/stringconversiontools.cxx +++ b/basegfx/source/tools/stringconversiontools.cxx @@ -23,7 +23,7 @@ namespace basegfx::internal { void skipSpaces(sal_Int32& io_rPos, - const OUString& rStr, + std::u16string_view rStr, const sal_Int32 nLen) { while( io_rPos < nLen && @@ -34,7 +34,7 @@ namespace basegfx::internal } static void skipSpacesAndCommas(sal_Int32& io_rPos, - const OUString& rStr, + std::u16string_view rStr, const sal_Int32 nLen) { while(io_rPos < nLen @@ -134,7 +134,7 @@ namespace basegfx::internal bool importFlagAndSpaces(sal_Int32& o_nRetval, sal_Int32& io_rPos, - const OUString& rStr, + std::u16string_view rStr, const sal_Int32 nLen) { sal_Unicode aChar( rStr[io_rPos] ); diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index e9b22500b6fa..e1fdc3299e59 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <string_view> + #include "ChartAreaPanel.hxx" #include <ChartController.hxx> @@ -189,7 +193,7 @@ XHatch getXHatchFromName(const css::uno::Reference<css::frame::XModel>& xModel, } GraphicObject getXBitmapFromName(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rName) + std::u16string_view rName) { try { diff --git a/comphelper/source/property/propertybag.cxx b/comphelper/source/property/propertybag.cxx index de230f470150..02e6f78c1287 100644 --- a/comphelper/source/property/propertybag.cxx +++ b/comphelper/source/property/propertybag.cxx @@ -29,7 +29,7 @@ #include <com/sun/star/beans/UnknownPropertyException.hpp> #include <map> - +#include <string_view> namespace comphelper { @@ -66,9 +66,9 @@ namespace comphelper namespace { - void lcl_checkForEmptyName( const bool _allowEmpty, const OUString& _name ) + void lcl_checkForEmptyName( const bool _allowEmpty, std::u16string_view _name ) { - if ( !_allowEmpty && _name.isEmpty() ) + if ( !_allowEmpty && _name.empty() ) throw IllegalArgumentException( "The property name must not be empty.", // TODO: resource diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx new file mode 100644 index 000000000000..a8df3c5f128d --- /dev/null +++ b/compilerplugins/clang/stringviewparam.cxx @@ -0,0 +1,380 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cassert> +#include <set> +#include <vector> + +#include "check.hxx" +#include "compat.hxx" +#include "functionaddress.hxx" +#include "plugin.hxx" + +// Find functions that take rtl::O[U]String parameters that can be generalized to take +// std::[u16]string_view instead. + +//TODO: At least theoretically, there are issues with replacing parameters that are being assigned +// to, as in +// +// void f(OUString s) { +// { +// OUString t = ...; +// s = t; +// } +// ... use s ... // if s is now std::u16string_view, it points into destroyed contents of t +// } + +namespace +{ +bool hasSalDllpublicExportAttr(FunctionDecl const* decl) +{ + if (auto const attr = decl->getAttr<VisibilityAttr>()) + { + return attr->getVisibility() == VisibilityAttr::Default; + } + return decl->hasAttr<DLLExportAttr>(); +} + +enum class StringType +{ + None, + RtlOstring, + RtlOustring +}; + +StringType relevantStringType(QualType type) +{ + loplugin::TypeCheck const c(type); + if (c.Class("OString").Namespace("rtl")) + { + return StringType::RtlOstring; + } + else if (c.Class("OUString").Namespace("rtl")) + { + return StringType::RtlOustring; + } + else + { + return StringType::None; + } +} + +bool relevantParmVarDecl(ParmVarDecl const* decl) +{ + auto const t1 = decl->getType(); + if (auto const t2 = t1->getAs<LValueReferenceType>()) + { + if (!t2->getPointeeType().isConstQualified()) + { + return false; + } + } + if (relevantStringType(t1.getNonReferenceType()) == StringType::None) + { + return false; + } + if (decl->hasAttr<UnusedAttr>()) + { + return false; + } + return true; +} + +DeclRefExpr const* relevantDeclRefExpr(Expr const* expr) +{ + //TODO: Look through BO_Comma and AbstractConditionalOperator + auto const e = dyn_cast<DeclRefExpr>(expr->IgnoreParenImpCasts()); + if (e == nullptr) + { + return nullptr; + } + auto const d = dyn_cast<ParmVarDecl>(e->getDecl()); + if (d == nullptr) + { + return nullptr; + } + if (!relevantParmVarDecl(d)) + { + return nullptr; + } + return e; +} + +DeclRefExpr const* relevantImplicitCastExpr(ImplicitCastExpr const* expr) +{ + if (!loplugin::TypeCheck(expr->getType()).ClassOrStruct("basic_string_view").StdNamespace()) + { + return nullptr; + } + return relevantDeclRefExpr(expr->getSubExprAsWritten()); +} + +DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr) +{ + StringType t = relevantStringType(compat::getObjectType(expr)); + if (t == StringType::None) + { + return nullptr; + } + bool good = false; + auto const d = expr->getMethodDecl(); + if (d->getOverloadedOperator() == OO_Subscript) + { + good = true; + } + else if (auto const i = d->getIdentifier()) + { + auto const n = i->getName(); + if (n == "isEmpty") + { + good = true; + } +#if 0 + //TODO: rtl::O[U]String::getLength would be awkward to replace with + // std::[u16]string_view::length/size due to the sal_Int32 vs. std::size_t return type + // mismatch (C++20 ssize might make that easier, though); and while rtl::OString::getStr is + // documented to be NUL-terminated (so not eligible for replacement with + // std::string_view::data in general), rtl::OUString::getStr is not (so should be eligible + // for replacement with std::u16string_view::data, but some call sites might nevertheless + // incorrectly rely on NUL termination, so any replacement would need careful review): + if (n == "getLength" || (t == StringType::RtlOustring && n == "getStr")) + { + good = true; + } +#endif + } + if (!good) + { + return nullptr; + } + return relevantDeclRefExpr(expr->getImplicitObjectArgument()); +} + +DeclRefExpr const* relevantCXXOperatorCallExpr(CXXOperatorCallExpr const* expr) +{ + if (expr->getOperator() != OO_Subscript) + { + return nullptr; + } + auto const e = expr->getArg(0); + if (relevantStringType(e->getType()) == StringType::None) + { + return nullptr; + } + return relevantDeclRefExpr(e); +} + +class StringViewParam final + : public loplugin::FunctionAddress<loplugin::FilteringPlugin<StringViewParam>> +{ +public: + explicit StringViewParam(loplugin::InstantiationData const& data) + : FunctionAddress(data) + { + } + + //TODO: Also check lambdas + bool TraverseFunctionDecl(FunctionDecl* decl) + { + if (ignoreLocation(decl)) + { + return true; + } + if (!relevantFunctionDecl(decl)) + { + return FunctionAddress::TraverseFunctionDecl(decl); + } + auto const oldParams = currentParams_; + auto const n = decl->getNumParams(); + for (unsigned i = 0; i != n; ++i) + { + auto const d = decl->getParamDecl(i); + if (relevantParmVarDecl(d)) + { + currentParams_.insert(d); + } + } + auto const ret = FunctionAddress::TraverseFunctionDecl(decl); + if (ret) + { + for (unsigned i = 0; i != n; ++i) + { + auto const d1 = decl->getParamDecl(i); + if (currentParams_.find(d1) == currentParams_.end()) + { + continue; + } + if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) + { + break; + } + badParams_.push_back(d1); + } + } + currentParams_ = oldParams; + return ret; + } + + bool TraverseImplicitCastExpr(ImplicitCastExpr* expr) + { + if (ignoreLocation(expr)) + { + return true; + } + auto const e = relevantImplicitCastExpr(expr); + if (e == nullptr) + { + return FunctionAddress::TraverseImplicitCastExpr(expr); + } + currentGoodUses_.insert(e); + auto const ret = FunctionAddress::TraverseImplicitCastExpr(expr); + currentGoodUses_.erase(e); + return ret; + } + + bool TraverseCXXMemberCallExpr(CXXMemberCallExpr* expr) + { + if (ignoreLocation(expr)) + { + return true; + } + auto const e = relevantCXXMemberCallExpr(expr); + if (e == nullptr) + { + return FunctionAddress::TraverseCXXMemberCallExpr(expr); + } + currentGoodUses_.insert(e); + auto const ret = FunctionAddress::TraverseCXXMemberCallExpr(expr); + currentGoodUses_.erase(e); + return ret; + } + + bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr* expr) + { + if (ignoreLocation(expr)) + { + return true; + } + auto const e = relevantCXXOperatorCallExpr(expr); + if (e == nullptr) + { + return FunctionAddress::TraverseCXXOperatorCallExpr(expr); + } + currentGoodUses_.insert(e); + auto const ret = FunctionAddress::TraverseCXXOperatorCallExpr(expr); + currentGoodUses_.erase(e); + return ret; + } + + bool VisitDeclRefExpr(DeclRefExpr* expr) + { + if (!FunctionAddress::VisitDeclRefExpr(expr)) + { + return false; + } + if (ignoreLocation(expr)) + { + return true; + } + if (currentGoodUses_.find(expr) != currentGoodUses_.end()) + { + return true; + } + if (auto const d = dyn_cast<ParmVarDecl>(expr->getDecl())) + { + currentParams_.erase(d); + } + return true; + } + +private: + void run() override + { + if (!compiler.getLangOpts().CPlusPlus) + { + return; + } + if (!TraverseDecl(compiler.getASTContext().getTranslationUnitDecl())) + { + return; + } + auto const ignoredFns = getFunctionsWithAddressTaken(); + for (auto const i : badParams_) + { + auto const d1 = cast<FunctionDecl>(i->getDeclContext()); + if (ignoredFns.find(d1) != ignoredFns.end()) + { + continue; + } + auto const t = relevantStringType(i->getType().getNonReferenceType()); + assert(t != StringType::None); + report(DiagnosticsEngine::Warning, + "replace function parameter of type %0 with " + "'%select{std::string_view|std::u16string_view}1'", + i->getLocation()) + << i->getType() << (int(t) - 1) << i->getSourceRange(); + for (auto d2 = d1;;) + { + d2 = d2->getPreviousDecl(); + if (d2 == nullptr) + { + break; + } + auto const d3 = d2->getParamDecl(i->getFunctionScopeIndex()); + report(DiagnosticsEngine::Note, "previous declaration is here", d3->getLocation()) + << d3->getSourceRange(); + } + } + } + + bool relevantFunctionDecl(FunctionDecl const* decl) + { + if (!decl->doesThisDeclarationHaveABody()) + { + return false; + } + if (auto const d = dyn_cast<CXXMethodDecl>(decl)) + { + if (d->isVirtual()) + { + return false; + } + } + if (decl->isFunctionTemplateSpecialization()) + { + return false; + } + if (decl->getLocation().isMacroID()) + { + return false; + } + // Filter out functions that are presumably meant to be called dynamically (e.g., via + // dlopen, or backwards compatibility stubs in cppuhelper/cppu/sal compat.cxx): + if (decl->getPreviousDecl() == nullptr && !decl->isInlined() + && hasSalDllpublicExportAttr(decl) + && compiler.getSourceManager().isInMainFile(decl->getLocation())) + { + return false; + } + if (isInUnoIncludeFile(compiler.getSourceManager().getSpellingLoc(decl->getLocation()))) + { + return false; + } + return true; + } + + std::set<ParmVarDecl const*> currentParams_; + std::set<DeclRefExpr const*> currentGoodUses_; + std::vector<ParmVarDecl const*> badParams_; +}; + +static loplugin::Plugin::Registration<StringViewParam> reg("stringviewparam"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/test/stringviewparam.cxx b/compilerplugins/clang/test/stringviewparam.cxx new file mode 100644 index 000000000000..afa0454b0b43 --- /dev/null +++ b/compilerplugins/clang/test/stringviewparam.cxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "sal/config.h" + +#include <string_view> + +#include "rtl/string.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +void f1a(std::string_view); +// expected-error@+1 {{replace function parameter of type 'const rtl::OString &' with 'std::string_view' [loplugin:stringviewparam]}} +char f1b(OString const& s) +{ + f1a(s); + if (s.isEmpty()) + { + f1a(std::string_view(s)); + } + return s[0]; +} + +void f2a(std::u16string_view); +// expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}} +sal_Unicode f2b(OUString const& s) +{ + f2a(s); + if (s.isEmpty()) + { + f2a(std::u16string_view(s)); + } + return s[0]; +} + +void f3a(OUString const&) {} +using F3 = void(OUString const&); +F3* f3b() { return f3a; } + +SAL_DLLPUBLIC_EXPORT void f4(OUString const&) {} + +template <typename T> void f5(T const&); +template <> void f5<OUString>(OUString const&) {} + +void f6([[maybe_unused]] OUString const&) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx index 29d4b18c49bf..04da5f9a50ab 100644 --- a/configmgr/source/writemodfile.cxx +++ b/configmgr/source/writemodfile.cxx @@ -172,7 +172,7 @@ void writeValueContent_(TempFile &handle, double value) { handle.writeString(OString::number(value)); } -void writeValueContent_(TempFile &handle, const OUString& value) { +void writeValueContent_(TempFile &handle, std::u16string_view value) { writeValueContent(handle, value); } diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index a9e0caff2eeb..b2626dd6fbe6 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -64,7 +64,7 @@ namespace dbtools using namespace connectivity; using namespace comphelper; -OUString createStandardTypePart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,const OUString& _sCreatePattern) +OUString createStandardTypePart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,std::u16string_view _sCreatePattern) { Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData(); @@ -141,10 +141,10 @@ OUString createStandardTypePart(const Reference< XPropertySet >& xColProp,const if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP ) { aSql.append(nPrecision); - if ( (nScale > 0) || (!_sCreatePattern.isEmpty() && sCreateParams.indexOf(_sCreatePattern) != -1) ) + if ( (nScale > 0) || (!_sCreatePattern.empty() && sCreateParams.indexOf(_sCreatePattern) != -1) ) aSql.append(","); } - if ( (nScale > 0) || ( !_sCreatePattern.isEmpty() && sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == DataType::TIMESTAMP ) + if ( (nScale > 0) || ( !_sCreatePattern.empty() && sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == DataType::TIMESTAMP ) aSql.append(nScale); if ( nParenPos == -1 ) @@ -170,7 +170,7 @@ OUString createStandardTypePart(const Reference< XPropertySet >& xColProp,const return aSql.makeStringAndClear(); } -OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) +OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,std::u16string_view _sCreatePattern) { Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData(); @@ -208,7 +208,7 @@ OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,cons } -OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) +OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,std::u16string_view _sCreatePattern) { OUStringBuffer aSql("CREATE TABLE "); OUString sCatalog,sSchema,sTable,sComposedName; diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 0b229aa9ec5a..8ab37a3f76f3 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -33,7 +33,7 @@ #include <tools/diagnose_ex.h> #include <memory> - +#include <string_view> namespace dbtools { @@ -59,12 +59,13 @@ namespace dbtools using ::connectivity::OSQLParseNode; - static sal_Unicode lcl_getSeparatorChar( const OUString& _rSeparator, sal_Unicode _nFallback ) + static sal_Unicode lcl_getSeparatorChar( + std::u16string_view _rSeparator, sal_Unicode _nFallback ) { - OSL_ENSURE( !_rSeparator.isEmpty(), "::lcl_getSeparatorChar: invalid separator string!" ); + OSL_ENSURE( !_rSeparator.empty(), "::lcl_getSeparatorChar: invalid separator string!" ); sal_Unicode nReturn( _nFallback ); - if ( !_rSeparator.isEmpty() ) + if ( !_rSeparator.empty() ) nReturn = _rSeparator[0]; return nReturn; } diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index 5c827b3bc0b7..c1d9a4f66731 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -54,6 +54,7 @@ #include <memory> #include <string.h> +#include <string_view> #include <connectivity/dbconversion.hxx> @@ -133,13 +134,13 @@ static bool isOperator( char c ) return *w != 0; } -static bool isNamedParameterStart( const OString & o , int index ) +static bool isNamedParameterStart( std::string_view o , int index ) { return o[index] == ':' && ( isWhitespace( o[index-1] ) || isOperator(o[index-1]) ); } -static bool isQuoted( const OString & str ) +static bool isQuoted( std::string_view str ) { return str[0] == '"' || str[0] == '\''; } diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index 95d646581943..676dda6bca55 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -43,6 +43,7 @@ #include <svtools/optionsdrawinglayer.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <set> +#include <string_view> using namespace com::sun::star; @@ -66,7 +67,7 @@ namespace return aTempl; } - OUString lcl_Image( const OUString& rScreenshotId, const Size& rSize ) + OUString lcl_Image( std::u16string_view rScreenshotId, const Size& rSize ) { OUString aTempl("<image id=\"%1\" src=\"media/screenshots/%2.png\"" " width=\"%3cm\" height=\"%4cm\">" @@ -81,7 +82,7 @@ namespace return aTempl; } - OUString lcl_ParagraphWithImage( const OUString& rScreenshotId, const Size& rSize ) + OUString lcl_ParagraphWithImage( std::u16string_view rScreenshotId, const Size& rSize ) { OUString aTempl( "<paragraph id=\"%1\" role=\"paragraph\">%2" "</paragraph>" SAL_NEWLINE_STRING ); @@ -91,7 +92,7 @@ namespace return aTempl; } - OUString lcl_Bookmark( const OUString& rWidgetId ) + OUString lcl_Bookmark( std::u16string_view rWidgetId ) { OUString aTempl = "<!-- Bookmark for widget %1 -->" SAL_NEWLINE_STRING "<bookmark branch=\"hid/%2\" id=\"%3\" localize=\"false\"/>" SAL_NEWLINE_STRING; diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 4c12a3ae7b51..bdc1876e9607 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -198,7 +198,7 @@ bool OGenericUnoController::Construct(vcl::Window* /*pParent*/) { SAL_WARN("dbaccess.ui","OGenericUnoController::Construct: could not create (or start listening at) the database context!"); // at least notify the user. Though the whole component does not make any sense without the database context ... - ShowServiceNotAvailableError(getFrameWeld(), "com.sun.star.sdb.DatabaseContext", true); + ShowServiceNotAvailableError(getFrameWeld(), u"com.sun.star.sdb.DatabaseContext", true); } return true; diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 2437196f14e3..2853110b1959 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -194,7 +194,7 @@ ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Refer } catch(const Exception&) { - ShowServiceNotAvailableError(pTopParent, "com.sun.star.sdb.DatabaseContext", true); + ShowServiceNotAvailableError(pTopParent, u"com.sun.star.sdb.DatabaseContext", true); } } diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx index c6fafa1b0926..190d5e192b2d 100644 --- a/dbaccess/source/ui/inc/UITools.hxx +++ b/dbaccess/source/ui/inc/UITools.hxx @@ -26,6 +26,7 @@ #include <connectivity/dbtools.hxx> #include <memory> +#include <string_view> #define RET_ALL 100 @@ -309,7 +310,7 @@ namespace dbaui @return RET_YES, RET_NO, RET_ALL */ - sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool bAll, const OUString& rName); + sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool bAll, std::u16string_view rName); /** creates a new view from a query or table @param _sName diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index d75ea241ed95..5147ab3271df 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1150,7 +1150,7 @@ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rType return pTypeInfo; } -sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool _bAll, const OUString& _sName) +sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool _bAll, std::u16string_view _sName) { SolarMutexGuard aGuard; OUString aMsg = DBA_RES(pText); diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx index 34fac13d18d5..53ef26fa3284 100644 --- a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx +++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx @@ -36,6 +36,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <memory> +#include <string_view> namespace dbaui { @@ -57,7 +58,7 @@ namespace dbaui // helper namespace { - void lcl_fillNameExistsError( const OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) + void lcl_fillNameExistsError( std::u16string_view _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) { SQLException aError; OUString sErrorMessage = DBA_RES(STR_NAMED_OBJECT_ALREADY_EXISTS); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index a490f3fa39e4..2c83c1165856 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -66,7 +66,7 @@ #include <unicode/ubidi.h> #include <algorithm> #include <memory> - +#include <string_view> #include <fstream> using namespace ::com::sun::star; @@ -1597,7 +1597,7 @@ bool ImpEditEngine::IsInputSequenceCheckingRequired( sal_Unicode nChar, const Ed return bIsSequenceChecking; } -static bool lcl_HasStrongLTR ( const OUString& rTxt, sal_Int32 nStart, sal_Int32 nEnd ) +static bool lcl_HasStrongLTR ( std::u16string_view rTxt, sal_Int32 nStart, sal_Int32 nEnd ) { for( sal_Int32 nCharIdx = nStart; nCharIdx < nEnd; ++nCharIdx ) { diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 70ff36c5594f..feab628d7f04 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1279,7 +1279,7 @@ OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPo } // search preceding opening quote in the paragraph before the insert position -static bool lcl_HasPrecedingChar( const OUString& rTxt, sal_Int32 nPos, +static bool lcl_HasPrecedingChar( std::u16string_view rTxt, sal_Int32 nPos, const sal_Unicode sPrecedingChar, const sal_Unicode* aStopChars ) { sal_Unicode cTmpChar; diff --git a/extensions/source/abpilot/admininvokationimpl.cxx b/extensions/source/abpilot/admininvokationimpl.cxx index 947f3886232b..fe208e85b3ec 100644 --- a/extensions/source/abpilot/admininvokationimpl.cxx +++ b/extensions/source/abpilot/admininvokationimpl.cxx @@ -61,7 +61,7 @@ namespace abp try { // the service name of the administration dialog - static const char s_sAdministrationServiceName[] = "com.sun.star.sdb.DatasourceAdministrationDialog"; + static const char16_t s_sAdministrationServiceName[] = u"com.sun.star.sdb.DatasourceAdministrationDialog"; static const char s_sDataSourceTypeChangeDialog[] = "com.sun.star.sdb.DataSourceTypeChangeDialog"; // the parameters for the call diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index aa8bba0b33fd..73795a3939ad 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -535,7 +535,7 @@ namespace abp if (!xInteractions.is()) { if ( _pMessageParent ) - ShowServiceNotAvailableError( _pMessageParent, "com.sun.star.task.InteractionHandler", true ); + ShowServiceNotAvailableError( _pMessageParent, u"com.sun.star.task.InteractionHandler", true ); return false; } diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index 24bcf10ec7a6..b442aca3fdbe 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -436,7 +436,7 @@ namespace dbp catch(const Exception&) { } if (!xHandler.is()) { - ShowServiceNotAvailableError(_pWindow, "com.sun.star.task.InteractionHandler", true); + ShowServiceNotAvailableError(_pWindow, u"com.sun.star.task.InteractionHandler", true); } return xHandler; } diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx index 57f4d3cf0545..0d0ec6479c5e 100644 --- a/extensions/source/logging/csvformatter.cxx +++ b/extensions/source/logging/csvformatter.cxx @@ -90,9 +90,9 @@ namespace const sal_Unicode comma_char = ','; constexpr OUStringLiteral dos_newline = u"\r\n"; - bool needsQuoting(const OUString& str) + bool needsQuoting(std::u16string_view str) { - return std::u16string_view(str).find_first_of(u"\",\n\r") != std::u16string_view::npos; + return str.find_first_of(u"\",\n\r") != std::u16string_view::npos; }; void appendEncodedString(OUStringBuffer& buf, const OUString& str) diff --git a/forms/source/xforms/resourcehelper.cxx b/forms/source/xforms/resourcehelper.cxx index 371b707f8c85..2fbfe06f1258 100644 --- a/forms/source/xforms/resourcehelper.cxx +++ b/forms/source/xforms/resourcehelper.cxx @@ -34,22 +34,22 @@ OUString getResource(const char* pResourceId) } OUString getResource(const char* pResourceId, - const OUString& rInfo1) + std::u16string_view rInfo1) { return getResource(pResourceId, rInfo1, OUString(), OUString()); } OUString getResource(const char* pResourceId, - const OUString& rInfo1, - const OUString& rInfo2) + std::u16string_view rInfo1, + std::u16string_view rInfo2) { return getResource(pResourceId, rInfo1, rInfo2, OUString()); } OUString getResource(const char* pResourceId, - const OUString& rInfo1, - const OUString& rInfo2, - const OUString& rInfo3) + std::u16string_view rInfo1, + std::u16string_view rInfo2, + std::u16string_view rInfo3) { OUString sResource = frm::ResourceManager::loadString(pResourceId); OSL_ENSURE( !sResource.isEmpty(), "resource not found?" ); diff --git a/forms/source/xforms/resourcehelper.hxx b/forms/source/xforms/resourcehelper.hxx index c41e6521d271..6741ec10764e 100644 --- a/forms/source/xforms/resourcehelper.hxx +++ b/forms/source/xforms/resourcehelper.hxx @@ -19,6 +19,10 @@ #ifndef INCLUDED_FORMS_SOURCE_XFORMS_RESOURCEHELPER_HXX #define INCLUDED_FORMS_SOURCE_XFORMS_RESOURCEHELPER_HXX +#include <sal/config.h> + +#include <string_view> + #include <rtl/ustring.hxx> namespace xforms @@ -27,12 +31,12 @@ namespace xforms OUString getResource(const char*); // overloaded: get a resource string, and substitute parameters - OUString getResource(const char*, const OUString&); - OUString getResource(const char*, const OUString&, - const OUString&); - OUString getResource(const char*, const OUString&, - const OUString&, - const OUString&); + OUString getResource(const char*, std::u16string_view); + OUString getResource(const char*, std::u16string_view, + std::u16string_view); + OUString getResource(const char*, std::u16string_view, + std::u16string_view, + std::u16string_view); } // namespace diff --git a/framework/inc/uielement/menubarmerger.hxx b/framework/inc/uielement/menubarmerger.hxx index 139c40efc818..8646563b86d8 100644 --- a/framework/inc/uielement/menubarmerger.hxx +++ b/framework/inc/uielement/menubarmerger.hxx @@ -24,6 +24,8 @@ #include <rtl/ustring.hxx> #include <vcl/menu.hxx> + +#include <string_view> #include <vector> namespace framework @@ -58,7 +60,8 @@ struct ReferencePathInfo namespace MenuBarMerger { - bool IsCorrectContext( const OUString& aContext, const OUString& aModuleIdentifier ); + bool IsCorrectContext( + const OUString& aContext, std::u16string_view aModuleIdentifier ); void RetrieveReferencePath( const OUString&, std::vector< OUString >& aReferencePath ); @@ -81,7 +84,7 @@ namespace MenuBarMerger const OUString& rMergeCommand, const OUString& rMergeFallback, const ::std::vector< OUString >& rReferencePath, - const OUString& rModuleIdentifier, + std::u16string_view rModuleIdentifier, const AddonMenuContainer& rAddonMenuItems ); bool MergeMenuItems( Menu* pMenu, sal_uInt16 nPos, diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx index 73aa7fd472f0..497862fae127 100644 --- a/framework/inc/uielement/statusbarmerger.hxx +++ b/framework/inc/uielement/statusbarmerger.hxx @@ -19,6 +19,10 @@ #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX #define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX +#include <sal/config.h> + +#include <string_view> + #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <rtl/ustring.hxx> @@ -45,7 +49,7 @@ typedef ::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer; namespace StatusbarMerger { - bool IsCorrectContext( const OUString& aContext ); + bool IsCorrectContext( std::u16string_view aContext ); bool ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence, AddonStatusbarItemContainer& rContainer ); diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx index 526b4fb5fb81..532cab083b7d 100644 --- a/framework/source/uielement/menubarmerger.cxx +++ b/framework/source/uielement/menubarmerger.cxx @@ -55,7 +55,8 @@ namespace framework description of css::frame::XModuleManager. */ -bool MenuBarMerger::IsCorrectContext( const OUString& rContext, const OUString& rModuleIdentifier ) +bool MenuBarMerger::IsCorrectContext( + const OUString& rContext, std::u16string_view rModuleIdentifier ) { return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 )); } @@ -309,7 +310,7 @@ bool MenuBarMerger::ProcessFallbackOperation( const OUString& rMergeCommand, const OUString& rMergeFallback, const ::std::vector< OUString >& rReferencePath, - const OUString& rModuleIdentifier, + const std::u16string_view rModuleIdentifier, const AddonMenuContainer& rAddonMenuItems ) { if (( rMergeFallback == MERGEFALLBACK_IGNORE ) || diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx index ed6948a70e1a..5b3868e9a0ac 100644 --- a/framework/source/uielement/statusbarmerger.cxx +++ b/framework/source/uielement/statusbarmerger.cxx @@ -152,9 +152,9 @@ bool lcl_RemoveItems( StatusBar* pStatusbar, } bool StatusbarMerger::IsCorrectContext( - const OUString& rContext ) + std::u16string_view rContext ) { - return rContext.isEmpty(); + return rContext.empty(); } bool StatusbarMerger::ConvertSeqSeqToVector( diff --git a/framework/source/uifactory/addonstoolbarfactory.cxx b/framework/source/uifactory/addonstoolbarfactory.cxx index 0c3f5d4fba7c..63742c89249c 100644 --- a/framework/source/uifactory/addonstoolbarfactory.cxx +++ b/framework/source/uifactory/addonstoolbarfactory.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <uielement/addonstoolbarwrapper.hxx> #include <com/sun/star/frame/ModuleManager.hpp> @@ -79,12 +83,12 @@ AddonsToolBarFactory::AddonsToolBarFactory( { } -bool IsCorrectContext( const OUString& rModuleIdentifier, const OUString& aContextList ) +bool IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& aContextList ) { if ( aContextList.isEmpty() ) return true; - if ( !rModuleIdentifier.isEmpty() ) + if ( !rModuleIdentifier.empty() ) { sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier ); return ( nIndex >= 0 ); diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx index 27d965d4b2bb..0aa999ae729a 100644 --- a/include/connectivity/dbtools.hxx +++ b/include/connectivity/dbtools.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_CONNECTIVITY_DBTOOLS_HXX #define INCLUDED_CONNECTIVITY_DBTOOLS_HXX +#include <sal/config.h> + +#include <string_view> + #include <connectivity/dbexception.hxx> #include <comphelper/stl_types.hxx> #include <unotools/sharedunocomponent.hxx> @@ -619,7 +623,7 @@ namespace dbtools OUString createStandardCreateStatement( const css::uno::Reference< css::beans::XPropertySet >& descriptor, const css::uno::Reference< css::sdbc::XConnection>& _xConnection, ISQLStatementHelper* _pHelper, - const OUString& _sCreatePattern); + std::u16string_view _sCreatePattern); /** creates the standard sql statement for the key part of a create table statement. @param descriptor @@ -642,7 +646,7 @@ namespace dbtools OOO_DLLPUBLIC_DBTOOLS OUString createStandardTypePart( const css::uno::Reference< css::beans::XPropertySet >& descriptor ,const css::uno::Reference< css::sdbc::XConnection>& _xConnection - ,const OUString& _sCreatePattern = OUString()); + ,std::u16string_view _sCreatePattern = {}); /** creates the standard sql statement for the column part of a create table statement. @param _pHelper @@ -658,7 +662,7 @@ namespace dbtools OUString createStandardColumnPart( const css::uno::Reference< css::beans::XPropertySet >& descriptor ,const css::uno::Reference< css::sdbc::XConnection>& _xConnection ,ISQLStatementHelper* _pHelper = nullptr - ,const OUString& _sCreatePattern = OUString()); + ,std::u16string_view _sCreatePattern = {}); /** creates a SQL CREATE TABLE statement diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx index 5f95471bc9ab..b8693c00fdeb 100644 --- a/include/oox/drawingml/drawingmltypes.hxx +++ b/include/oox/drawingml/drawingmltypes.hxx @@ -21,6 +21,7 @@ #define INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX #include <memory> +#include <string_view> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> @@ -103,22 +104,22 @@ css::geometry::IntegerRectangle2D GetRelativeRect( const css::uno::Reference< cs sal_Int32 GetCoordinate( sal_Int32 nValue ); /** converts an emu string into 1/100th mmm */ -sal_Int32 GetCoordinate( const OUString& sValue ); +sal_Int32 GetCoordinate( std::u16string_view sValue ); /** converts 1/100mm to EMU */ sal_Int32 GetPointFromCoordinate( sal_Int32 nValue ); /** converts a ST_Percentage % string into 1/1000th of % */ -sal_Int32 GetPercent( const OUString& sValue ); +sal_Int32 GetPercent( std::u16string_view sValue ); /** Converts a ST_PositiveFixedPercentage to a float. 1.0 == 100% */ double GetPositiveFixedPercentage( const OUString& sValue ); /** converts the ST_TextFontSize to point */ -float GetTextSize( const OUString& rValue ); +float GetTextSize( std::u16string_view rValue ); /** converts the ST_TextSpacingPoint to 1/100mm */ -sal_Int32 GetTextSpacingPoint( const OUString& sValue ); +sal_Int32 GetTextSpacingPoint( std::u16string_view sValue ); sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue ); /** */ diff --git a/include/sfx2/QuerySaveDocument.hxx b/include/sfx2/QuerySaveDocument.hxx index 00aecfeaea99..b006074b4efa 100644 --- a/include/sfx2/QuerySaveDocument.hxx +++ b/include/sfx2/QuerySaveDocument.hxx @@ -19,6 +19,10 @@ #ifndef INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX #define INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX +#include <sal/config.h> + +#include <string_view> + #include <rtl/ustring.hxx> #include <sfx2/dllapi.h> @@ -31,7 +35,7 @@ namespace weld { class Widget; } The title of the document. */ SFX2_DLLPUBLIC short ExecuteQuerySaveDocument( - weld::Widget* _pParent, const OUString& _rTitle); + weld::Widget* _pParent, std::u16string_view _rTitle); #endif // INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 58397cea2c05..6e9c9505fde9 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -22,6 +22,7 @@ #include <memory> #include <map> +#include <string_view> #include <vector> #ifdef check # //some problem with MacOSX and a check define @@ -492,7 +493,7 @@ protected: /* * @return true if rValue is "True", "true", "1", etc. */ -bool toBool(const OUString &rValue); +bool toBool(std::u16string_view rValue); #endif diff --git a/include/vcl/stdtext.hxx b/include/vcl/stdtext.hxx index c98e4c4c7779..c77e5ebfca42 100644 --- a/include/vcl/stdtext.hxx +++ b/include/vcl/stdtext.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_VCL_STDTEXT_HXX #define INCLUDED_VCL_STDTEXT_HXX +#include <sal/config.h> + +#include <string_view> + #include <rtl/ustring.hxx> #include <tools/wintypes.hxx> #include <vcl/dllapi.h> @@ -27,7 +31,7 @@ class Image; namespace weld { class Widget; } -void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget* pParent, const OUString& rServiceName, bool bError); +void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget* pParent, std::u16string_view rServiceName, bool bError); OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton); diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx index 432ce7dc416c..645fe9ec9221 100644 --- a/oox/source/drawingml/drawingmltypes.cxx +++ b/oox/source/drawingml/drawingmltypes.cxx @@ -45,7 +45,7 @@ sal_Int32 GetCoordinate( sal_Int32 nValue ) } /** converts an emu string into 1/100th mmm */ -sal_Int32 GetCoordinate( const OUString& sValue ) +sal_Int32 GetCoordinate( std::u16string_view sValue ) { sal_Int32 nRet = 0; if( !::sax::Converter::convertNumber( nRet, sValue ) ) @@ -60,7 +60,7 @@ sal_Int32 GetPointFromCoordinate( sal_Int32 nValue ) } /** converts a ST_Percentage % string into 1/1000th of % */ -sal_Int32 GetPercent( const OUString& sValue ) +sal_Int32 GetPercent( std::u16string_view sValue ) { sal_Int32 nRet = 0; if( !::sax::Converter::convertNumber( nRet, sValue ) ) @@ -82,7 +82,7 @@ awt::Point GetPointPercent( const Reference< XFastAttributeList >& xAttribs ) } /** converts the ST_TextFontSize to point */ -float GetTextSize( const OUString& sValue ) +float GetTextSize( std::u16string_view sValue ) { float fRet = 0; sal_Int32 nRet; @@ -92,7 +92,7 @@ float GetTextSize( const OUString& sValue ) } /** converts the ST_TextSpacingPoint to 1/100mm */ -sal_Int32 GetTextSpacingPoint( const OUString& sValue ) +sal_Int32 GetTextSpacingPoint( std::u16string_view sValue ) { sal_Int32 nRet; if( ::sax::Converter::convertNumber( nRet, sValue, (SAL_MIN_INT32 + 360) / 254, (SAL_MAX_INT32 - 360) / 254 ) ) diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index 8afd92cc5979..fe4c7df47f0b 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -135,7 +135,7 @@ PropBrw::PropBrw(const Reference< XComponentContext >& _xORB, vcl::Window* pPare m_xBrowserController = inspection::ObjectInspector::createWithModel(m_xInspectorContext, xInspectorModel); if ( !m_xBrowserController.is() ) { - ShowServiceNotAvailableError(pParent ? pParent->GetFrameWeld() : nullptr, "com.sun.star.inspection.ObjectInspector", true); + ShowServiceNotAvailableError(pParent ? pParent->GetFrameWeld() : nullptr, u"com.sun.star.inspection.ObjectInspector", true); } else { diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 52e07726daa1..507a7aeb2eef 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -76,6 +76,7 @@ #include <vector> #include <memory> #include <limits> +#include <string_view> const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48 @@ -9038,7 +9039,7 @@ static bool IsDBCS(sal_Unicode currentChar) bRet = (i < SAL_N_ELEMENTS(scriptList) && block >= scriptList[i].from); return bRet; } -static sal_Int32 lcl_getLengthB( const OUString &str, sal_Int32 nPos ) +static sal_Int32 lcl_getLengthB( std::u16string_view str, sal_Int32 nPos ) { sal_Int32 index = 0; sal_Int32 length = 0; diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx index 532e9187f289..05c4b673d0fe 100644 --- a/sc/source/filter/excel/xehelper.cxx +++ b/sc/source/filter/excel/xehelper.cxx @@ -890,7 +890,7 @@ namespace { /** Encodes special parts of the URL, i.e. directory separators and volume names. @param pTableName Pointer to a table name to be encoded in this URL, or 0. */ OUString lclEncodeDosUrl( - XclBiff eBiff, const OUString& rUrl, const OUString& rBase, const OUString* pTableName) + XclBiff eBiff, const OUString& rUrl, std::u16string_view rBase, const OUString* pTableName) { OUStringBuffer aBuf; @@ -908,7 +908,7 @@ OUString lclEncodeDosUrl( else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) ) { // drive letter - sal_Unicode cThisDrive = rBase.isEmpty() ? ' ' : rBase[0]; + sal_Unicode cThisDrive = rBase.empty() ? ' ' : rBase[0]; sal_Unicode cDrive = aOldUrl[0]; if (cThisDrive == cDrive) // This document and the referenced document are under the same drive. diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx index 5ca24adb1b42..922b0ccb93a1 100644 --- a/sc/source/filter/oox/numberformatsbuffer.cxx +++ b/sc/source/filter/oox/numberformatsbuffer.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <numberformatsbuffer.hxx> #include <biffhelper.hxx> @@ -1871,7 +1875,7 @@ NumberFormatFinalizer::NumberFormatFinalizer( const WorkbookHelper& rHelper ) : OSL_ENSURE( mxNumFmts.is(), "NumberFormatFinalizer::NumberFormatFinalizer - cannot get number formats" ); } -sal_Int32 lclPosToken ( const OUString& sFormat, const OUString& sSearch, sal_Int32 nStartPos ) +sal_Int32 lclPosToken ( const OUString& sFormat, std::u16string_view sSearch, sal_Int32 nStartPos ) { sal_Int32 nLength = sFormat.getLength(); for ( sal_Int32 i = nStartPos; i < nLength && i >= 0 ; i++ ) @@ -1912,7 +1916,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode ) sal_Int32 nLastIndex = rFmtCode.getLength() - 1; OUStringBuffer sFormat = rFmtCode; - while ( ( nPosEscape = lclPosToken( rFmtCode, "\\ ", nPosEscape ) ) > 0 ) + while ( ( nPosEscape = lclPosToken( rFmtCode, u"\\ ", nPosEscape ) ) > 0 ) { sal_Int32 nPos = nPosEscape + 2; while ( nPos < nLastIndex && ( rFmtCode[nPos] == '?' || rFmtCode[nPos] == '#' || rFmtCode[nPos] == '0' ) ) @@ -1922,7 +1926,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode ) sFormat.remove(nPosEscape - nErase, 1); nErase ++; } // tdf#81939 preserve other escape characters - nPosEscape = lclPosToken( rFmtCode, ";", nPosEscape ); // skip to next format + nPosEscape = lclPosToken( rFmtCode, u";", nPosEscape ); // skip to next format } maModel.maFmtCode = sFormat.makeStringAndClear(); } diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index 61cb5a9b0f12..0ec73e1a95ad 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -18,6 +18,8 @@ */ #include <memory> +#include <string_view> + #include <sal/config.h> #include <AccessibleCell.hxx> @@ -461,7 +463,7 @@ void ScAccessibleCell::AddRelation(const ScRange& rRange, pRelationSet->AddRelation(aRelation); } -static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr) +static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, const OUString& replaceStr) { int iReplace = oldOUString.lastIndexOf(replacedChar); OUString aRet = oldOUString; @@ -475,11 +477,11 @@ static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& repl static OUString ReplaceFourChar(const OUString& oldOUString) { - OUString aRet = ReplaceOneChar(oldOUString, "\\", "\\\\"); - aRet = ReplaceOneChar(aRet, ";", "\\;"); - aRet = ReplaceOneChar(aRet, "=", "\\="); - aRet = ReplaceOneChar(aRet, ",", "\\,"); - aRet = ReplaceOneChar(aRet, ":", "\\:"); + OUString aRet = ReplaceOneChar(oldOUString, u"\\", "\\\\"); + aRet = ReplaceOneChar(aRet, u";", "\\;"); + aRet = ReplaceOneChar(aRet, u"=", "\\="); + aRet = ReplaceOneChar(aRet, u",", "\\,"); + aRet = ReplaceOneChar(aRet, u":", "\\:"); return aRet; } diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx index 37e580bfa403..8b83ff5eb952 100644 --- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx @@ -9,6 +9,7 @@ */ #include <memory> +#include <string_view> #include <rangelst.hxx> #include <reffact.hxx> @@ -48,11 +49,11 @@ const char* lclAnovaLabels[] = nullptr }; -const char strWildcardRange[] = "%RANGE%"; +const OUStringLiteral strWildcardRange = u"%RANGE%"; OUString lclCreateMultiParameterFormula( ScRangeList& aRangeList, const OUString& aFormulaTemplate, - const OUString& aWildcard, const ScDocument& rDocument, + std::u16string_view aWildcard, const ScDocument& rDocument, const ScAddress::Details& aAddressDetails) { OUStringBuffer aResult; diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 60fd4b939de3..02c6054751b2 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -19,6 +19,7 @@ #include <memory> +#include <string_view> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -343,7 +344,7 @@ lcl_removeUnusedStyles(SfxStyleSheetBasePool* const pStyleSheetPool, StyleSheetC rStyles = aUsedStyles; } -SfxStyleSheet *lcl_findStyle(StyleSheetCopyResultVector& rStyles, const OUString& aStyleName) +SfxStyleSheet *lcl_findStyle(StyleSheetCopyResultVector& rStyles, std::u16string_view aStyleName) { for (const auto& a : rStyles) { @@ -921,7 +922,7 @@ bool SdDrawDocument::InsertBookmarkAsPage( if(pPg->GetObj(i)->GetStyleSheet()) { OUString aStyleName = pPg->GetObj(i)->GetStyleSheet()->GetName(); - SfxStyleSheet *pSheet = lcl_findStyle(aNewGraphicStyles, aStyleName + aRenameStr); + SfxStyleSheet *pSheet = lcl_findStyle(aNewGraphicStyles, OUString(aStyleName + aRenameStr)); if(pSheet != nullptr) pPg->GetObj(i)->SetStyleSheet(pSheet, true); } diff --git a/sfx2/source/doc/QuerySaveDocument.cxx b/sfx2/source/doc/QuerySaveDocument.cxx index 9d66a164563c..138db6393dc4 100644 --- a/sfx2/source/doc/QuerySaveDocument.cxx +++ b/sfx2/source/doc/QuerySaveDocument.cxx @@ -21,7 +21,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> -short ExecuteQuerySaveDocument(weld::Widget* _pParent, const OUString& _rTitle) +short ExecuteQuerySaveDocument(weld::Widget* _pParent, std::u16string_view _rTitle) { if (Application::IsHeadlessModeEnabled()) { diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index b64be198620b..1dd0495e4d54 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -89,6 +89,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/stringloop \ compilerplugins/clang/test/stringstatic \ compilerplugins/clang/test/stringview \ + compilerplugins/clang/test/stringviewparam \ compilerplugins/clang/test/typedefparam \ compilerplugins/clang/test/unnecessarycatchthrow \ compilerplugins/clang/test/unnecessaryoverride \ diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx index a78c3210cd7f..82d58cc2e472 100644 --- a/svgio/inc/svgtools.hxx +++ b/svgio/inc/svgtools.hxx @@ -25,6 +25,8 @@ #include <basegfx/vector/b2ivector.hxx> #include <rtl/ustrbuf.hxx> #include "svgpaint.hxx" + +#include <string_view> #include <vector> namespace svgio::svgreader @@ -179,16 +181,16 @@ namespace svgio::svgreader basegfx::B2DHomMatrix createMapping(const basegfx::B2DRange& rTarget, const basegfx::B2DRange& rSource) const; }; - void skip_char(const OUString& rCandidate, sal_Unicode aChar, sal_Int32& nPos, const sal_Int32 nLen); - void skip_char(const OUString& rCandidate, sal_Unicode aCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen); - void copySign(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); - void copyNumber(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); - void copyHex(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); - void copyString(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); - void copyToLimiter(const OUString& rCandidate, sal_Unicode aLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); - bool readNumber(const OUString& rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen); - SvgUnit readUnit(const OUString& rCandidate, sal_Int32& nPos, const sal_Int32 nLen); - bool readNumberAndUnit(const OUString& rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen); + void skip_char(std::u16string_view rCandidate, sal_Unicode aChar, sal_Int32& nPos, const sal_Int32 nLen); + void skip_char(std::u16string_view rCandidate, sal_Unicode aCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen); + void copySign(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); + void copyNumber(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); + void copyHex(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); + void copyString(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); + void copyToLimiter(std::u16string_view rCandidate, sal_Unicode aLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen); + bool readNumber(std::u16string_view rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen); + SvgUnit readUnit(std::u16string_view rCandidate, sal_Int32& nPos, const sal_Int32 nLen); + bool readNumberAndUnit(std::u16string_view rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen); bool readAngle(const OUString& rCandidate, sal_Int32& nPos, double& fAngle, const sal_Int32 nLen); sal_Int32 read_hex(sal_Unicode aChar); bool match_colorKeyword(basegfx::BColor& rColor, const OUString& rName, bool bCaseIndependent); diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 867c3b1b0bea..1aadf895b9a2 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -272,7 +272,7 @@ namespace svgio::svgreader return basegfx::fTools::moreOrEqual(mfNumber, 0.0); } - void skip_char(const OUString& rCandidate, sal_Unicode nChar, sal_Int32& nPos, const sal_Int32 nLen) + void skip_char(std::u16string_view rCandidate, sal_Unicode nChar, sal_Int32& nPos, const sal_Int32 nLen) { while(nPos < nLen && nChar == rCandidate[nPos]) { @@ -280,7 +280,7 @@ namespace svgio::svgreader } } - void skip_char(const OUString& rCandidate, sal_Unicode nCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen) + void skip_char(std::u16string_view rCandidate, sal_Unicode nCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen) { while(nPos < nLen && (nCharA == rCandidate[nPos] || nCharB == rCandidate[nPos])) { @@ -288,7 +288,7 @@ namespace svgio::svgreader } } - void copySign(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) + void copySign(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) { if(nPos < nLen) { @@ -302,7 +302,7 @@ namespace svgio::svgreader } } - void copyNumber(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) + void copyNumber(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) { bool bOnNumber(true); @@ -320,7 +320,7 @@ namespace svgio::svgreader } } - void copyHex(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) + void copyHex(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) { bool bOnHex(true); @@ -340,7 +340,7 @@ namespace svgio::svgreader } } - void copyString(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) + void copyString(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) { bool bOnChar(true); @@ -360,7 +360,7 @@ namespace svgio::svgreader } } - void copyToLimiter(const OUString& rCandidate, sal_Unicode nLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) + void copyToLimiter(std::u16string_view rCandidate, sal_Unicode nLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen) { while(nPos < nLen && nLimiter != rCandidate[nPos]) { @@ -369,7 +369,7 @@ namespace svgio::svgreader } } - bool readNumber(const OUString& rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen) + bool readNumber(std::u16string_view rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen) { if(nPos < nLen) { @@ -421,7 +421,7 @@ namespace svgio::svgreader return false; } - SvgUnit readUnit(const OUString& rCandidate, sal_Int32& nPos, const sal_Int32 nLen) + SvgUnit readUnit(std::u16string_view rCandidate, sal_Int32& nPos, const sal_Int32 nLen) { SvgUnit aRetval(Unit_px); @@ -524,7 +524,7 @@ namespace svgio::svgreader return aRetval; } - bool readNumberAndUnit(const OUString& rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen) + bool readNumberAndUnit(std::u16string_view rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen) { double fNum(0.0); diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 4974fe9d5ac4..92e62e87aeae 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5052,7 +5052,7 @@ const Color* SvNumberformat::GetColor( sal_uInt16 nNumFor ) const static void lcl_SvNumberformat_AddLimitStringImpl( OUString& rStr, SvNumberformatLimitOps eOp, - double fLimit, const OUString& rDecSep ) + double fLimit, std::u16string_view rDecSep ) { if ( eOp == NUMBERFORMAT_OP_NO ) return; diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index e36cae84ab20..f3a3bbd03fd3 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -686,7 +686,7 @@ void AssignmentPersistentData::ImplCommit() catch(const Exception&) { } if (!m_xDatabaseContext.is()) { - ShowServiceNotAvailableError(m_xDialog.get(), "com.sun.star.sdb.DatabaseContext", false); + ShowServiceNotAvailableError(m_xDialog.get(), u"com.sun.star.sdb.DatabaseContext", false); return; } } @@ -731,7 +731,7 @@ void AssignmentPersistentData::ImplCommit() catch(const Exception&) { } if (!xHandler.is()) { - ShowServiceNotAvailableError(m_xDialog.get(), "com.sun.star.task.InteractionHandler", true); + ShowServiceNotAvailableError(m_xDialog.get(), u"com.sun.star.task.InteractionHandler", true); return; } @@ -1074,7 +1074,7 @@ void AssignmentPersistentData::ImplCommit() catch(const Exception&) { } if (!xAdminDialog.is()) { - ShowServiceNotAvailableError(m_xDialog.get(), "com.sun.star.ui.dialogs.AddressBookSourcePilot", true); + ShowServiceNotAvailableError(m_xDialog.get(), u"com.sun.star.ui.dialogs.AddressBookSourcePilot", true); return; } diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index 2d1700f65f4e..478057eadf1e 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -474,7 +474,7 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) if ( !m_xBrowserController.is() ) { - ShowServiceNotAvailableError(m_pParent, "com.sun.star.inspection.ObjectInspector", true); + ShowServiceNotAvailableError(m_pParent, u"com.sun.star.inspection.ObjectInspector", true); } else { diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index ee533636e29d..a1b52d41c98f 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -39,6 +39,7 @@ #include "acccell.hxx" #include <cfloat> +#include <string_view> #include <editeng/brushitem.hxx> #include <swatrset.hxx> @@ -364,7 +365,7 @@ uno::Any SwAccessibleCell::getMinimumValue( ) return uno::Any(-DBL_MAX); } -static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr) +static OUString ReplaceOneChar(const OUString& oldOUString, std::u16string_view replacedChar, const OUString& replaceStr) { int iReplace = oldOUString.lastIndexOf(replacedChar); OUString aRet = oldOUString; @@ -378,11 +379,11 @@ static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& repl static OUString ReplaceFourChar(const OUString& oldOUString) { - OUString aRet = ReplaceOneChar(oldOUString,"\\","\\\\"); - aRet = ReplaceOneChar(aRet,";","\\;"); - aRet = ReplaceOneChar(aRet,"=","\\="); - aRet = ReplaceOneChar(aRet,",","\\,"); - aRet = ReplaceOneChar(aRet,":","\\:"); + OUString aRet = ReplaceOneChar(oldOUString,u"\\","\\\\"); + aRet = ReplaceOneChar(aRet,u";","\\;"); + aRet = ReplaceOneChar(aRet,u"=","\\="); + aRet = ReplaceOneChar(aRet,u",","\\,"); + aRet = ReplaceOneChar(aRet,u":","\\:"); return aRet; } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 5e03d523dd70..e308e467571b 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -85,6 +85,7 @@ #include <sortedobjs.hxx> +#include <string_view> #include <vector> using namespace ::com::sun::star; @@ -1273,7 +1274,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel( return pNewFormat; } -static void lcl_collectUsedNums(std::vector<unsigned int>& rSetFlags, sal_Int32 nNmLen, const OUString& rName, const OUString& rCmpName) +static void lcl_collectUsedNums(std::vector<unsigned int>& rSetFlags, sal_Int32 nNmLen, const OUString& rName, std::u16string_view rCmpName) { if (rName.startsWith(rCmpName)) { diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 0812f3bebc8b..49d7e26e9acc 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <editsh.hxx> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -277,7 +281,7 @@ std::map<OUString, OUString> lcl_getRDFStatements(const uno::Reference<frame::XM /// Returns RDF (key, value) pair associated with the field, if any. std::pair<OUString, OUString> lcl_getFieldRDFByPrefix(const uno::Reference<frame::XModel>& xModel, const uno::Reference<css::text::XTextField>& xField, - const OUString& sPrefix) + std::u16string_view sPrefix) { for (const auto& pair : lcl_getRDFStatements(xModel, xField)) { @@ -705,7 +709,7 @@ static void insertFieldToDocument(uno::Reference<lang::XMultiServiceFactory> con rxText->insertTextContent(rxParagraphCursor, xTextContent, false); } -static void removeAllClassificationFields(OUString const & rPolicy, uno::Reference<text::XText> const & rxText) +static void removeAllClassificationFields(std::u16string_view rPolicy, uno::Reference<text::XText> const & rxText) { uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(rxText, uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParagraphs = xParagraphEnumerationAccess->createEnumeration(); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 7a72d65b12f4..06a4e5f4b7c7 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include "porlay.hxx" #include "itrform2.hxx" #include "porglue.hxx" @@ -157,7 +161,7 @@ static bool lcl_ConnectToPrev( sal_Unicode cCh, sal_Unicode cPrevCh ) return bRet; } -static bool lcl_HasStrongLTR ( const OUString& rText, sal_Int32 nStart, sal_Int32 nEnd ) +static bool lcl_HasStrongLTR ( std::u16string_view rText, sal_Int32 nStart, sal_Int32 nEnd ) { for( sal_Int32 nCharIdx = nStart; nCharIdx < nEnd; ++nCharIdx ) { @@ -313,7 +317,7 @@ void SwLineLayout::CreateSpaceAdd( const tools::Long nInit ) } // Returns true if there are only blanks in [nStt, nEnd[ -static bool lcl_HasOnlyBlanks(const OUString& rText, TextFrameIndex nStt, TextFrameIndex nEnd) +static bool lcl_HasOnlyBlanks(std::u16string_view rText, TextFrameIndex nStt, TextFrameIndex nEnd) { bool bBlankOnly = true; while ( nStt < nEnd ) diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx index 5ea4560e9907..3c618ecb5b52 100644 --- a/sw/source/filter/ascii/wrtasc.cxx +++ b/sw/source/filter/ascii/wrtasc.cxx @@ -203,7 +203,8 @@ ErrCode SwASCWriter::WriteStream() return ERRCODE_NONE; } -void GetASCWriter( const OUString& rFltNm, const OUString& /*rBaseURL*/, WriterRef& xRet ) +void GetASCWriter( + const OUString& rFltNm, [[maybe_unused]] const OUString& /*rBaseURL*/, WriterRef& xRet ) { xRet = new SwASCWriter( rFltNm ); } diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 3c1a468474ff..d8764612cc72 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -559,7 +559,8 @@ bool SwXMLWriter::WriteThroughComponent( return xFilter->filter( rMediaDesc ); } -void GetXMLWriter( const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet ) +void GetXMLWriter( + [[maybe_unused]] const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet ) { xRet = new SwXMLWriter( rBaseURL ); } diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx index 8999482195ae..4e85ad795825 100644 --- a/unoidl/source/unoidlprovider.cxx +++ b/unoidl/source/unoidlprovider.cxx @@ -13,6 +13,7 @@ #include <cassert> #include <cstring> #include <set> +#include <string_view> #include <vector> #include <osl/endian.h> @@ -466,7 +467,7 @@ namespace { enum Compare { COMPARE_LESS, COMPARE_GREATER, COMPARE_EQUAL }; Compare compare( - rtl::Reference< MappedFile > const & file, OUString const & name, + rtl::Reference< MappedFile > const & file, std::u16string_view name, sal_Int32 nameOffset, sal_Int32 nameLength, MapEntry const * entry) { assert(file.is()); diff --git a/vcl/inc/driverblocklist.hxx b/vcl/inc/driverblocklist.hxx index fa85dd7dab24..c63fc14acd61 100644 --- a/vcl/inc/driverblocklist.hxx +++ b/vcl/inc/driverblocklist.hxx @@ -26,7 +26,7 @@ enum class VersionType }; VCL_DLLPUBLIC bool IsDeviceBlocked(const OUString& blocklistURL, VersionType versionType, - const OUString& driverVersion, const OUString& vendorId, + const OUString& driverVersion, std::u16string_view vendorId, const OUString& deviceId); #ifdef _WIN32 @@ -144,7 +144,7 @@ OUString VCL_DLLPUBLIC GetVendorId(DeviceVendor id); bool VCL_DLLPUBLIC FindBlocklistedDeviceInList( std::vector<DriverInfo>& aDeviceInfos, VersionType versionType, OUString const& sDriverVersion, - OUString const& sAdapterVendorID, OUString const& sAdapterDeviceID, OperatingSystem system, + std::u16string_view sAdapterVendorID, OUString const& sAdapterDeviceID, OperatingSystem system, const OUString& blocklistURL = OUString()); #define GFX_DRIVER_VERSION(a, b, c, d) \ diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx index 7d6bae82016c..0d5e8411bc60 100644 --- a/vcl/source/app/stdtext.cxx +++ b/vcl/source/app/stdtext.cxx @@ -25,7 +25,7 @@ #include <svdata.hxx> void ShowServiceNotAvailableError(weld::Widget* pParent, - const OUString& rServiceName, bool bError) + std::u16string_view rServiceName, bool bError) { OUString aText = VclResId(SV_STDTEXT_SERVICENOTAVAILABLE).replaceAll("%s", rServiceName); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 7fbeed108d99..fc39b48de12d 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -461,7 +461,7 @@ static void ImplPatternProcessStrictModify( weld::Entry& rEntry, rEntry.select_region(nStartPos, nEndPos); } -static sal_Int32 ImplPatternLeftPos(const OString& rEditMask, sal_Int32 nCursorPos) +static sal_Int32 ImplPatternLeftPos(std::string_view rEditMask, sal_Int32 nCursorPos) { // search non-literal predecessor sal_Int32 nNewPos = nCursorPos; @@ -1193,7 +1193,7 @@ static sal_uInt16 ImplCutNumberFromString( OUString& rStr ) return nValue; } -static bool ImplCutMonthName( OUString& rStr, const OUString& _rLookupMonthName ) +static bool ImplCutMonthName( OUString& rStr, std::u16string_view _rLookupMonthName ) { sal_Int32 index = 0; rStr = rStr.replaceFirst(_rLookupMonthName, "", &index); diff --git a/vcl/source/helper/driverblocklist.cxx b/vcl/source/helper/driverblocklist.cxx index 0fb1edd73f75..a24cdc98fbcb 100644 --- a/vcl/source/helper/driverblocklist.cxx +++ b/vcl/source/helper/driverblocklist.cxx @@ -596,7 +596,8 @@ DriverInfo::DriverInfo(OperatingSystem os, const OUString& vendor, VersionCompar } bool FindBlocklistedDeviceInList(std::vector<DriverInfo>& aDeviceInfos, VersionType versionType, - OUString const& sDriverVersion, OUString const& sAdapterVendorID, + OUString const& sDriverVersion, + std::u16string_view sAdapterVendorID, OUString const& sAdapterDeviceID, OperatingSystem system, const OUString& blocklistURL) { @@ -700,7 +701,7 @@ bool FindBlocklistedDeviceInList(std::vector<DriverInfo>& aDeviceInfos, VersionT } bool IsDeviceBlocked(const OUString& blocklistURL, VersionType versionType, - const OUString& driverVersion, const OUString& vendorId, + const OUString& driverVersion, std::u16string_view vendorId, const OUString& deviceId) { std::vector<DriverInfo> driverList; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 3e9200df6d2e..c1163335aaff 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -11,6 +11,7 @@ #include <config_options.h> #include <memory> +#include <string_view> #include <unordered_map> #include <com/sun/star/accessibility/AccessibleRole.hpp> @@ -76,9 +77,9 @@ #include <dlfcn.h> #endif -static bool toBool(const OString &rValue) +static bool toBool(std::string_view rValue) { - return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); + return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); } namespace diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 6aa30005942e..245befc2c3a7 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1318,9 +1318,9 @@ void VclGrid::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) rJsonWriter.put("type", "grid"); } -bool toBool(const OUString &rValue) +bool toBool(std::u16string_view rValue) { - return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); + return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); } bool VclGrid::set_property(const OString &rKey, const OUString &rValue) diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 6d08fbb7842a..099e5f929adb 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -29,6 +29,10 @@ printer job functions. */ +#include <sal/config.h> + +#include <string_view> + // For spawning PDF and FAX generation #include <unistd.h> #include <sys/wait.h> @@ -340,7 +344,7 @@ static std::vector<OUString> getFaxNumbers() return aFaxNumbers; } -static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine ) +static bool createPdf( std::u16string_view rToFile, const OUString& rFromFile, const OUString& rCommandLine ) { return passFileToCommandLine( rFromFile, rCommandLine.replaceAll("(OUTFILE)", rToFile) ); } diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index ff4ee0ac168a..49206329c86d 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -45,6 +45,7 @@ #include <vector> #include <algorithm> #include <iterator> +#include <string_view> using namespace com::sun::star; using namespace ::xmloff::token; @@ -183,11 +184,11 @@ bool lcl_mapContainsRange( bool lcl_tableOfRangeMatches( const OUString & rRange, - const OUString & rTableName ) + std::u16string_view rTableName ) { // both strings are non-empty and the table name is part of the range return ( !rRange.isEmpty() && - !rTableName.isEmpty() && + !rTableName.empty() && (rRange.indexOf( rTableName ) != -1 )); } diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index 556ac4f950b3..ce3eeac8d45f 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <xexptran.hxx> #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> @@ -34,28 +38,28 @@ using namespace ::com::sun::star; using std::make_unique; // parsing help functions for simple chars -static void Imp_SkipSpaces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen) +static void Imp_SkipSpaces(std::u16string_view rStr, sal_Int32& rPos, const sal_Int32 nLen) { while(rPos < nLen && ' ' == rStr[rPos]) rPos++; } -static void Imp_SkipSpacesAndOpeningBraces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen) +static void Imp_SkipSpacesAndOpeningBraces(std::u16string_view rStr, sal_Int32& rPos, const sal_Int32 nLen) { while(rPos < nLen && (' ' == rStr[rPos] || '(' == rStr[rPos])) rPos++; } -static void Imp_SkipSpacesAndCommas(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen) +static void Imp_SkipSpacesAndCommas(std::u16string_view rStr, sal_Int32& rPos, const sal_Int32 nLen) { while(rPos < nLen && (' ' == rStr[rPos] || ',' == rStr[rPos])) rPos++; } -static void Imp_SkipSpacesAndClosingBraces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen) +static void Imp_SkipSpacesAndClosingBraces(std::u16string_view rStr, sal_Int32& rPos, const sal_Int32 nLen) { while(rPos < nLen && (' ' == rStr[rPos] || ')' == rStr[rPos])) @@ -64,7 +68,7 @@ static void Imp_SkipSpacesAndClosingBraces(const OUString& rStr, sal_Int32& rPos // parsing help functions for integer numbers -static bool Imp_IsOnUnitChar(const OUString& rStr, const sal_Int32 nPos) +static bool Imp_IsOnUnitChar(std::u16string_view rStr, const sal_Int32 nPos) { sal_Unicode aChar(rStr[nPos]); @@ -73,7 +77,7 @@ static bool Imp_IsOnUnitChar(const OUString& rStr, const sal_Int32 nPos) || '%' == aChar; } -static double Imp_GetDoubleChar(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen, +static double Imp_GetDoubleChar(std::u16string_view rStr, sal_Int32& rPos, const sal_Int32 nLen, const SvXMLUnitConverter& rConv, double fRetval, bool bLookForUnits = false) { sal_Unicode aChar(rStr[rPos]); diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index b3e5dee8fc10..d3dace64ece4 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -45,6 +45,7 @@ #include <sax/tools/converter.hxx> #include <comphelper/sequence.hxx> #include <memory> +#include <string_view> #include <unordered_map> using namespace ::com::sun::star; @@ -85,7 +86,7 @@ static void GetBool( std::vector< css::beans::PropertyValue >& rDest, } static void GetInt32( std::vector< css::beans::PropertyValue >& rDest, - const OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) + std::u16string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp ) { sal_Int32 nAttrNumber; if (::sax::Converter::convertNumber( nAttrNumber, rValue )) diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index e463b1dcd89d..9be8b434df31 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -47,6 +47,7 @@ #include <float.h> #include <set> +#include <string_view> #include <vector> using namespace ::com::sun::star; @@ -836,7 +837,7 @@ void SvXMLNumFmtExport::WriteMapElement_Impl( sal_Int32 nOp, double fLimit, // for old (automatic) currency formats: parse currency symbol from text -static sal_Int32 lcl_FindSymbol( const OUString& sUpperStr, const OUString& sCurString ) +static sal_Int32 lcl_FindSymbol( const OUString& sUpperStr, std::u16string_view sCurString ) { // search for currency symbol // Quoting as in ImpSvNumberformatScan::Symbol_Division |