diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-10-13 08:44:49 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-10-15 21:15:49 +0200 |
commit | b4844c310bd9897fef59e8a4da0513100ea86096 (patch) | |
tree | 379a43d012894ff06d29d79c7d4d8009b7853501 | |
parent | 8797ba5e5d63151837ba443e1aea9d0997b6b7ab (diff) |
Repurpose loplugin:stringstatic for O[U]String vars that can be constexpr
...now that warning about O[U]String vars that could be O[U]StringLiteral is no
longer useful
Change-Id: I389e72038171f28482049b41f6224257dd11f452
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157992
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
50 files changed, 164 insertions, 326 deletions
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx index 6559b3e35d48..f17750c89a6e 100644 --- a/basic/qa/cppunit/test_scanner.cxx +++ b/basic/qa/cppunit/test_scanner.cxx @@ -69,12 +69,12 @@ private: CPPUNIT_TEST_SUITE_END(); }; -const OUString cr = "\n"; -const OUString rem = "REM"; -const OUString asdf = "asdf"; -const OUString dot = "."; -const OUString goto_ = "goto"; -const OUString excl = "!"; +constexpr OUString cr = u"\n"_ustr; +constexpr OUString rem = u"REM"_ustr; +constexpr OUString asdf = u"asdf"_ustr; +constexpr OUString dot = u"."_ustr; +constexpr OUString goto_ = u"goto"_ustr; +constexpr OUString excl = u"!"_ustr; std::vector<Symbol> getSymbols(const OUString& source, sal_Int32& errors, bool bCompatible = false) { @@ -160,14 +160,14 @@ void ScannerTest::testBlankLines() void ScannerTest::testOperators() { - const OUString sourceE("="); - const OUString sourceLT("<"); - const OUString sourceGT(">"); - const OUString sourceLTE("<="); - const OUString sourceGTE(">="); - const OUString sourceNE("<>"); - const OUString sourceA(":="); - const OUString sourceNot("Not"); + constexpr OUString sourceE(u"="_ustr); + constexpr OUString sourceLT(u"<"_ustr); + constexpr OUString sourceGT(u">"_ustr); + constexpr OUString sourceLTE(u"<="_ustr); + constexpr OUString sourceGTE(u">="_ustr); + constexpr OUString sourceNE(u"<>"_ustr); + constexpr OUString sourceA(u":="_ustr); + constexpr OUString sourceNot(u"Not"_ustr); std::vector<Symbol> symbols; @@ -239,12 +239,12 @@ void ScannerTest::testOperators() void ScannerTest::testAlphanum() { - const OUString source1("asdfghefg"); - const OUString source3("AdfsaAUdsl10987"); - const OUString source4("asdfa_mnvcnm"); - const OUString source5("_asdf1"); - const OUString source6("_6"); - const OUString source7("joxclk_"); + constexpr OUString source1(u"asdfghefg"_ustr); + constexpr OUString source3(u"AdfsaAUdsl10987"_ustr); + constexpr OUString source4(u"asdfa_mnvcnm"_ustr); + constexpr OUString source5(u"_asdf1"_ustr); + constexpr OUString source6(u"_6"_ustr); + constexpr OUString source7(u"joxclk_"_ustr); std::vector<Symbol> symbols; diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index f2f95ad5296a..a9e155a3e8c6 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -62,7 +62,7 @@ constexpr OUStringLiteral m_aMultiClick = u"MultiClick"; constexpr OUStringLiteral m_aDragMethodEquals = u"DragMethod="; constexpr OUStringLiteral m_aDragParameterEquals = u"DragParameter="; constexpr OUStringLiteral m_aProtocol = u"CID/"; -const OUString m_aPieSegmentDragMethodServiceName("PieSegmentDragging"); +constexpr OUString m_aPieSegmentDragMethodServiceName(u"PieSegmentDragging"_ustr); namespace { diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index 6493776a158b..9cd61f6f4c14 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -1512,7 +1512,7 @@ namespace comphelper const OUString& BackupFileHelper::getSafeModeName() { - static const OUString aSafeMode("SafeMode"); + static constexpr OUString aSafeMode(u"SafeMode"_ustr); return aSafeMode; } diff --git a/compilerplugins/clang/stringstatic.cxx b/compilerplugins/clang/stringstatic.cxx index 5ad225b68d80..a7439608d556 100644 --- a/compilerplugins/clang/stringstatic.cxx +++ b/compilerplugins/clang/stringstatic.cxx @@ -12,16 +12,7 @@ #include "check.hxx" #include "plugin.hxx" -#include "config_clang.h" - -#include <unordered_set> - -/** Look for static O*String and O*String[], they can be more efficiently declared as: - - static constexpr OUStringLiteral our_aLBEntryMap[] = {u" ", u", "}; - static constexpr OUStringLiteral sName(u"name"); - - which is more efficient at startup time. +/** Look for static O*String and O*String[] which can be constepxr. */ namespace { @@ -34,17 +25,7 @@ public: FilteringPlugin(rData) {} void run() override; - bool preRun() override; - void postRun() override; bool VisitVarDecl(VarDecl const*); - bool VisitReturnStmt(ReturnStmt const*); - bool VisitDeclRefExpr(DeclRefExpr const*); - bool VisitMemberExpr(MemberExpr const*); - bool VisitUnaryOperator(UnaryOperator const*); - -private: - std::unordered_set<VarDecl const *> potentialVars; - std::unordered_set<VarDecl const *> excludeVars; }; void StringStatic::run() @@ -54,51 +35,17 @@ void StringStatic::run() postRun(); } -bool StringStatic::preRun() -{ - StringRef fn(handler.getMainFileName()); - // passing around pointers to global OUString - if (loplugin::hasPathnamePrefix(fn, SRCDIR "/filter/source/svg/")) - return false; - // call replaceAll on a 'const OUString", for which there is no OUStringLiteral equivalent - if (loplugin::hasPathnamePrefix(fn, SRCDIR "/i18npool/qa/cppunit/test_breakiterator.cxx")) - return false; - if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sd/qa/unit/export-tests-ooxml2.cxx")) - return false; - return true; -} - -void StringStatic::postRun() -{ - for (auto const & pVarDecl : excludeVars) { - potentialVars.erase(pVarDecl); - } - for (auto const & varDecl : potentialVars) { - report(DiagnosticsEngine::Warning, - "rather declare this using OUStringLiteral/OStringLiteral/char[]", - varDecl->getLocation()) - << varDecl->getSourceRange(); - } -} - bool StringStatic::VisitVarDecl(VarDecl const* varDecl) { if (ignoreLocation(varDecl)) return true; QualType qt = varDecl->getType(); if (!varDecl->isThisDeclarationADefinition() - || !qt.isConstQualified()) + || !qt.isConstQualified() || varDecl->isConstexpr()) return true; if (varDecl->hasGlobalStorage()) { - if (varDecl->hasGlobalStorage() && !varDecl->isStaticLocal()) { - //TODO: For a non-public static member variable from an included file, we could still - // examine it further if all its uses must be seen in that included file: - if (!compiler.getSourceManager().isInMainFile(varDecl->getLocation())) { - return true; - } - } if (qt->isArrayType()) qt = qt->getAsArrayTypeUnsafe()->getElementType(); @@ -154,91 +101,14 @@ bool StringStatic::VisitVarDecl(VarDecl const* varDecl) return true; } } - potentialVars.insert(varDecl); + report(DiagnosticsEngine::Warning, + "rather declare this as constexpr", + varDecl->getLocation()) + << varDecl->getSourceRange(); return true; } -bool StringStatic::VisitReturnStmt(ReturnStmt const * returnStmt) -{ - if (ignoreLocation(returnStmt)) { - return true; - } - if (!returnStmt->getRetValue()) { - return true; - } - DeclRefExpr const * declRef = dyn_cast<DeclRefExpr>(returnStmt->getRetValue()); - if (!declRef) { - return true; - } - VarDecl const * varDecl = dyn_cast<VarDecl>(declRef->getDecl()); - if (varDecl) { - excludeVars.insert(varDecl); - } - return true; -} - -bool StringStatic::VisitDeclRefExpr(DeclRefExpr const * declRef) -{ - if (ignoreLocation(declRef)) - return true; - VarDecl const * varDecl = dyn_cast<VarDecl>(declRef->getDecl()); - if (!varDecl) - return true; - if (potentialVars.count(varDecl) == 0) - return true; - // ignore globals that are used in CPPUNIT_ASSERT expressions, otherwise we can end up - // trying to compare an OUStringLiteral and an OUString, and CPPUNIT can't handle that - auto loc = declRef->getBeginLoc(); - if (compiler.getSourceManager().isMacroArgExpansion(loc)) - { - StringRef name { Lexer::getImmediateMacroName(loc, compiler.getSourceManager(), compiler.getLangOpts()) }; - if (name.startswith("CPPUNIT_ASSERT")) - excludeVars.insert(varDecl); - } - return true; -} - -bool StringStatic::VisitMemberExpr(MemberExpr const * expr) -{ - if (ignoreLocation(expr)) - return true; - auto const declRef = dyn_cast<DeclRefExpr>(expr->getBase()); - if (declRef == nullptr) { - return true; - } - VarDecl const * varDecl = dyn_cast<VarDecl>(declRef->getDecl()); - if (!varDecl) - return true; - if (potentialVars.count(varDecl) == 0) - return true; - auto const id = expr->getMemberDecl()->getIdentifier(); - if (id == nullptr || id->getName() != "pData") { - return true; - } - excludeVars.insert(varDecl); - return true; -} - -bool StringStatic::VisitUnaryOperator(UnaryOperator const * expr) -{ - if (ignoreLocation(expr)) - return true; - if (expr->getOpcode() != UO_AddrOf) - return true; - if (this->ignoreLocation(expr)) - return true; - auto const dre = dyn_cast<DeclRefExpr>( - expr->getSubExpr()->IgnoreParenImpCasts()); - if (!dre) - return true; - auto const vd = dyn_cast<VarDecl>(dre->getDecl()); - if (!vd) - return true; - excludeVars.insert(vd->getCanonicalDecl()); - return true; -} - loplugin::Plugin::Registration<StringStatic> stringstatic("stringstatic"); } // namespace diff --git a/compilerplugins/clang/test/stringstatic.cxx b/compilerplugins/clang/test/stringstatic.cxx index bfe92b69f598..7e2089a17da7 100644 --- a/compilerplugins/clang/test/stringstatic.cxx +++ b/compilerplugins/clang/test/stringstatic.cxx @@ -9,22 +9,21 @@ #include <rtl/ustring.hxx> -#include "stringstatic.hxx" - -// expected-error@+1 {{rather declare this using OUStringLiteral/OStringLiteral/char[] [loplugin:stringstatic]}} +// expected-error@+1 {{rather declare this as constexpr [loplugin:stringstatic]}} static const OUString TEST1 = "xxx"; - -void f(rtl_uString const*); -void f(const OUString&); +static constexpr OUString TEST2 = u"xxx"_ustr; void test2() { - // expected-error@+1 {{rather declare this using OUStringLiteral/OStringLiteral/char[] [loplugin:stringstatic]}} + (void)TEST2; + // expected-error@+1 {{rather declare this as constexpr [loplugin:stringstatic]}} static const OUString XXX = "xxx"; - // expected-error@+1 {{rather declare this using OUStringLiteral/OStringLiteral/char[] [loplugin:stringstatic]}} - static const OUString XXX2 = "xxx"; + static constexpr OUString XXX2 = u"xxx"_ustr; (void)XXX; (void)XXX2; - static const OUString DATA = "xxx"; - f(DATA.pData); + // expected-error@+1 {{rather declare this as constexpr [loplugin:stringstatic]}} + static const OUString A1[1] = { u"xxx"_ustr }; + static constexpr OUString A2[1] = { u"xxx"_ustr }; + (void)A1; + (void)A2; } diff --git a/compilerplugins/clang/test/stringstatic.hxx b/compilerplugins/clang/test/stringstatic.hxx deleted file mode 100644 index ec82a8bf5deb..000000000000 --- a/compilerplugins/clang/test/stringstatic.hxx +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- 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 "rtl/ustring.hxx" - -OUString const INCLUDED = "xxx"; - -inline void f() -{ - // expected-error@+1 {{rather declare this using OUStringLiteral/OStringLiteral/char[] [loplugin:stringstatic]}} - static OUString const XXX = "xxx"; - (void)XXX; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/commontools/filtermanager.cxx b/connectivity/source/commontools/filtermanager.cxx index cd31489d6067..0a6ac9018fd6 100644 --- a/connectivity/source/commontools/filtermanager.cxx +++ b/connectivity/source/commontools/filtermanager.cxx @@ -74,7 +74,7 @@ namespace dbtools } assert(false); - static const OUString sErr("#FilterManager::getFilterComponent unknown component#"); + static constexpr OUString sErr(u"#FilterManager::getFilterComponent unknown component#"_ustr); return sErr; } diff --git a/connectivity/source/commontools/sqlerror.cxx b/connectivity/source/commontools/sqlerror.cxx index 28565fb46884..50c5968cd7d6 100644 --- a/connectivity/source/commontools/sqlerror.cxx +++ b/connectivity/source/commontools/sqlerror.cxx @@ -79,7 +79,7 @@ namespace connectivity const OUString& SQLError_Impl::getMessagePrefix() { - static const OUString s_sMessagePrefix( "[OOoBase]" ); + static constexpr OUString s_sMessagePrefix( u"[OOoBase]"_ustr ); return s_sMessagePrefix; } diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 089580cdae49..489fa2216bac 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -1741,7 +1741,7 @@ IMPL_LINK_NOARG(OfaLanguagesTabPage, LocaleSettingHdl, weld::ComboBox&, void) const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( (eLang == LANGUAGE_USER_SYSTEM_CONFIG) ? MsLangId::getConfiguredSystemLanguage() : eLang); - const OUString aDefaultID = "default"; + constexpr OUString aDefaultID = u"default"_ustr; // Update the "Default ..." currency. m_xCurrencyLB->remove_id(aDefaultID); OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol(); diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 12099ea0a719..b5320f90e448 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -1767,7 +1767,7 @@ void Test::testTransliterate() CPPUNIT_ASSERT_EQUAL(OUString("One (Two) Three"), editEng.GetText()); using TF = TransliterationFlags; - const OUString sText2 = "Mary Jones met joe Smith. Time Passed."; + constexpr OUString sText2 = u"Mary Jones met joe Smith. Time Passed."_ustr; int selStart = 12; int selEnd = 12; ESelection esel(0, selStart, 0, selEnd); @@ -1870,7 +1870,7 @@ void Test::testTransliterate() selStart = 0; selEnd = 19; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText3("CURRENT IS EQUAL TO 10 A"); + constexpr OUString sText3(u"CURRENT IS EQUAL TO 10 A"_ustr); editEng.SetText(sText3); CPPUNIT_ASSERT_EQUAL(OUString("CURRENT IS EQUAL TO"), editEng.GetText(esel)); @@ -1898,7 +1898,7 @@ void Test::testTdf148148() int selStart = 0; int selEnd = 3; ESelection esel(0, selStart, 0, selEnd); - const OUString sText1(" text"); + constexpr OUString sText1(u" text"_ustr); editEng.SetText(sText1); CPPUNIT_ASSERT_EQUAL(OUString(" "), editEng.GetText(esel)); @@ -1910,7 +1910,7 @@ void Test::testTdf148148() selStart = 4; selEnd = 8; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText2("text "); + constexpr OUString sText2(u"text "_ustr); editEng.SetText(sText2); CPPUNIT_ASSERT_EQUAL(OUString(" "), editEng.GetText(esel)); @@ -1923,7 +1923,7 @@ void Test::testTdf148148() selStart = 0; selEnd = 3; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText3(" -1"); + constexpr OUString sText3(u" -1"_ustr); editEng.SetText(sText3); CPPUNIT_ASSERT_EQUAL(OUString(" "), editEng.GetText(esel)); @@ -1935,7 +1935,7 @@ void Test::testTdf148148() selStart = 2; selEnd = 6; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText4("-1 "); + constexpr OUString sText4(u"-1 "_ustr); editEng.SetText(sText4); CPPUNIT_ASSERT_EQUAL(OUString(" "), editEng.GetText(esel)); @@ -1948,7 +1948,7 @@ void Test::testTdf148148() selStart = 0; selEnd = 5; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText5(" -1"); + constexpr OUString sText5(u" -1"_ustr); editEng.SetText(sText3); CPPUNIT_ASSERT_EQUAL(OUString(" -1"), editEng.GetText(esel)); @@ -1960,7 +1960,7 @@ void Test::testTdf148148() selStart = 0; selEnd = 5; esel = ESelection(0, selStart, 0, selEnd); - const OUString sText6("-1 "); + constexpr OUString sText6(u"-1 "_ustr); editEng.SetText(sText4); CPPUNIT_ASSERT_EQUAL(OUString("-1 "), editEng.GetText(esel)); diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 18f4be09c86f..9edadaaf4755 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -334,7 +334,7 @@ void TestBreakIterator::testWordBoundaries() //See https://bz.apache.org/ooo/show_bug.cgi?id=13494 { - const OUString aBase("xxAAxxBBxxCCxx"); + constexpr OUString aBase(u"xxAAxxBBxxCCxx"_ustr); const sal_Unicode aTests[] = { '\'', ';', ',', '.', '!', '@', '#', '%', '&', '*', diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx index 51656e7d37d2..08fccf50316d 100644 --- a/sal/osl/all/debugbase.cxx +++ b/sal/osl/all/debugbase.cxx @@ -35,9 +35,9 @@ const std::vector<OString>& StaticDebugBaseAddressFilter() { std::vector<OString> vec; rtl_uString * pStr = nullptr; - OUString const name( - "OSL_DEBUGBASE_STORE_ADDRESSES" ); - if (osl_getEnvironment( name.pData, &pStr ) == osl_Process_E_None) { + if (osl_getEnvironment( u"OSL_DEBUGBASE_STORE_ADDRESSES"_ustr.pData, &pStr ) + == osl_Process_E_None) + { OUString const str(pStr); rtl_uString_release(pStr); sal_Int32 nIndex = 0; diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index e2d3d125b0ab..0e3f3e6d8e20 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -247,10 +247,8 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv) /* see @ osl_getExecutableFile(). */ if (rtl_ustr_indexOfChar (rtl_uString_getStr(ppArgs[0]), '/') == -1) { - const OUString PATH ("PATH"); - rtl_uString * pSearchPath = nullptr; - osl_getEnvironment (PATH.pData, &pSearchPath); + osl_getEnvironment (u"PATH"_ustr.pData, &pSearchPath); if (pSearchPath) { rtl_uString * pSearchResult = nullptr; diff --git a/sal/qa/osl/socket.cxx b/sal/qa/osl/socket.cxx index ed31c9ede7ae..4598754a2214 100644 --- a/sal/qa/osl/socket.cxx +++ b/sal/qa/osl/socket.cxx @@ -25,7 +25,7 @@ class SocketTest : public CppUnit::TestFixture void test_createInetSocketAddr() { - OUString const in("123.4.56.78"); + OUString constexpr in(u"123.4.56.78"_ustr); auto const addr = osl_createInetSocketAddr(in.pData, 100); CPPUNIT_ASSERT(addr != nullptr); CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, osl_getFamilyOfSocketAddr(addr)); @@ -39,8 +39,7 @@ class SocketTest : public CppUnit::TestFixture void test_createInetBroadcastAddr() { - OUString const in("123.4.56.78"); - auto const addr = osl_createInetBroadcastAddr(in.pData, 100); + auto const addr = osl_createInetBroadcastAddr(u"123.4.56.78"_ustr.pData, 100); CPPUNIT_ASSERT(addr != nullptr); CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, osl_getFamilyOfSocketAddr(addr)); OUString out; diff --git a/sal/qa/rtl/strings/test_ostring.cxx b/sal/qa/rtl/strings/test_ostring.cxx index b4fb201cafa3..f0a82a712254 100644 --- a/sal/qa/rtl/strings/test_ostring.cxx +++ b/sal/qa/rtl/strings/test_ostring.cxx @@ -109,7 +109,7 @@ void Test::testCompareTo() void Test::testUtf8StringLiterals() { - const OString sIn(u8"ßa"); + OString sIn(u8"ßa"); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), sIn.getLength()); CPPUNIT_ASSERT_EQUAL(195, int(static_cast<unsigned char>(sIn[0]))); CPPUNIT_ASSERT_EQUAL(159, int(static_cast<unsigned char>(sIn[1]))); diff --git a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx index 591688b31c3c..3e7c5f971599 100644 --- a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx +++ b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx @@ -52,7 +52,7 @@ class Test : public CppUnit::TestFixture OUString("foo").startsWithIgnoreAsciiCase(std::u16string_view())); CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWith(std::u16string_view())); CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWithIgnoreAsciiCase(std::u16string_view())); - OUString const foo("foo"); // avoid loplugin:stringconstant, loplugin:stringview + OUString constexpr foo(u"foo"_ustr); // avoid loplugin:stringconstant, loplugin:stringview CPPUNIT_ASSERT_EQUAL(false, foo == std::u16string_view()); CPPUNIT_ASSERT_EQUAL(true, foo != std::u16string_view()); CPPUNIT_ASSERT_EQUAL(false, foo < std::u16string_view()); diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index 60b9f9fb1c0f..5f5132c299c2 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -343,7 +343,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testTdf99856_dataValidationTest) CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF16LErtlSHA1) { - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); createScDoc("fods/protection-key1.fods"); @@ -369,7 +369,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF16LErtlSHA1) CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA1) { - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); createScDoc("fods/protection-key2.fods"); @@ -395,7 +395,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA1) CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA256ODF12) { - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); createScDoc("fods/protection-key3.fods"); @@ -423,7 +423,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA256ODF12) CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA256W3C) { - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); createScDoc("fods/protection-key4.fods"); @@ -451,7 +451,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_UTF8SHA256W3C) CPPUNIT_TEST_FIXTURE(ScExportTest, testProtectionKeyODS_XL_SHA1) { - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); createScDoc("fods/protection-key5.fods"); diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 49ef48e80e37..90129e4bbf13 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -1030,7 +1030,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf112567) CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf75702) { // The problem was that line breaks were not imported. - const OUString sA1("line1\nline2"); + constexpr OUString sA1(u"line1\nline2"_ustr); createScDoc("ods/tdf75702_textLineBreak.ods"); ScDocument* pDoc = getScDoc(); @@ -1049,8 +1049,8 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf103829) { // The problem was that tabspaces were not imported or exported at all. // These strings match the current implementations of CELLTYPE_EDIT and CELLTYPE_STRING. - const OUString sA1("\x001Leading tab\nTHREE tabs inside: [\x001\x001\x001]"); - const OUString sA2("\tLeading tab. THREE tabs inside: [\t\t\t]"); + constexpr OUString sA1(u"\x001Leading tab\nTHREE tabs inside: [\x001\x001\x001]"_ustr); + constexpr OUString sA2(u"\tLeading tab. THREE tabs inside: [\t\t\t]"_ustr); createScDoc("ods/tdf103829_textTab.ods"); ScDocument* pDoc = getScDoc(); diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 77750a206622..b611ceb5ba6f 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -461,7 +461,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf154445_unused_pagestyles) createScDoc("ods/tdf108188_pagestyle.ods"); // Check if the user defined page style is present - const OUString aTestPageStyle = "TestPageStyle"; + constexpr OUString aTestPageStyle = u"TestPageStyle"_ustr; ScDocument* pDoc = getScDoc(); CPPUNIT_ASSERT_EQUAL(aTestPageStyle, pDoc->GetPageStyle(0)); diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx index 19563674501e..87e00ac7f3f0 100644 --- a/sc/qa/unit/subsequent_filters_test.cxx +++ b/sc/qa/unit/subsequent_filters_test.cxx @@ -535,14 +535,13 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest, testBooleanFormatXLSX) ScDocument* pDoc = getScDoc(); SvNumberFormatter* pNumFormatter = pDoc->GetFormatTable(); // Saved as >"TRUE";"TRUE";"FALSE"< but reading converted back to >BOOLEAN< - const OUString aBooleanTypeStr = "BOOLEAN"; for (SCROW i = 0; i <= 1; i++) { sal_uInt32 nNumberFormat = pDoc->GetNumberFormat(0, i, 0); const SvNumberformat* pNumberFormat = pNumFormatter->GetEntry(nNumberFormat); const OUString& rFormatStr = pNumberFormat->GetFormatstring(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Number format != boolean", aBooleanTypeStr, rFormatStr); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Number format != boolean", u"BOOLEAN"_ustr, rFormatStr); } } diff --git a/sc/qa/unit/subsequent_filters_test3.cxx b/sc/qa/unit/subsequent_filters_test3.cxx index a88cc136d870..0c2ec7864de2 100644 --- a/sc/qa/unit/subsequent_filters_test3.cxx +++ b/sc/qa/unit/subsequent_filters_test3.cxx @@ -1776,7 +1776,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf108188_pagestyle) createScDoc("ods/tdf108188_pagestyle.ods"); // Check if the user defined page style is present - const OUString aTestPageStyle = "TestPageStyle"; + constexpr OUString aTestPageStyle = u"TestPageStyle"_ustr; ScDocument* pDoc = getScDoc(); CPPUNIT_ASSERT_EQUAL(aTestPageStyle, pDoc->GetPageStyle(0)); diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index ab25340e8c3e..d1f7152793c6 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1504,7 +1504,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLanguageStatus) const SfxStringItem* pItem2 = dynamic_cast<const SfxStringItem*>(xItem2.get()); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT(pItem2); - const OUString aLangBolivia("Spanish (Bolivia);es-BO"); + constexpr OUString aLangBolivia(u"Spanish (Bolivia);es-BO"_ustr); CPPUNIT_ASSERT_EQUAL(aLangBolivia, pItem1->GetValue()); CPPUNIT_ASSERT_EQUAL(aLangBolivia, pItem2->GetValue()); } diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index 575cfb90f9f7..603238dbf1ae 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -259,7 +259,7 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPaste) ScRangeData* pLocal5 = new ScRangeData(*m_pDoc, "local5", "$A$1"); // implicit relative sheet reference ScRangeData* pGlobal = new ScRangeData(*m_pDoc, "global", aAdr); - const OUString aGlobal2Symbol("$Sheet1.$A$1:$A$23"); + constexpr OUString aGlobal2Symbol(u"$Sheet1.$A$1:$A$23"_ustr); ScRangeData* pGlobal2 = new ScRangeData(*m_pDoc, "global2", aGlobal2Symbol); std::unique_ptr<ScRangeName> pGlobalRangeName(new ScRangeName()); pGlobalRangeName->insert(pGlobal); @@ -10046,7 +10046,7 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteFormulasExternalDoc) m_xDocShell->DoLoad(pMedium); ScDocShellRef xExtDocSh = new ScDocShell; - OUString const aExtDocName("file:///extdata.fake"); + OUString constexpr aExtDocName(u"file:///extdata.fake"_ustr); SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE); xExtDocSh->DoLoad(pMed); CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.", diff --git a/sc/qa/unit/ucalc_formula2.cxx b/sc/qa/unit/ucalc_formula2.cxx index c2f9894cdafa..e6606f126d8e 100644 --- a/sc/qa/unit/ucalc_formula2.cxx +++ b/sc/qa/unit/ucalc_formula2.cxx @@ -1558,8 +1558,8 @@ CPPUNIT_TEST_FIXTURE(TestFormula2, testExternalRef) rExtDoc.InsertTab(1, aExtSh2Name); rExtDoc.InsertTab(2, aExtSh3Name); - OUString const name("Name"); - OUString const value("Value"); + OUString constexpr name(u"Name"_ustr); + OUString constexpr value(u"Value"_ustr); // Sheet 1 rExtDoc.SetString(0, 0, 0, name); @@ -1600,7 +1600,7 @@ CPPUNIT_TEST_FIXTURE(TestFormula2, testExternalRef) m_pDoc->InsertTab(0, "Test Sheet"); m_pDoc->SetString(0, 0, 0, "='file:///extdata.fake'#Data1.A1"); OUString test = m_pDoc->GetString(0, 0, 0); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Value is different from the original", test, name); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value is different from the original", name, test); // After the initial access to the external document, the external ref // manager should create sheet cache entries for *all* sheets from that @@ -1617,7 +1617,7 @@ CPPUNIT_TEST_FIXTURE(TestFormula2, testExternalRef) m_pDoc->SetString(1, 0, 0, "='file:///extdata.fake'#Data1.B1"); test = m_pDoc->GetString(1, 0, 0); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Value is different from the original", test, value); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value is different from the original", value, test); m_pDoc->SetString(0, 1, 0, "='file:///extdata.fake'#Data1.A2"); m_pDoc->SetString(0, 2, 0, "='file:///extdata.fake'#Data1.A3"); @@ -1717,7 +1717,7 @@ CPPUNIT_TEST_FIXTURE(TestFormula2, testExternalRef) CPPUNIT_TEST_FIXTURE(TestFormula2, testExternalRangeName) { ScDocShellRef xExtDocSh = new ScDocShell; - OUString const aExtDocName("file:///extdata.fake"); + OUString constexpr aExtDocName(u"file:///extdata.fake"_ustr); SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE); xExtDocSh->DoLoad(pMed); CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.", @@ -3514,8 +3514,8 @@ CPPUNIT_TEST_FIXTURE(TestFormula2, testFormulaErrorPropagation) ScMarkData aMark(m_pDoc->GetSheetLimits()); aMark.SelectOneTable(0); ScAddress aPos, aPos2; - const OUString aTRUE("TRUE"); - const OUString aFALSE("FALSE"); + constexpr OUString aTRUE(u"TRUE"_ustr); + constexpr OUString aFALSE(u"FALSE"_ustr); aPos.Set(0, 0, 0); // A1 m_pDoc->SetValue(aPos, 1.0); diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx index d90e3bb3d3e2..1eaeb5cac4e3 100644 --- a/sc/qa/unit/uicalc/uicalc2.cxx +++ b/sc/qa/unit/uicalc/uicalc2.cxx @@ -286,7 +286,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf124816) // The actual result is completely unrelated to this test and behaviour of // OFFSET() was changed as of tdf#85551 and here result of that test // document is now Err:502 instead of 0. - const OUString aExpectedResult("Err:502"); + constexpr OUString aExpectedResult(u"Err:502"_ustr); lcl_AssertCurrentCursorPosition(*pDocSh, u"D10"); CPPUNIT_ASSERT_EQUAL(aExpectedResult, pDoc->GetString(ScAddress(3, 9, 0))); diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index da0eadbe3309..8ea94c434283 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3235,7 +3235,7 @@ bool ScCompiler::ParsePredetectedReference( const OUString& rName ) // It could also be a broken invalidated reference that contains #REF! // (but is not equal to), which we wrote prior to ODFF and also to ODFF // between 2013 and 2016 until 5.1.4 - const OUString aErrRef("#REF!"); // not localized in ODFF + constexpr OUString aErrRef(u"#REF!"_ustr); // not localized in ODFF sal_Int32 nPos = rName.indexOf( aErrRef); if (nPos != -1) { diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx index 5c219e3c3d3a..94ac690c131a 100644 --- a/sc/source/filter/ftools/ftools.cxx +++ b/sc/source/filter/ftools/ftools.cxx @@ -284,26 +284,26 @@ void ScfTools::AppendCString( SvStream& rStrm, OUString& rString, rtl_TextEncodi const OUString& ScfTools::GetHTMLDocName() { - static const OUString saHTMLDoc( "HTML_all" ); + static constexpr OUString saHTMLDoc( u"HTML_all"_ustr ); return saHTMLDoc; } const OUString& ScfTools::GetHTMLTablesName() { - static const OUString saHTMLTables( "HTML_tables" ); + static constexpr OUString saHTMLTables( u"HTML_tables"_ustr ); return saHTMLTables; } const OUString& ScfTools::GetHTMLIndexPrefix() { - static const OUString saHTMLIndexPrefix( "HTML_" ); + static constexpr OUString saHTMLIndexPrefix( u"HTML_"_ustr ); return saHTMLIndexPrefix; } const OUString& ScfTools::GetHTMLNamePrefix() { - static const OUString saHTMLNamePrefix( "HTML__" ); + static constexpr OUString saHTMLNamePrefix( u"HTML__"_ustr ); return saHTMLNamePrefix; } diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index c075d54d7ca4..625c04953006 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -727,8 +727,6 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testPresetShapesExport) save("Impress Office Open XML"); xmlDocUniquePtr pXmlDocCT = parseExport("ppt/slides/slide1.xml"); - const OString sPattern( - "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom[@prst='_T_']/a:avLst/a:gd[_N_]"); static constexpr OStringLiteral sT("_T_"); static constexpr OStringLiteral sN("_N_"); static constexpr OStringLiteral sPropertyName("name"); @@ -742,7 +740,10 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testPresetShapesExport) && o3tl::starts_with(sShapeTypeAndValues[i], "adj"); ++j) { - OString sXPath = sPattern.replaceFirst(sT, sType).replaceFirst(sN, OString::number(j)); + OString sXPath + = "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom[@prst='_T_']/a:avLst/a:gd[_N_]"_ostr + .replaceFirst(sT, sType) + .replaceFirst(sN, OString::number(j)); assertXPath(pXmlDocCT, sXPath, sPropertyName, OUString::createFromAscii(sShapeTypeAndValues[i++])); assertXPath(pXmlDocCT, sXPath, sPropertyFmla, diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 92971d4b4221..9d9ba03f14a9 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -736,7 +736,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT) // Check if the graphic has been imported correctly (before doing the export/import run) { - const OString sFailedImportMessage = "Failed to correctly import the document"; + constexpr OString sFailedImportMessage = "Failed to correctly import the document"_ostr; SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pXImpressDocument); diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx index 94cc2b24327d..a27e92e28931 100644 --- a/sdext/source/pdfimport/inc/wrapper.hxx +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -53,39 +53,39 @@ namespace pdfi css::uno::XComponentContext >& xContext, const OUString& rFilterOptions ); - const OUString fontAttributesSuffixes[] = { + constexpr OUString fontAttributesSuffixes[] = { // Note: for performance consideration, each one listed here is evaluated once, // and they are checked from the suffix, thus the order matters. // e.g. for "TimesNewRomanPS-BoldItalic", to get "TimesNewRoman", you should // first have "Italic", and then "Bold", then "-", and then "PS". - "-VKana", - "MT", - "PS", - "PSMT", - "Regular", - "Normal", - "Book", - "Medium", - "ExtraBold", - "UltraBold", - "ExtraLight", - "UltraLight", - "Bold", - "Heavy", - "Black", - "Italic", - "Oblique", - "Bold", //BoldItalic, BoldOblique - "Light", - "Thin", - "Semibold", - "-Roman", - "Reg", - "VKana", - "-", - ",", - ";", - "PS", // e.g. TimesNewRomanPS-BoldMT + u"-VKana"_ustr, + u"MT"_ustr, + u"PS"_ustr, + u"PSMT"_ustr, + u"Regular"_ustr, + u"Normal"_ustr, + u"Book"_ustr, + u"Medium"_ustr, + u"ExtraBold"_ustr, + u"UltraBold"_ustr, + u"ExtraLight"_ustr, + u"UltraLight"_ustr, + u"Bold"_ustr, + u"Heavy"_ustr, + u"Black"_ustr, + u"Italic"_ustr, + u"Oblique"_ustr, + u"Bold"_ustr, //BoldItalic, BoldOblique + u"Light"_ustr, + u"Thin"_ustr, + u"Semibold"_ustr, + u"-Roman"_ustr, + u"Reg"_ustr, + u"VKana"_ustr, + u"-"_ustr, + u","_ustr, + u";"_ustr, + u"PS"_ustr, // e.g. TimesNewRomanPS-BoldMT }; } diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 3ec824a4b034..e9556e88c19e 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -52,43 +52,43 @@ namespace const OUString& PROP_BACNAME() { - static const OUString sProp("BusinessAuthorizationCategory:Name"); + static constexpr OUString sProp(u"BusinessAuthorizationCategory:Name"_ustr); return sProp; } const OUString& PROP_STARTVALIDITY() { - static const OUString sProp("Authorization:StartValidity"); + static constexpr OUString sProp(u"Authorization:StartValidity"_ustr); return sProp; } const OUString& PROP_NONE() { - static const OUString sProp("None"); + static constexpr OUString sProp(u"None"_ustr); return sProp; } const OUString& PROP_IMPACTSCALE() { - static const OUString sProp("Impact:Scale"); + static constexpr OUString sProp(u"Impact:Scale"_ustr); return sProp; } const OUString& PROP_IMPACTLEVEL() { - static const OUString sProp("Impact:Level:Confidentiality"); + static constexpr OUString sProp(u"Impact:Level:Confidentiality"_ustr); return sProp; } const OUString& PROP_PREFIX_EXPORTCONTROL() { - static const OUString sProp("urn:bails:ExportControl:"); + static constexpr OUString sProp(u"urn:bails:ExportControl:"_ustr); return sProp; } const OUString& PROP_PREFIX_NATIONALSECURITY() { - static const OUString sProp("urn:bails:NationalSecurity:"); + static constexpr OUString sProp(u"urn:bails:NationalSecurity:"_ustr); return sProp; } @@ -917,25 +917,25 @@ const OUString& SfxClassificationHelper::policyTypeToString(SfxClassificationPol const OUString& SfxClassificationHelper::PROP_DOCHEADER() { - static const OUString sProp("Marking:document-header"); + static constexpr OUString sProp(u"Marking:document-header"_ustr); return sProp; } const OUString& SfxClassificationHelper::PROP_DOCFOOTER() { - static const OUString sProp("Marking:document-footer"); + static constexpr OUString sProp(u"Marking:document-footer"_ustr); return sProp; } const OUString& SfxClassificationHelper::PROP_DOCWATERMARK() { - static const OUString sProp("Marking:document-watermark"); + static constexpr OUString sProp(u"Marking:document-watermark"_ustr); return sProp; } const OUString& SfxClassificationHelper::PROP_PREFIX_INTELLECTUALPROPERTY() { - static const OUString sProp("urn:bails:IntellectualProperty:"); + static constexpr OUString sProp(u"urn:bails:IntellectualProperty:"_ustr); return sProp; } diff --git a/svl/qa/unit/test_lngmisc.cxx b/svl/qa/unit/test_lngmisc.cxx index 19efdd74a10c..2e82deac6339 100644 --- a/svl/qa/unit/test_lngmisc.cxx +++ b/svl/qa/unit/test_lngmisc.cxx @@ -134,7 +134,7 @@ void LngMiscTest::testReplaceControlChars() void LngMiscTest::testGetThesaurusReplaceText() { - const OUString str2("asdf"); + constexpr OUString str2(u"asdf"_ustr); OUString r = linguistic::GetThesaurusReplaceText(""); CPPUNIT_ASSERT(r.isEmpty()); diff --git a/svx/qa/unit/gallery/test_gallery.cxx b/svx/qa/unit/gallery/test_gallery.cxx index fc3a89c50771..0919a09503eb 100644 --- a/svx/qa/unit/gallery/test_gallery.cxx +++ b/svx/qa/unit/gallery/test_gallery.cxx @@ -166,7 +166,7 @@ void GalleryObjTest::TestThemeURLCase() CPPUNIT_ASSERT_MESSAGE("Could not create gallery instance", (pGallery != nullptr)); // Mixed Case Theme Name - const OUString myThemeName = "AddyTestTheme"; + constexpr OUString myThemeName = u"AddyTestTheme"_ustr; CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName)); CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName)); @@ -243,7 +243,7 @@ void GalleryObjTest::TestGalleryThemeEntry() std::unique_ptr<Gallery> pGallery(new Gallery(aGalleryURL)); CPPUNIT_ASSERT_MESSAGE("Could not create gallery instance", (pGallery != nullptr)); - const OUString myThemeName = "addytesttheme"; + constexpr OUString myThemeName = u"addytesttheme"_ustr; CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName)); CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName)); @@ -251,8 +251,8 @@ void GalleryObjTest::TestGalleryThemeEntry() const GalleryThemeEntry* mpThemeEntry = pGallery->GetThemeInfo(myThemeName); // Check Theme Name - CPPUNIT_ASSERT_EQUAL_MESSAGE("Theme name doesn't match", mpThemeEntry->GetThemeName(), - myThemeName); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Theme name doesn't match", myThemeName, + mpThemeEntry->GetThemeName()); // Check URLs GalleryStorageLocations& rGalleryStorageLocations = mpThemeEntry->getGalleryStorageLocations(); @@ -458,7 +458,7 @@ void GalleryObjTest::TestGetThemeNameFromGalleryTheme() std::unique_ptr<Gallery> pGallery(new Gallery(aGalleryURL)); CPPUNIT_ASSERT_MESSAGE("Could not create gallery instance", (pGallery != nullptr)); - const OUString myThemeName = "addytesttheme"; + constexpr OUString myThemeName = u"addytesttheme"_ustr; CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName)); CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName)); diff --git a/sw/qa/core/test_ToxWhitespaceStripper.cxx b/sw/qa/core/test_ToxWhitespaceStripper.cxx index 14ebc6ac2e14..f3c2de946773 100644 --- a/sw/qa/core/test_ToxWhitespaceStripper.cxx +++ b/sw/qa/core/test_ToxWhitespaceStripper.cxx @@ -113,7 +113,7 @@ void ToxWhitespaceStripperTest::StrippingWhitespacesFromVariousStringsWorks() void ToxWhitespaceStripperTest::PositionAfterStringCanBeRequested() { - OUString const test("abc"); + OUString constexpr test(u"abc"_ustr); ToxWhitespaceStripper sut(test); sal_Int32 expected = test.getLength(); CPPUNIT_ASSERT_EQUAL(expected, sut.GetPositionInStrippedString(test.getLength())); diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 6810baa1efe3..be3c67fb0bba 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -1115,7 +1115,7 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testFieldShadeReqIf) DECLARE_HTMLEXPORT_TEST(testTdf126879, "tdf126879.odt") { - const OString aExpected("<!DOCTYPE html>"); + constexpr OString aExpected("<!DOCTYPE html>"_ostr); SvStream* pStream = maTempFile.GetStream(StreamMode::READ); CPPUNIT_ASSERT(pStream); const OString aActual(read_uInt8s_ToOString(*pStream, aExpected.getLength())); diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index f2ce8f149306..3bb0e585f6fc 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1196,7 +1196,7 @@ DECLARE_ODFEXPORT_TEST(testCharacterBorder, "charborder.odt") CPPUNIT_TEST_FIXTURE(Test, testProtectionKey) { loadAndReload("protection-key.fodt"); - OUString const password("1012345678901234567890123456789012345678901234567890"); + OUString constexpr password(u"1012345678901234567890123456789012345678901234567890"_ustr); // check 1 invalid OOo legacy password and 3 valid ODF 1.2 passwords uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 402c2ddcc04a..c0dea13f2075 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -1490,7 +1490,7 @@ DECLARE_OOXMLEXPORT_TEST(testActiveXOptionButtonGroup, "activex_option_button_gr { // Optionbutton groups were not handled // The two optionbutton should have the same group name - const OUString sGroupName = "GroupX"; + constexpr OUString sGroupName = u"GroupX"_ustr; uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xControlShape.is()); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index d3877d94c0cc..d62a46aa3671 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1568,7 +1568,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testToxmarkLinks) // click on the links... { - OUString const tmp("Table of Contents"); + OUString constexpr tmp(u"Table of Contents"_ustr); pWrtShell->GotoNextTOXBase(&tmp); } @@ -1603,7 +1603,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testToxmarkLinks) } { - OUString const tmp("User-Defined1"); + OUString constexpr tmp(u"User-Defined1"_ustr); pWrtShell->GotoNextTOXBase(&tmp); } @@ -1653,7 +1653,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testToxmarkLinks) } { - OUString const tmp("NewUD!|1"); + OUString constexpr tmp(u"NewUD!|1"_ustr); pWrtShell->GotoNextTOXBase(&tmp); } diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index d5acadd55569..2865378fa998 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -663,7 +663,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testBookmarkCollapsed) // load only content.xml from the resaved document xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - const OString aPath("/office:document-content/office:body/office:text/text:p"); + constexpr OString aPath("/office:document-content/office:body/office:text/text:p"_ostr); const int pos1 = getXPathPosition(pXmlDoc, aPath, "bookmark"); CPPUNIT_ASSERT_EQUAL(0, pos1); // found, and it is first @@ -736,7 +736,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testRemoveBookmarkText) // load only content.xml from the resaved document xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - const OString aPath("/office:document-content/office:body/office:text/text:p"); + constexpr OString aPath("/office:document-content/office:body/office:text/text:p"_ostr); CPPUNIT_ASSERT_ASSERTION_FAIL(getXPathPosition(pXmlDoc, aPath, "bookmark")); // not found const int pos2 = getXPathPosition(pXmlDoc, aPath, "bookmark-start"); @@ -838,7 +838,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testRemoveBookmarkTextAndAddNew) // load only content.xml from the resaved document xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - const OString aPath("/office:document-content/office:body/office:text/text:p"); + constexpr OString aPath("/office:document-content/office:body/office:text/text:p"_ostr); CPPUNIT_ASSERT_ASSERTION_FAIL(getXPathPosition(pXmlDoc, aPath, "bookmark")); // not found const int pos2 = getXPathPosition(pXmlDoc, aPath, "bookmark-start"); @@ -902,7 +902,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testRemoveBookmarkTextAndAddNewAfterReload // load only content.xml from the resaved document xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - const OString aPath("/office:document-content/office:body/office:text/text:p"); + constexpr OString aPath("/office:document-content/office:body/office:text/text:p"_ostr); const int pos1 = getXPathPosition(pXmlDoc, aPath, "bookmark"); const int pos2 = getXPathPosition(pXmlDoc, aPath, "text"); @@ -1319,7 +1319,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testRedlineViewAuthor) SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); pWrtShell->Insert("middle"); SwView* pView = pDocShell->GetView(); - const OUString aAuthor("A U. Thor"); + constexpr OUString aAuthor(u"A U. Thor"_ustr); pView->SetRedlineAuthor(aAuthor); pDocShell->SetView(pView); @@ -2141,7 +2141,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testCreateDocxAnnotation) createSwDoc(); // insert an annotation with a text - const OUString aSomeText("some text"); + constexpr OUString aSomeText(u"some text"_ustr); uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence({ { "Text", uno::Any(aSomeText) }, { "Author", uno::Any(OUString("me")) }, diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 74221022bd6d..ac5155f429a9 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -715,7 +715,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf113481) CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115013) { - const OUString sColumnName("Name with spaces, \"quotes\" and \\backslashes"); + constexpr OUString sColumnName(u"Name with spaces, \"quotes\" and \\backslashes"_ustr); utl::TempFileNamed aTempDir(nullptr, true); aTempDir.EnableKillingFile(); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 4cc4f8379b58..375371192ef6 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -729,7 +729,7 @@ SwNumRule* SwWW8ImplReader::GetStyRule() if( m_xStyles->mpStyRule ) // Bullet-Style already present return m_xStyles->mpStyRule; - const OUString aBaseName("WW8StyleNum"); + constexpr OUString aBaseName(u"WW8StyleNum"_ustr); const OUString aName( m_rDoc.GetUniqueNumRuleName( &aBaseName, false) ); // #i86652# @@ -811,7 +811,7 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor // If NumRuleItems were set, either directly or through inheritance, disable them now m_pCurrentColl->SetFormatAttr( SwNumRuleItem() ); - const OUString aName("Outline"); + constexpr OUString aName(u"Outline"_ustr); SwNumRule aNR( m_rDoc.GetUniqueNumRuleName( &aName ), SvxNumberFormat::LABEL_WIDTH_AND_POSITION, OUTLINE_RULE ); diff --git a/toolkit/source/helper/accessibilityclient.cxx b/toolkit/source/helper/accessibilityclient.cxx index 1926b004d15e..cad81b3a915e 100644 --- a/toolkit/source/helper/accessibilityclient.cxx +++ b/toolkit/source/helper/accessibilityclient.cxx @@ -187,13 +187,11 @@ namespace toolkit if (!s_pFactory) { #ifndef DISABLE_DYNLOADING - const OUString sModuleName( SVLIBRARY( "acc" ) ); - s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 ); + s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, u"" SVLIBRARY( "acc" ) ""_ustr.pData, 0 ); if ( s_hAccessibleImplementationModule != nullptr ) { - const OUString sFactoryCreationFunc("getStandardAccessibleFactory"); s_pAccessibleFactoryFunc = reinterpret_cast<GetStandardAccComponentFactory>( - osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData )); + osl_getFunctionSymbol( s_hAccessibleImplementationModule, u"getStandardAccessibleFactory"_ustr.pData )); } OSL_ENSURE( s_pAccessibleFactoryFunc, "AccessibilityClient::ensureInitialized: could not load the library, or not retrieve the needed symbol!" ); diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index 5febc25abbc9..f6103e24fa01 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -313,7 +313,7 @@ namespace void Test::test_write_unicode() { - const OUString write("abc"); + constexpr OUString write(u"abc"_ustr); utl::TempFileNamed aTempFile(u"test_write_unicode"); aTempFile.EnableKillingFile(); { diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 19b8cd52b7e7..269077ddb0ff 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1609,7 +1609,7 @@ const OUString& Application::GetDesktopEnvironment() { if (IsHeadlessModeEnabled()) { - static const OUString aNone("none"); + static constexpr OUString aNone(u"none"_ustr); return aNone; } else diff --git a/vcl/source/helper/svtaccessiblefactory.cxx b/vcl/source/helper/svtaccessiblefactory.cxx index 278c9552b61d..fa9e151fcc23 100644 --- a/vcl/source/helper/svtaccessiblefactory.cxx +++ b/vcl/source/helper/svtaccessiblefactory.cxx @@ -243,13 +243,11 @@ namespace vcl if (!s_pFactory) { #ifndef DISABLE_DYNLOADING - const OUString sModuleName( SVLIBRARY( "acc" )); - s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 ); + s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, u"" SVLIBRARY( "acc" ) ""_ustr.pData, 0 ); if ( s_hAccessibleImplementationModule != nullptr ) { - const OUString sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" ); s_pAccessibleFactoryFunc = reinterpret_cast<GetSvtAccessibilityComponentFactory>( - osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData )); + osl_getFunctionSymbol( s_hAccessibleImplementationModule, u"getSvtAccessibilityComponentFactory"_ustr.pData )); } OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" ); diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx index f9b0da12ce9c..ebfa0fbd7e16 100644 --- a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx @@ -63,9 +63,8 @@ OUString applicationDirPath() OUString findPickerExecutable() { const auto path = applicationDirPath(); - const OUString app("lo_kde5filepicker"); OUString ret; - osl_searchFileURL(app.pData, path.pData, &ret.pData); + osl_searchFileURL(u"lo_kde5filepicker"_ustr.pData, path.pData, &ret.pData); if (ret.isEmpty()) throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory), "could not find lo_kde5filepicker executable"); diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 5827da5673f5..f667213288bf 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -167,7 +167,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMimetype) uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponentContext->getServiceManager(), uno::UNO_QUERY); - const OUString aServiceName("com.sun.star.comp.Writer.EPUBExportFilter"); + constexpr OUString aServiceName(u"com.sun.star.comp.Writer.EPUBExportFilter"_ustr); uno::Reference<document::XFilter> xFilter(xMSF->createInstance(aServiceName), uno::UNO_QUERY); // Should result in no errors. xFilter->cancel(); diff --git a/xmloff/source/forms/layerexport.cxx b/xmloff/source/forms/layerexport.cxx index d1e92bca920d..800a88960143 100644 --- a/xmloff/source/forms/layerexport.cxx +++ b/xmloff/source/forms/layerexport.cxx @@ -65,7 +65,7 @@ namespace xmloff //= OFormLayerXMLExport_Impl const OUString& OFormLayerXMLExport_Impl::getControlNumberStyleNamePrefix() { - static const OUString s_sControlNumberStyleNamePrefix("C"); + static constexpr OUString s_sControlNumberStyleNamePrefix(u"C"_ustr); return s_sControlNumberStyleNamePrefix; } diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index aa9b364fedb4..b779d059306e 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -414,7 +414,7 @@ OUString const & XMLRedlineExport::ConvertTypeName( else { OSL_FAIL("unknown redline type"); - static const OUString sUnknownChange("UnknownChange"); + static constexpr OUString sUnknownChange(u"UnknownChange"_ustr); return sUnknownChange; } } diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index bb7e050a3886..3d87fb40030d 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -589,8 +589,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testODFDoubleX509Certificate) CPPUNIT_TEST_FIXTURE(SigningTest, testDNCompatibility) { - OUString const msDN("CN=\"\"\"ABC\"\".\", O=\"Enterprise \"\"ABC\"\"\""); - OUString const nssDN("CN=\\\"ABC\\\".,O=Enterprise \\\"ABC\\\""); + OUString constexpr msDN(u"CN=\"\"\"ABC\"\".\", O=\"Enterprise \"\"ABC\"\"\""_ustr); + OUString constexpr nssDN(u"CN=\\\"ABC\\\".,O=Enterprise \\\"ABC\\\""_ustr); // this is just the status quo, possibly either NSS or CryptoAPI might change CPPUNIT_ASSERT(!xmlsecurity::EqualDistinguishedNames(msDN, nssDN, xmlsecurity::NOCOMPAT)); CPPUNIT_ASSERT(!xmlsecurity::EqualDistinguishedNames(nssDN, msDN, xmlsecurity::NOCOMPAT)); |