diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-05-13 11:57:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-05-14 13:11:50 +0200 |
commit | af16aa625682b649e8843237652b9246d519cbae (patch) | |
tree | 2ea597c328318d6b75761b71af313bef02b5ad77 | |
parent | f40cbba63f13e7081fc5901769651fd4d43ea34d (diff) |
Improve loplugin:stringview
Issue the "instead of O[U]String, pass [u16]string_view" diagnostic also for
operator call arguments. (The "rather than copy, pass subView()" diagnostic is
already part of handleSubExprThatCouldBeView, so no need to repeat it explicitly
for operator call arguments.)
(And many call sites don't even require an explicit [u16]string_view, esp. with
the recent ad48b2b02f83eed41fb1eb8d16de7e804156fcf1 "Optimized OString operator
+= overloads". Just some test code in sal/qa/ that explicitly tests the
O[U]String functionality had to be excluded.)
Change-Id: I8d55ba5a7fa16a563f5ffe43d245125c88c793bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115589
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
51 files changed, 170 insertions, 116 deletions
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 0cf83c509a39..5b177b906d2d 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -530,7 +530,7 @@ ErrCode const & SbiStream::Read( char& ch ) if (aLine.isEmpty()) { Read( aLine ); - aLine += OString('\n'); + aLine += "\n"; } ch = aLine[0]; aLine = aLine.copy(1); @@ -724,7 +724,7 @@ char SbiIoSystem::Read() if( aIn.isEmpty() ) { ReadCon( aIn ); - aIn += OString('\n'); + aIn += "\n"; } ch = aIn[0]; aIn = aIn.copy(1); diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index b82cf7b5f8a1..385f67540b37 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -2737,12 +2737,12 @@ void SbiRuntime::StepWRITE() // write TOS OUString s; if( ch ) { - s += OUString(ch); + s += OUStringChar(ch); } s += p->GetOUString(); if( ch ) { - s += OUString(ch); + s += OUStringChar(ch); } pIosys->Write( s ); Error( pIosys->GetError() ); diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index 4a6b2cf345c1..e302d7c7742c 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -24,6 +24,7 @@ #include <osl/file.hxx> #include <string.h> +#include <string_view> #include <errno.h> #if defined(_WIN32) @@ -118,7 +119,7 @@ OString createFileNameFromType( const OString& destination, if( nIndex == -1 ) break; - if (buffer.isEmpty() || OString(".") == buffer.getStr()) + if (buffer.isEmpty() || std::string_view(".") == buffer.getStr()) { buffer.append(token); continue; diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index cc717079732f..0c060ce93513 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -39,7 +39,14 @@ public: { } - bool preRun() override { return true; } + bool preRun() override + { + auto const fn = handler.getMainFileName(); + return !( + loplugin::isSamePathname(fn, SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx") + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx") + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx")); + } virtual void run() override { @@ -65,32 +72,21 @@ bool StringView::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* cxxOperator if (ignoreLocation(cxxOperatorCallExpr)) return true; - auto check = [&](const Expr* expr) -> void { - auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(compat::IgnoreImplicit(expr)); - if (!memberCallExpr) - return; - auto methodDecl = memberCallExpr->getMethodDecl(); - if (!methodDecl || !methodDecl->getIdentifier() || methodDecl->getName() != "copy") - return; - report(DiagnosticsEngine::Warning, "rather than copy, pass with a view using subView()", - compat::getBeginLoc(expr)) - << expr->getSourceRange(); - }; auto op = cxxOperatorCallExpr->getOperator(); if (op == OO_Plus && cxxOperatorCallExpr->getNumArgs() == 2) { - check(cxxOperatorCallExpr->getArg(0)); - check(cxxOperatorCallExpr->getArg(1)); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(0))); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(1))); } if (compat::isComparisonOp(cxxOperatorCallExpr)) { - check(cxxOperatorCallExpr->getArg(0)); - check(cxxOperatorCallExpr->getArg(1)); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(0))); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(1))); } else if (op == OO_PlusEqual) - check(cxxOperatorCallExpr->getArg(1)); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(1))); else if (op == OO_Subscript) - check(cxxOperatorCallExpr->getArg(0)); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(0))); else if (op == OO_Equal) { if (loplugin::TypeCheck(cxxOperatorCallExpr->getType()) @@ -102,7 +98,7 @@ bool StringView::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* cxxOperator .Namespace("rtl") .GlobalNamespace()) { - check(cxxOperatorCallExpr->getArg(1)); + handleSubExprThatCouldBeView(compat::IgnoreImplicit(cxxOperatorCallExpr->getArg(1))); } } return true; diff --git a/compilerplugins/clang/test/stringview.cxx b/compilerplugins/clang/test/stringview.cxx index edd2305f2c69..66d35975bf13 100644 --- a/compilerplugins/clang/test/stringview.cxx +++ b/compilerplugins/clang/test/stringview.cxx @@ -152,6 +152,8 @@ void f5(OUString s) buf.append(s.copy(12)); // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}} buf.append(OUString(std::u16string_view(u"foo"))); + // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}} + s += OUString(std::u16string_view(u"foo")); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index b774c80a230b..a165cf6e8652 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1971,7 +1971,7 @@ public: case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: { uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aPayload)); - if (OString("EMPTY") == pPayload) + if (std::string_view("EMPTY") == pPayload) return; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); m_aOwnCursor.setX(aSeq[0].toInt32()); diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 13f70dabf6a5..d8e82beb40b9 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -522,7 +522,7 @@ bool SvxLRSpaceItem::GetPresentation else rText = GetMetricText( nLeftMargin, eCoreUnit, ePresUnit, &rIntl ); - rText += OUString(cpDelim); + rText += cpDelim; if ( 100 != nPropFirstLineOffset ) { rText += unicode::formatPercent(nPropFirstLineOffset, @@ -531,7 +531,7 @@ bool SvxLRSpaceItem::GetPresentation else rText += GetMetricText( static_cast<tools::Long>(nFirstLineOffset), eCoreUnit, ePresUnit, &rIntl ); - rText += OUString(cpDelim); + rText += cpDelim; if ( 100 != nRightMargin ) { rText += unicode::formatPercent(nRightMargin, @@ -553,7 +553,7 @@ bool SvxLRSpaceItem::GetPresentation rText += GetMetricText( nLeftMargin, eCoreUnit, ePresUnit, &rIntl ) + " " + EditResId(GetMetricId(ePresUnit)); } - rText += OUString(cpDelim); + rText += cpDelim; if ( 100 != nPropFirstLineOffset || nFirstLineOffset ) { rText += EditResId(RID_SVXITEMS_LRSPACE_FLINE); @@ -566,7 +566,7 @@ bool SvxLRSpaceItem::GetPresentation eCoreUnit, ePresUnit, &rIntl ) + " " + EditResId(GetMetricId(ePresUnit)); } - rText += OUString(cpDelim); + rText += cpDelim; } rText += EditResId(RID_SVXITEMS_LRSPACE_RIGHT); if ( 100 != nPropRightMargin ) @@ -800,7 +800,7 @@ bool SvxULSpaceItem::GetPresentation } else rText = GetMetricText( static_cast<tools::Long>(nUpper), eCoreUnit, ePresUnit, &rIntl ); - rText += OUString(cpDelim); + rText += cpDelim; if ( 100 != nPropLower ) { rText += unicode::formatPercent(nPropLower, diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 3e20001f82d8..06ac5c24f841 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -4419,7 +4419,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) uno::Reference<beans::XPropertySet> aPropertySet( aXShape, uno::UNO_QUERY ); - if ((aType == OString( "drawing.PolyPolygon" )) || (aType == OString( "drawing.PolyLine" ))) + if ((aType == "drawing.PolyPolygon") || (aType == "drawing.PolyLine")) { if ( aPropertySet.is() ) { @@ -4458,8 +4458,8 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) } } } - else if ((aType == OString( "drawing.OpenBezier" )) || (aType == OString( "drawing.OpenFreeHand" )) || (aType == OString( "drawing.PolyLinePath" )) - || (aType == OString( "drawing.ClosedBezier" )) || ( aType == OString( "drawing.ClosedFreeHand" )) || (aType == OString( "drawing.PolyPolygonPath" )) ) + else if ((aType == "drawing.OpenBezier") || (aType == "drawing.OpenFreeHand") || (aType == "drawing.PolyLinePath") + || (aType == "drawing.ClosedBezier") || ( aType == "drawing.ClosedFreeHand") || (aType == "drawing.PolyPolygonPath") ) { uno::Reference<beans::XPropertySet> aPropertySet2( aXShape, uno::UNO_QUERY ); @@ -4623,7 +4623,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) aPoly.Rotate( aRect.TopLeft(), Degree10(static_cast<sal_Int16>( ( nAngle + 5 ) / 10 )) ); nRule = GetClosestPoint( aPoly, aRefPoint ); - if (aType == OString( "drawing.Ellipse" )) + if (aType == "drawing.Ellipse") nRule <<= 1; // In PPT an ellipse has 8 ways to connect } } diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 7bc22fa370c7..06e26f8522c8 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -19,6 +19,7 @@ #include <deque> #include <memory> +#include <string_view> #include "hwpreader.hxx" #include <math.h> @@ -3152,25 +3153,26 @@ void HwpReader::makeFieldCode(hchar_string const & rStr, FieldCode const *hbox) /* Document Summary */ else if( hbox->type[0] == 3 && hbox->type[1] == 0 ) { - if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "title") + if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) + == std::u16string_view(u"title")) { rstartEl( "text:title", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:title" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "subject") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"subject")) { rstartEl( "text:subject", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:subject" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "author") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"author")) { rstartEl( "text:author-name", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:author-name" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "keywords") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"keywords")) { rstartEl( "text:keywords", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); @@ -3180,61 +3182,63 @@ void HwpReader::makeFieldCode(hchar_string const & rStr, FieldCode const *hbox) /* Personal Information */ else if( hbox->type[0] == 3 && hbox->type[1] == 1 ) { - if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "User") + if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) + == std::u16string_view(u"User")) { rstartEl( "text:sender-lastname", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-lastname" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Company") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Company")) { rstartEl( "text:sender-company", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-company" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Position") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Position")) { rstartEl( "text:sender-title", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-title" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Division") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Division")) { rstartEl( "text:sender-position", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-position" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Fax") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) + == std::u16string_view(u"Fax")) { rstartEl( "text:sender-fax", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-fax" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Pager") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Pager")) { rstartEl( "text:phone-private", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:phone-private" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "E-mail") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"E-mail")) { rstartEl( "text:sender-email", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-email" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Zipcode(office)") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Zipcode(office)")) { rstartEl( "text:sender-postal-code", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-postal-code" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Phone(office)") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Phone(office)")) { rstartEl( "text:sender-phone-work", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); rendEl( "text:sender-phone-work" ); } - else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get()))) == "Address(office)") + else if (reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3.get())) == std::u16string_view(u"Address(office)")) { rstartEl( "text:sender-street", mxList ); rchars( fromHcharStringToOUString(hstr2ucsstr(hbox->str2.get())) ); diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 91b9a0acbe03..a12949c952e1 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -19,6 +19,7 @@ #include <string.h> #include <stack> +#include <string_view> using namespace ::com::sun::star; @@ -798,7 +799,7 @@ void TestBreakIterator::testWeak() sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i); OString aMsg = "Char 0x" + - OString::number(static_cast<sal_Int32>(OUString(aWeaks)[i]), 16) + + OString::number(static_cast<sal_Int32>(std::u16string_view(aWeaks)[i]), 16) + " should have been weak"; CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), i18n::ScriptType::WEAK, nScript); @@ -834,7 +835,7 @@ void TestBreakIterator::testAsian() sal_Int16 nScript = m_xBreak->getScriptType(aAsians, i); OString aMsg = "Char 0x" + - OString::number(static_cast<sal_Int32>(OUString(aAsians)[i]), 16) + + OString::number(static_cast<sal_Int32>(std::u16string_view(aAsians)[i]), 16) + " should have been asian"; CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), i18n::ScriptType::ASIAN, nScript); diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx index af020c207faf..dadfc13b86a0 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -961,7 +961,7 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal if ( number > tableSize && !bRecycleSymbol) result += OUString::number( number); else - result += OUString(&table[--number % tableSize], 1); + result += OUStringChar(table[--number % tableSize]); } // append suffix diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 40dd0a300cc5..0f3b03a2689a 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -18,6 +18,7 @@ */ #include <memory> +#include <string_view> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> @@ -703,7 +704,7 @@ Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems( const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq ) { Sequence< CalendarItem2 > aItems; - if ( OUString( allCalendars[rnOffset] ) == "ref" ) + if ( allCalendars[rnOffset] == std::u16string_view(u"ref") ) { aItems = getCalendarItemByName( OUString( allCalendars[rnOffset+1]), rLocale, calendarsSeq, nWhichItem); rnOffset += 2; diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index a79a30a504e2..742dc4e815ce 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -103,7 +103,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { outputFile = options.getOption("-O"); if (!outputFile.endsWith("/")) { - outputFile += OString('/'); + outputFile += "/"; } outputFile += strippedFileName.replaceAt( strippedFileName.getLength() -3 , 3, "urd"); diff --git a/idlc/source/parser.y b/idlc/source/parser.y index 5238f3b5c879..29654c32bbbe 100644 --- a/idlc/source/parser.y +++ b/idlc/source/parser.y @@ -2172,7 +2172,7 @@ scoped_name : identifier { checkIdentifier($4); - *$1 += OString("::"); + *$1 += "::"; *$1 += *$4; delete $4; $$ = $1; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 85001803bebc..90911ee7d153 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -33,6 +33,7 @@ #include <utility> #include <algorithm> #include <map> +#include <string_view> #if defined(_WIN32) #if !defined WIN32_LEAN_AND_MEAN @@ -252,13 +253,13 @@ FileHandleReader::readLine(OString * pLine) m_bLf = true; [[fallthrough]]; case 0x0A: - *pLine += OString(m_aBuffer + nStart, + *pLine += std::string_view(m_aBuffer + nStart, m_nIndex - 1 - nStart); //TODO! check for overflow, and not very efficient return RESULT_OK; } - *pLine += OString(m_aBuffer + nStart, m_nIndex - nStart); + *pLine += std::string_view(m_aBuffer + nStart, m_nIndex - nStart); //TODO! check for overflow, and not very efficient } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 99030277b387..6805c1bd3a49 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3445,7 +3445,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b if ( ( rProp.Value >>= aAdjustmentSeq ) && eShapeType != mso_sptActionButtonForwardNext // we have adjustments values for these type of shape, but MSO doesn't like them && eShapeType != mso_sptActionButtonBackPrevious // so they are now disabled - && OString(pShape) != "rect" //some shape types are commented out in pCustomShapeTypeTranslationTable[] & are being defaulted to rect & rect does not have adjustment values/name. + && pShape != std::string_view("rect") //some shape types are commented out in pCustomShapeTypeTranslationTable[] & are being defaulted to rect & rect does not have adjustment values/name. ) { SAL_INFO("oox.shape", "adj seq len: " << aAdjustmentSeq.getLength()); diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index b83dbb3b821a..e4c595a6f0f7 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -4705,7 +4705,7 @@ namespace osl_Directory OString tmp_x(OUStringToOString(system_path, RTL_TEXTENCODING_UTF8)); if (tmp_x.lastIndexOf('/') != (tmp_x.getLength() - 1)) - tmp_x += OString('/'); + tmp_x += "/"; #if !defined(_WIN32) && !defined(ANDROID) && !defined(AIX) // FIXME would be nice to create unique dir even on Windows @@ -4718,9 +4718,9 @@ namespace osl_Directory out != nullptr ); - tmp_x += OString('/'); + tmp_x += "/"; #endif - tmp_x += OString(TEST_PATH_POSTFIX); + tmp_x += TEST_PATH_POSTFIX; OUString tmpTestPath; rc = osl::FileBase::getFileURLFromSystemPath(OStringToOUString(tmp_x, RTL_TEXTENCODING_UTF8), tmpTestPath); diff --git a/sal/qa/rtl/strings/test_oustring_convert.cxx b/sal/qa/rtl/strings/test_oustring_convert.cxx index bfd1a2aac784..da930a03f244 100644 --- a/sal/qa/rtl/strings/test_oustring_convert.cxx +++ b/sal/qa/rtl/strings/test_oustring_convert.cxx @@ -90,7 +90,7 @@ void testConvertToString(TestConvertToString const & rTest) } else { - if (aStrict != OString(RTL_CONSTASCII_STRINGPARAM("12345"))) + if (aStrict != "12345") { OStringBuffer aMessage(aPrefix); aMessage.append("modified output"); diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index c3da14b3453d..7c4b22a2d9a3 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -26,6 +26,7 @@ #include <comphelper/sequence.hxx> #include <string.h> +#include <string_view> #if OSL_DEBUG_LEVEL > 0 #include <iostream> @@ -315,9 +316,11 @@ namespace sax_fastparser { mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement))); Sequence<sal_Int8> const name( mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement))); - return OString(reinterpret_cast<char const*>(ns.getConstArray()), ns.getLength()) + return std::string_view( + reinterpret_cast<char const*>(ns.getConstArray()), ns.getLength()) + sColon - + OString(reinterpret_cast<char const*>(name.getConstArray()), name.getLength()); + + std::string_view( + reinterpret_cast<char const*>(name.getConstArray()), name.getLength()); } else { Sequence<sal_Int8> const name( mxFastTokenHandler->getUTF8Identifier(nElement)); diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 67e1954598eb..48882d71bee9 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -29,6 +29,7 @@ #include <comphelper/string.hxx> #include <sal/log.hxx> #include <memory> +#include <string_view> static const char* GetAddInName( const sal_uInt8 nIndex ); @@ -145,7 +146,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nCnt, const char* pExtString ) SAL_WARN_IF( nCnt != 3, "sc.filter", "*LotusToSc::DoFunc(): TERM() or CTERM() need 3 parameters!" ); nCnt = 4; - if ( OString(pExtString) == "TERM" ) + if ( pExtString == std::string_view("TERM") ) { // @TERM(pmt,int,fv) -> NPER(int,-pmt,pv=0,fv) NegToken( eParam[ 2 ] ); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 627ef8e8412a..0814abb2515d 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -56,6 +56,7 @@ #include <chrono> #include <cstdlib> +#include <string_view> using namespace css; @@ -931,7 +932,7 @@ public: case LOK_CALLBACK_CURSOR_VISIBLE: { m_bCursorVisibleChanged = true; - m_bCursorVisible = (OString("true") == pPayload); + m_bCursorVisible = (std::string_view("true") == pPayload); } break; case LOK_CALLBACK_VIEW_LOCK: @@ -957,7 +958,7 @@ public: boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); const int nViewId = aTree.get_child("viewId").get_value<int>(); - m_aViewCursorVisibilities[nViewId] = OString("true") == pPayload; + m_aViewCursorVisibilities[nViewId] = std::string_view("true") == pPayload; } break; case LOK_CALLBACK_TEXT_VIEW_SELECTION: diff --git a/sd/source/ui/app/sdpopup.cxx b/sd/source/ui/app/sdpopup.cxx index 52a0435351de..4aafd2848a3a 100644 --- a/sd/source/ui/app/sdpopup.cxx +++ b/sd/source/ui/app/sdpopup.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <editeng/flditem.hxx> #include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> @@ -164,7 +168,8 @@ void SdFieldPopup::Execute(weld::Window* pParent, const tools::Rectangle& rRect) { int nCount = m_xPopup->n_children(); for (int i = 3; i < nCount; i++) - m_xPopup->set_active(OString::number(i), sIdent == OString::number(i)); + m_xPopup->set_active( + OString::number(i), sIdent == std::string_view(OString::number(i))); } } diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index 0a6d198f1d0b..65564a00d280 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -12,6 +12,7 @@ #include <iostream> #include <memory> #include <new> +#include <string_view> #include <sal/log.hxx> #include <osl/socket.hxx> @@ -254,7 +255,7 @@ getBluez5Adapter(DBusConnection *pConnection) char* pMessage; dbus_message_iter_get_basic(&aInnerInnerIter, &pMessage); - if (OString(pMessage) == "org.bluez.Adapter1") + if (pMessage == std::string_view("org.bluez.Adapter1")) { dbus_message_unref(pMsg); if (pPath) @@ -882,13 +883,13 @@ static DBusHandlerResult ProfileMessageFunction { SAL_INFO("sdremote.bluetooth", "ProfileMessageFunction||" << dbus_message_get_interface(pMessage) << "||" << dbus_message_get_member(pMessage)); - if (OString(dbus_message_get_interface(pMessage)) == "org.bluez.Profile1") + if (dbus_message_get_interface(pMessage) == std::string_view("org.bluez.Profile1")) { - if (OString(dbus_message_get_member(pMessage)) == "Release") + if (dbus_message_get_member(pMessage) == std::string_view("Release")) { return DBUS_HANDLER_RESULT_HANDLED; } - else if (OString(dbus_message_get_member(pMessage)) == "NewConnection") + else if (dbus_message_get_member(pMessage) == std::string_view("NewConnection")) { if (!dbus_message_has_signature(pMessage, "oha{sv}")) { @@ -939,7 +940,7 @@ static DBusHandlerResult ProfileMessageFunction return DBUS_HANDLER_RESULT_HANDLED; } } - else if (OString(dbus_message_get_member(pMessage)) == "RequestDisconnection") + else if (dbus_message_get_member(pMessage) == std::string_view("RequestDisconnection")) { return DBUS_HANDLER_RESULT_HANDLED; } diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 78be4e455894..ea64de5589ce 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -85,6 +85,7 @@ #include <ucbhelper/content.hxx> #include <unotools/ucbhelper.hxx> +#include <string_view> #include <unordered_map> #include <vector> @@ -612,7 +613,8 @@ void IndexTabPage_Impl::InitializeIndex() it = aInfo.emplace(aTempString, 0).first; sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(OUString(), false))); if ( (tmp = it->second++) != 0) - m_xIndexList->append(sId, aTempString + OUString(append, tmp)); + m_xIndexList->append( + sId, aTempString + std::u16string_view(append, tmp)); else m_xIndexList->append(sId, aTempString); } @@ -639,7 +641,7 @@ void IndexTabPage_Impl::InitializeIndex() // Assume the token is trimmed it = aInfo.emplace(aKeywordPair, 0).first; if ((tmp = it->second++) != 0) - m_xIndexList->append(sId, aKeywordPair + OUString(append, tmp)); + m_xIndexList->append(sId, aKeywordPair + std::u16string_view(append, tmp)); else m_xIndexList->append(sId, aKeywordPair); @@ -664,7 +666,8 @@ void IndexTabPage_Impl::InitializeIndex() it = aInfo.emplace(aTempString, 0).first; if ( (tmp = it->second++) != 0 ) - m_xIndexList->append(sId, aTempString + OUString(append, tmp)); + m_xIndexList->append( + sId, aTempString + std::u16string_view(append, tmp)); else m_xIndexList->append(sId, aTempString); } diff --git a/svx/source/fmcomp/dbaexchange.cxx b/svx/source/fmcomp/dbaexchange.cxx index 18d425cc17bc..23e53d83bc10 100644 --- a/svx/source/fmcomp/dbaexchange.cxx +++ b/svx/source/fmcomp/dbaexchange.cxx @@ -180,7 +180,7 @@ namespace svx cCommandType = '2'; break; } - m_sCompatibleFormat += OUString(&cCommandType, 1); + m_sCompatibleFormat += OUStringChar(cCommandType); m_sCompatibleFormat += sSeparator; m_sCompatibleFormat += _rFieldName; @@ -545,13 +545,13 @@ namespace svx switch (_nCommandType) { case CommandType::TABLE: - m_sCompatibleObjectDescription += OUString(&cTableMark, 1); + m_sCompatibleObjectDescription += OUStringChar(cTableMark); break; case CommandType::QUERY: - m_sCompatibleObjectDescription += OUString(&cQueryMark, 1); + m_sCompatibleObjectDescription += OUStringChar(cQueryMark); break; case CommandType::COMMAND: - m_sCompatibleObjectDescription += OUString(&cQueryMark, 1); + m_sCompatibleObjectDescription += OUStringChar(cQueryMark); // think of it as a query break; } diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index b6ead94c80fe..9a08d06b48cd 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -10,6 +10,7 @@ #include <swmodeltestbase.hxx> #include <memory> +#include <string_view> #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/embed/ElementModes.hpp> @@ -207,12 +208,12 @@ public: private: bool mustCalcLayoutOf(const char* filename) override { - return OString(filename) != "fdo62336.docx"; + return filename != std::string_view("fdo62336.docx"); } bool mustTestImportOf(const char* filename) const override { - return OString(filename) != "fdo62336.docx"; + return filename != std::string_view("fdo62336.docx"); } virtual std::unique_ptr<Resetter> preTest(const char* filename) override @@ -237,7 +238,7 @@ private: else setFilterOptions(""); - if (OString(filename) == "charborder.odt") + if (filename == std::string_view("charborder.odt")) { // FIXME if padding-top gets exported as inches, not cms, we get rounding errors. SwGlobals::ensure(); // make sure that SW_MOD() is not 0 diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 6dc67ca58a1d..d5efe8a29677 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -9,6 +9,7 @@ #include <algorithm> #include <memory> +#include <string_view> #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontSlant.hpp> @@ -82,7 +83,7 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* pFilename) override { - if (OString(pFilename) == "fdo58949.docx") + if (pFilename == std::string_view("fdo58949.docx")) { std::unique_ptr<Resetter> pResetter(new Resetter( [] () { @@ -97,7 +98,7 @@ public: pBatch->commit(); return pResetter; } - if (OString(pFilename) == "2_MathType3.docx") + if (pFilename == std::string_view("2_MathType3.docx")) { std::unique_ptr<Resetter> pResetter(new Resetter( [this] () { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index ba6a6a6a98e2..9ff2a3db4e38 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -73,7 +73,8 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { - if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" ) + if (filename == std::string_view("smartart.docx") + || filename == std::string_view("strict-smartart.docx") ) { std::unique_ptr<Resetter> pResetter(new Resetter( [] () { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index f0450f7b6cbb..5f3fc94cd8e4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.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 <swmodeltestbase.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -43,7 +47,8 @@ protected: */ bool mustTestImportOf(const char* filename) const override { // If the testcase is stored in some other format, it's pointless to test. - return OString(filename).endsWith(".docx") || OString(filename) == "ooo39250-1-min.rtf"; + return OString(filename).endsWith(".docx") + || filename == std::string_view("ooo39250-1-min.rtf"); } }; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 991bfb6817f1..c7936e1ec58e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.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 <swmodeltestbase.hxx> #include <svx/svddef.hxx> @@ -39,7 +43,7 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { - if (OString(filename) == "tdf135774_numberingShading.docx") + if (filename == std::string_view("tdf135774_numberingShading.docx")) { bool bIsExportAsShading = SvtFilterOptions::Get().IsCharBackground2Shading(); // This function is run at the end of the test - returning the filter options to normal. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index ac0930169253..3dfd1af1a302 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.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 <swmodeltestbase.hxx> #include <com/sun/star/awt/XBitmap.hpp> @@ -54,7 +58,7 @@ protected: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { - if (OString(filename) == "combobox-control.docx" ) + if (filename == std::string_view("combobox-control.docx") ) { std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create()); officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true, batch); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index f11b7d8ae140..0faed8c2ac02 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -8,6 +8,7 @@ */ #include <memory> +#include <string_view> #ifdef MACOSX #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 @@ -65,7 +66,8 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { - if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" ) + if (filename == std::string_view("smartart.docx") + || filename == std::string_view("strict-smartart.docx") ) { std::unique_ptr<Resetter> pResetter(new Resetter( [] () { diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 84183572cefd..2af4b6877673 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -8,6 +8,7 @@ */ #include <memory> +#include <string_view> #include <config_features.h> #ifdef MACOSX @@ -76,7 +77,7 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { - if (OString(filename) == "fdo87488.docx") + if (filename == std::string_view("fdo87488.docx")) { std::unique_ptr<Resetter> pResetter(new Resetter( [] () { diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index d34e8cb5a969..24675f30c924 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -52,7 +52,7 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { m_aSavedSettings = Application::GetSettings(); - if (OString(filename) == "fdo48023.rtf") + if (filename == std::string_view("fdo48023.rtf")) { std::unique_ptr<Resetter> pResetter( new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); })); @@ -61,7 +61,7 @@ public: Application::SetSettings(aSettings); return pResetter; } - else if (OString(filename) == "fdo44211.rtf") + else if (filename == std::string_view("fdo44211.rtf")) { std::unique_ptr<Resetter> pResetter( new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); })); diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index d356ed1c0938..ad392be7fb75 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -8,6 +8,7 @@ */ #include <memory> +#include <string_view> #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontWeight.hpp> @@ -55,7 +56,7 @@ public: virtual std::unique_ptr<Resetter> preTest(const char* filename) override { m_aSavedSettings = Application::GetSettings(); - if (OString(filename) == "fdo72031.rtf") + if (filename == std::string_view("fdo72031.rtf")) { std::unique_ptr<Resetter> pResetter( new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); })); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index b5d8000c967f..aab2a4cc71e8 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -10,6 +10,7 @@ #include <swmodeltestbase.hxx> #include <string> +#include <string_view> #include <boost/property_tree/json_parser.hpp> @@ -327,7 +328,7 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) { tools::Rectangle aInvalidation; uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); - if (OString("EMPTY") == pPayload) + if (std::string_view("EMPTY") == pPayload) return; CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); aInvalidation.setX(aSeq[0].toInt32()); @@ -875,7 +876,7 @@ public: else sRect = aPayload; uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(sRect)); - if (OString("EMPTY") == pPayload) + if (std::string_view("EMPTY") == pPayload) return; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); m_aOwnCursor.setX(aSeq[0].toInt32()); @@ -895,7 +896,7 @@ public: OString aRect = aTree.get_child("rectangle").get_value<std::string>().c_str(); uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aRect)); - if (OString("EMPTY") == pPayload) + if (std::string_view("EMPTY") == pPayload) return; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); m_aViewCursor.setX(aSeq[0].toInt32()); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index b7befec7c0cd..2d17a7ff88fb 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.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 <swmodeltestbase.hxx> #include <com/sun/star/awt/FontWeight.hpp> @@ -103,7 +107,7 @@ protected: virtual void postLoad(const char* pFilename) override { - if (OString(pFilename) == "tdf94386.odt") + if (pFilename == std::string_view("tdf94386.odt")) { SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx index 08d9c36c866c..4f1bc42ecc18 100644 --- a/sw/source/core/layout/dbg_lay.cxx +++ b/sw/source/core/layout/dbg_lay.cxx @@ -440,7 +440,7 @@ void SwImplProtocol::FileInit() aLine.clear(); } else - aLine += OString(c); + aLine += OStringChar(c); } if( !aLine.isEmpty() ) CheckLine( aLine ); // evaluate last line diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index a15cd96519cb..bff41ee81471 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -3130,7 +3130,7 @@ static Writer& OutHTML_SwTextCharFormat( Writer& rWrt, const SfxPoolItem& rHt ) if( !pFormatInfo->aToken.isEmpty() ) sOut += pFormatInfo->aToken; else - sOut += OString(OOO_STRING_SVTOOLS_HTML_span); + sOut += OOO_STRING_SVTOOLS_HTML_span; if( rHTMLWrt.m_bCfgOutStyles && (!pFormatInfo->aClass.isEmpty() || pFormatInfo->bScriptDependent) ) diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index fabccbb8a2e0..38c0418060e1 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -167,7 +167,7 @@ static void lcl_html_outEvents( SvStream& rStrm, OString sOut = " "; if( pOpt && (EXTENDED_STYPE != eScriptType || rDesc.AddListenerParam.isEmpty()) ) - sOut += OString(pOpt); + sOut += pOpt; else { sOut += OOO_STRING_SVTOOLS_HTML_O_sdevent + diff --git a/sw/source/filter/html/htmlnumwriter.cxx b/sw/source/filter/html/htmlnumwriter.cxx index ddfedd760923..2fa1e6aa3f6b 100644 --- a/sw/source/filter/html/htmlnumwriter.cxx +++ b/sw/source/filter/html/htmlnumwriter.cxx @@ -213,7 +213,7 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt, if( SVX_NUM_CHAR_SPECIAL == eType ) { // ordered list: <OL> - sOut += OString(OOO_STRING_SVTOOLS_HTML_unorderlist); + sOut += OOO_STRING_SVTOOLS_HTML_unorderlist; // determine the type by the bullet character const char *pStr = nullptr; @@ -238,7 +238,7 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt, else if( SVX_NUM_BITMAP == eType ) { // Unordered list: <UL> - sOut += OString(OOO_STRING_SVTOOLS_HTML_unorderlist); + sOut += OOO_STRING_SVTOOLS_HTML_unorderlist; rWrt.Strm().WriteOString( sOut ); OutHTML_BulletImage( rWrt, nullptr, @@ -248,7 +248,7 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt, else { // Ordered list: <OL> - sOut += OString(OOO_STRING_SVTOOLS_HTML_orderlist); + sOut += OOO_STRING_SVTOOLS_HTML_orderlist; // determine the type by the format char cType = 0; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 3c6b2616e13a..f0775d63f6b8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2722,7 +2722,7 @@ void DocxAttributeOutput::WriteCollectedRunProperties() { const char* pVal = nullptr; m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pVal); - if (OString("auto") != pVal) + if (std::string_view("auto") != pVal) { m_pSerializer->startElementNS(XML_w14, XML_textFill); m_pSerializer->startElementNS(XML_w14, XML_solidFill); diff --git a/vcl/source/filter/idxf/dxfreprd.cxx b/vcl/source/filter/idxf/dxfreprd.cxx index 340f8fcb5e0a..8bed6cb57b29 100644 --- a/vcl/source/filter/idxf/dxfreprd.cxx +++ b/vcl/source/filter/idxf/dxfreprd.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> #include "dxfreprd.hxx" #include <osl/nlsupport.h> @@ -205,7 +208,7 @@ void DXFRepresentation::ReadHeader(DXFGroupReader & rDGR) // encodings for storing to corresponding formats, but there's // no way to know that. // See http://autodesk.blogs.com/between_the_lines/autocad-release-history.html - if ((rDGR.GetS() <= "AC1009") || (rDGR.GetS() == "AC2.22") || (rDGR.GetS() == "AC2.21") || (rDGR.GetS() == "AC2.10") || + if ((rDGR.GetS() <= std::string_view("AC1009")) || (rDGR.GetS() == "AC2.22") || (rDGR.GetS() == "AC2.21") || (rDGR.GetS() == "AC2.10") || (rDGR.GetS() == "AC1.50") || (rDGR.GetS() == "AC1.40") || (rDGR.GetS() == "AC1.2") || (rDGR.GetS() == "MC0.0")) { // Set OEM encoding for old DOS formats @@ -215,7 +218,7 @@ void DXFRepresentation::ReadHeader(DXFGroupReader & rDGR) setTextEncoding(utl_getWinTextEncodingFromLangStr( utl_getLocaleForGlobalDefaultEncoding(), true)); } - else if (rDGR.GetS() >= "AC1021") + else if (rDGR.GetS() >= std::string_view("AC1021")) setTextEncoding(RTL_TEXTENCODING_UTF8); else { diff --git a/vcl/source/filter/ipcd/ipcd.cxx b/vcl/source/filter/ipcd/ipcd.cxx index 5072e2ab4354..10c4abc30549 100644 --- a/vcl/source/filter/ipcd/ipcd.cxx +++ b/vcl/source/filter/ipcd/ipcd.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> #include <vcl/graph.hxx> #include <vcl/BitmapTools.hxx> @@ -167,7 +170,7 @@ void PCDReader::CheckPCDImagePacFile() m_rPCD.Seek( 2048 ); m_rPCD.ReadBytes(Buf, 7); Buf[ 7 ] = 0; - if (OString(Buf) != "PCD_IPI") + if (Buf != std::string_view("PCD_IPI")) bStatus = false; } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 522ec374693c..55993009e03c 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -502,7 +502,7 @@ VclBuilder::VclBuilder(vcl::Window* pParent, const OUString& sUIDir, const OUStr sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); if (nIdx != -1) m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); - m_sHelpRoot += OString('/'); + m_sHelpRoot += "/"; OUString sUri = sUIDir + sUIFile; diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 77b2bec9fc53..6b2605f01117 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -18035,7 +18035,7 @@ public: sal_Int32 nIdx = sHelpRoot.lastIndexOf('.'); if (nIdx != -1) sHelpRoot = sHelpRoot.copy(0, nIdx); - sHelpRoot += OUString('/'); + sHelpRoot += "/"; m_aUtf8HelpRoot = OUStringToOString(sHelpRoot, RTL_TEXTENCODING_UTF8); m_aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); m_aUILang = Application::GetSettings().GetUILanguageTag().getBcp47(); diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx index 11dfd8cfe908..da9c0f28e530 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.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 "txtparai.hxx" #include "XMLFootnoteImportContext.hxx" @@ -44,7 +48,7 @@ void FillStyle(const OUString& rName, std::map<OUString, librevenge::RVNGPropert librevenge::RVNGPropertyList::Iter itProp(rStyle); for (itProp.rewind(); itProp.next();) { - if (OString("style:parent-style-name") != itProp.key()) + if (std::string_view("style:parent-style-name") != itProp.key()) rPropertyList.insert(itProp.key(), itProp()->clone()); } } diff --git a/xmloff/source/forms/eventimport.cxx b/xmloff/source/forms/eventimport.cxx index 150a9f27a5cc..02bfe7764a6b 100644 --- a/xmloff/source/forms/eventimport.cxx +++ b/xmloff/source/forms/eventimport.cxx @@ -77,8 +77,7 @@ namespace xmloff if ( !sLibrary.isEmpty() ) { // for StarBasic, the library is prepended - sal_Unicode cLibSeparator = ':'; - sLibrary += OUString( &cLibSeparator, 1 ); + sLibrary += ":"; } sLibrary += pTranslated->ScriptCode; pTranslated->ScriptCode = sLibrary; diff --git a/xmlscript/qa/cppunit/test.cxx b/xmlscript/qa/cppunit/test.cxx index 692837a19615..fd5137db90d1 100644 --- a/xmlscript/qa/cppunit/test.cxx +++ b/xmlscript/qa/cppunit/test.cxx @@ -129,7 +129,7 @@ void XmlScriptTest::exportToFile(std::u16string_view sURL, memcpy(bytes.getArray() + nPos, readBytes.getConstArray(), static_cast<sal_uInt32>(nRead)); } - osl::File aFile(OUString() + sURL); + osl::File aFile(OUString{ sURL }); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, aFile.open(osl_File_OpenFlag_Write)); sal_uInt64 nBytesWritten; CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index c612962f86e3..5f1e6a1286e7 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -556,7 +556,7 @@ CPPUNIT_TEST_FIXTURE(PDFSigningTest, testTokenize) // Just make sure the tokenizer finishes without an error, don't look at the signature. CPPUNIT_ASSERT(aDocument.Read(aStream)); - if (OUString(rName) == "tdf107149.pdf") + if (rName == u"tdf107149.pdf") // This failed, page list was empty. CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aDocument.GetPages().size()); } diff --git a/xmlsecurity/workben/pdfverify.cxx b/xmlsecurity/workben/pdfverify.cxx index 16856129fa5e..0951eb7c5e65 100644 --- a/xmlsecurity/workben/pdfverify.cxx +++ b/xmlsecurity/workben/pdfverify.cxx @@ -83,7 +83,7 @@ int pdfVerify(int nArgc, char** pArgv) InitVCL(); comphelper::ScopeGuard g([] { DeInitVCL(); }); - if (nArgc > 3 && OString(pArgv[3]) == "-p") + if (nArgc > 3 && pArgv[3] == std::string_view("-p")) { generatePreview(pArgv[1], pArgv[2]); return 0; @@ -110,7 +110,7 @@ int pdfVerify(int nArgc, char** pArgv) osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(pArgv[2]), aOutURL); bool bRemoveSignature = false; - if (nArgc > 3 && OString(pArgv[3]) == "-r") + if (nArgc > 3 && pArgv[3] == std::string_view("-r")) bRemoveSignature = true; SvFileStream aStream(aInURL, StreamMode::READ); |