diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index b5d533b115cb..d59d1dc68555 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -43,16 +43,9 @@ public: 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") - || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/oustring/rtl_OUString2.cxx") - || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx") - || loplugin::isSamePathname(fn, - SRCDIR "/sal/qa/rtl/strings/test_oustring_startswith.cxx") - || loplugin::isSamePathname(fn, SRCDIR - "/sal/qa/rtl/strings/test_strings_defaultstringview.cxx")); + return !(loplugin::isSamePathname(fn, SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/strings/") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/oustring/")); } virtual void run() override @@ -368,7 +361,8 @@ bool StringView::VisitCXXMemberCallExpr(CXXMemberCallExpr const* expr) || dc.Function("toDouble") || dc.Function("equalsAscii") || dc.Function("equalsAsciiL") || dc.Function("equalsIgnoreAsciiCase") || dc.Function("compareToIgnoreAsciiCase") || dc.Function("matchIgnoreAsciiCase") || dc.Function("trim") - || dc.Function("startsWith") || dc.Function("endsWith") || dc.Function("match")) + || dc.Function("startsWith") || dc.Function("endsWith") || dc.Function("match") + || dc.Function("isEmpty") || dc.Function("getLength")) { handleSubExprThatCouldBeView(expr->getImplicitObjectArgument()); } diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 62e54caa4468..5b8cdb7b16d6 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -196,7 +196,7 @@ void Connection::construct(const OUString& url, const Sequence< PropertyValue >& // External file AND/OR remote connection else if (url.startsWith("sdbc:firebird:")) { - m_sFirebirdURL = url.copy(OUString("sdbc:firebird:").getLength()); + m_sFirebirdURL = url.copy(strlen("sdbc:firebird:")); if (m_sFirebirdURL.startsWith("file://")) { m_bIsFile = true; diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index e867ba266688..fa485a97b2df 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -204,7 +204,7 @@ namespace dbaui m_xJavaDriverLabel->set_visible(bEnableJDBC); m_xJavaDriver->set_visible(bEnableJDBC); m_xTestJavaDriver->set_visible(bEnableJDBC); - m_xTestJavaDriver->set_sensitive( !m_xJavaDriver->get_text().trim().isEmpty() ); + m_xTestJavaDriver->set_sensitive( !o3tl::trim(m_xJavaDriver->get_text()).empty() ); m_xFL3->set_visible(bEnableJDBC); checkTestConnection(); @@ -244,7 +244,7 @@ namespace dbaui #if HAVE_FEATURE_JAVA try { - if ( !m_xJavaDriver->get_text().trim().isEmpty() ) + if ( !o3tl::trim(m_xJavaDriver->get_text()).empty() ) { ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() ); m_xJavaDriver->set_text(m_xJavaDriver->get_text().trim()); // fdo#68341 @@ -266,14 +266,14 @@ namespace dbaui OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); bool bEnableTestConnection = !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty(); if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC ) - bEnableTestConnection = bEnableTestConnection && (!m_xJavaDriver->get_text().trim().isEmpty()); + bEnableTestConnection = bEnableTestConnection && (!o3tl::trim(m_xJavaDriver->get_text()).empty()); m_xTestConnection->set_sensitive(bEnableTestConnection); return true; } IMPL_LINK(OConnectionTabPage, OnEditModified, weld::Entry&, rEdit, void) { if (&rEdit == m_xJavaDriver.get()) - m_xTestJavaDriver->set_sensitive( !m_xJavaDriver->get_text().trim().isEmpty() ); + m_xTestJavaDriver->set_sensitive( !o3tl::trim(m_xJavaDriver->get_text()).empty() ); checkTestConnection(); // tell the listener we were modified diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index 299dfa6b34cb..a5041ae2af12 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -448,7 +448,7 @@ using namespace ::com::sun::star; OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); // to get the correct value when saveValue was called by base class - if ( m_xETDriverClass->get_text().trim().isEmpty() ) + if ( o3tl::trim(m_xETDriverClass->get_text()).empty() ) { m_xETDriverClass->set_text(m_sDefaultJdbcDriverName); m_xETDriverClass->save_value(); @@ -467,7 +467,7 @@ using namespace ::com::sun::star; #if HAVE_FEATURE_JAVA try { - if ( !m_xETDriverClass->get_text().trim().isEmpty() ) + if ( !o3tl::trim(m_xETDriverClass->get_text()).empty() ) { // TODO change jvmaccess ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() ); @@ -488,8 +488,8 @@ using namespace ::com::sun::star; void OGeneralSpecialJDBCConnectionPageSetup::callModifiedHdl(weld::Widget* pControl) { if (pControl == m_xETDriverClass.get()) - m_xPBTestJavaDriver->set_sensitive( !m_xETDriverClass->get_text().trim().isEmpty() ); - bool bRoadmapState = ((!m_xETDatabasename->get_text().isEmpty() ) && ( !m_xETHostname->get_text().isEmpty() ) && (!m_xNFPortNumber->get_text().isEmpty() ) && ( !m_xETDriverClass->get_text().trim().isEmpty() )); + m_xPBTestJavaDriver->set_sensitive( !o3tl::trim(m_xETDriverClass->get_text()).empty() ); + bool bRoadmapState = ((!m_xETDatabasename->get_text().isEmpty() ) && ( !m_xETHostname->get_text().isEmpty() ) && (!m_xNFPortNumber->get_text().isEmpty() ) && ( !o3tl::trim(m_xETDriverClass->get_text()).empty() )); SetRoadmapStateValue(bRoadmapState); OGenericAdministrationPage::callModifiedHdl(); } diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx index 57ae3bd59fd7..1e8f94a89b79 100644 --- a/dbaccess/source/ui/dlg/detailpages.cxx +++ b/dbaccess/source/ui/dlg/detailpages.cxx @@ -442,7 +442,7 @@ namespace dbaui OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); // to get the correct value when saveValue was called by base class - if ( m_bUseClass && m_xEDDriverClass->get_text().trim().isEmpty() ) + if ( m_bUseClass && o3tl::trim(m_xEDDriverClass->get_text()).empty() ) { m_xEDDriverClass->set_text(m_sDefaultJdbcDriverName); m_xEDDriverClass->save_value(); @@ -457,7 +457,7 @@ namespace dbaui #if HAVE_FEATURE_JAVA try { - if (!m_xEDDriverClass->get_text().trim().isEmpty()) + if (!o3tl::trim(m_xEDDriverClass->get_text()).empty()) { // TODO change jvmaccess ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() ); @@ -478,7 +478,7 @@ namespace dbaui void OGeneralSpecialJDBCDetailsPage::callModifiedHdl(weld::Widget* pControl) { if (m_bUseClass && pControl == m_xEDDriverClass.get()) - m_xTestJavaDriver->set_sensitive(!m_xEDDriverClass->get_text().trim().isEmpty()); + m_xTestJavaDriver->set_sensitive(!o3tl::trim(m_xEDDriverClass->get_text()).empty()); // tell the listener we were modified OGenericAdministrationPage::callModifiedHdl(); diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index c1cd7399b685..e21e3c7a38d4 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -1146,7 +1146,7 @@ void Test::testUnderlineCopyPaste() aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen + (OUString("textforunder")).getLength(), rDoc.GetTextLen() ); + CPPUNIT_ASSERT_EQUAL( static_cast(aTextLen + strlen("textforunder")), rDoc.GetTextLen() ); CPPUNIT_ASSERT_EQUAL( OUString(aParaText + "textforunder" ), rDoc.GetParaAsString(sal_Int32(0)) ); // Check updated text for appropriate Underline diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx index 13059dba5d91..b5da23e7e00d 100644 --- a/i18npool/source/textconversion/textconversion_zh.cxx +++ b/i18npool/source/textconversion/textconversion_zh.cxx @@ -232,9 +232,9 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, current = entry[current] + word.getLength() + 1; sal_Int32 start=current; if (offset.hasElements()) { - if (word.getLength() != OUString(&wordData[current]).getLength()) + if (word.getLength() != static_cast(std::u16string_view(&wordData[current]).size())) one2one=false; - sal_Int32 convertedLength=OUString(&wordData[current]).getLength(); + sal_Int32 convertedLength=std::u16string_view(&wordData[current]).size(); while (wordData[current]) { offsetRange[count]=nStartPos + currPos + ((current-start) * word.getLength() / convertedLength); diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index 30da2bebf509..b3fa97ae00d0 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1060,7 +1061,7 @@ bool lcl_isTag( const icu::UnicodeString& rString ) OString XMLUtil::QuotHTML( const OString &rString ) { - if( rString.trim().isEmpty() ) + if( o3tl::trim(rString).empty() ) return rString; UErrorCode nIcuErr = U_ZERO_ERROR; static const sal_uInt32 nSearchFlags = diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index cfc53d944232..8e8aad365c7f 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -2438,7 +2438,7 @@ void XmlStreamObject::implDumpText( TextInputStream& rTextStrm ) entirely. */ mxOut->writeString( aElem ); mxOut->newLine(); - if( !aText.trim().isEmpty() ) + if( !o3tl::trim(aText).empty() ) { mxOut->writeString( aText ); mxOut->newLine(); diff --git a/reportdesign/source/filter/xml/xmlGroup.cxx b/reportdesign/source/filter/xml/xmlGroup.cxx index 3b5449fb0e40..b25a31fa8089 100644 --- a/reportdesign/source/filter/xml/xmlGroup.cxx +++ b/reportdesign/source/filter/xml/xmlGroup.cxx @@ -138,7 +138,7 @@ OXMLGroup::OXMLGroup( ORptFilter& _rImport { nGroupOn = report::GroupOn::INTERVAL; _rImport.removeFunction(sExpression); - sExpression = sExpression.copy(OUString("INT_count_").getLength()); + sExpression = sExpression.copy(std::string_view("INT_count_").size()); OUString sInterval = sCompleteFormula.getToken(1,'/'); sInterval = sInterval.getToken(0,')'); m_xGroup->setGroupInterval(sInterval.toInt32()); diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index ca84e648f859..c62d4643e00f 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -325,7 +325,7 @@ bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt) if (index != -1) { selected = selected.copy(index, sal_Int32(aSelection.nEndPos-index)); - if (selected.trim().isEmpty()) + if (o3tl::trim(selected).empty()) autoClose = true; } else @@ -336,7 +336,7 @@ bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt) else { selected = selected.copy(aSelection.nEndPos); - if (selected.trim().isEmpty()) + if (o3tl::trim(selected).empty()) autoClose = true; } } diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx index 2275965e866a..4119cf5f6998 100644 --- a/svtools/source/dialogs/PlaceEditDialog.cxx +++ b/svtools/source/dialogs/PlaceEditDialog.cxx @@ -176,12 +176,12 @@ void PlaceEditDialog::InitDetails( ) // Create CMIS controls for each server type // Load the ServerType entries - bool bSkipGDrive = OUString( GDRIVE_CLIENT_ID ).isEmpty() || - OUString( GDRIVE_CLIENT_SECRET ).isEmpty(); - bool bSkipAlfresco = OUString( ALFRESCO_CLOUD_CLIENT_ID ).isEmpty() || - OUString( ALFRESCO_CLOUD_CLIENT_SECRET ).isEmpty(); - bool bSkipOneDrive= OUString( ONEDRIVE_CLIENT_ID ).isEmpty() || - OUString( ONEDRIVE_CLIENT_SECRET ).isEmpty(); + bool bSkipGDrive = std::string_view( GDRIVE_CLIENT_ID ).empty() || + std::string_view( GDRIVE_CLIENT_SECRET ).empty(); + bool bSkipAlfresco = std::string_view( ALFRESCO_CLOUD_CLIENT_ID ).empty() || + std::string_view( ALFRESCO_CLOUD_CLIENT_SECRET ).empty(); + bool bSkipOneDrive= std::string_view( ONEDRIVE_CLIENT_ID ).empty() || + std::string_view( ONEDRIVE_CLIENT_SECRET ).empty(); Sequence< OUString > aTypesUrlsList( officecfg::Office::Common::Misc::CmisServersUrls::get() ); Sequence< OUString > aTypesNamesList( officecfg::Office::Common::Misc::CmisServersNames::get() ); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 17b574231ebf..4feda3af8f75 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -96,6 +96,7 @@ #include #include #include +#include #include #include #include @@ -4352,7 +4353,7 @@ void ColorListBox::createColorWindow() void ColorListBox::SelectEntry(const NamedColor& rColor) { - if (rColor.second.trim().isEmpty()) + if (o3tl::trim(rColor.second).empty()) { SelectEntry(rColor.first); return; diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 7a51b8edabc1..bae9b9d0c586 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1253,7 +1254,7 @@ public: const uno::Reference xDocumentProperties( xDPS->getDocumentProperties()); OUString sTitle = xDocumentProperties->getTitle(); - if (sTitle.trim().isEmpty()) + if (o3tl::trim(sTitle).empty()) { lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE), sfx::AccessibilityIssueID::DOCUMENT_TITLE); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 751727c4ed4c..0158a93a46df 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -1996,7 +1997,7 @@ bool SwFlyFrame::IsShowUnfloatButton(SwWrtShell* pWrtSh) const if (pLower->IsTextFrame()) { const SwTextFrame* pTextFrame = static_cast(pLower); - if (!pTextFrame->GetText().trim().isEmpty()) + if (!o3tl::trim(pTextFrame->GetText()).empty()) return false; } pLower = pLower->GetNext(); diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index c94aef2c4b0c..1b802660cf3a 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -790,13 +790,13 @@ namespace OUStringBuffer aBuf; sal_Int32 nTextLen; - nTextLen = OUString(OUString::number(rFormatter.GetMin())).getLength(); + nTextLen = std::u16string_view(OUString::number(rFormatter.GetMin())).size(); string::padToLength(aBuf, nTextLen, '9'); Size aMinTextSize = rSpinField.CalcMinimumSizeForText( rFormatter.CreateFieldText(OUString::unacquired(aBuf).toInt64())); aBuf.setLength(0); - nTextLen = OUString(OUString::number(rFormatter.GetMax())).getLength(); + nTextLen = std::u16string_view(OUString::number(rFormatter.GetMax())).size(); string::padToLength(aBuf, nTextLen, '9'); Size aMaxTextSize = rSpinField.CalcMinimumSizeForText( rFormatter.CreateFieldText(OUString::unacquired(aBuf).toInt64())); diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx index 9ef0e145ed6d..86c215dd21b6 100644 --- a/vcl/source/treelist/svtabbx.cxx +++ b/vcl/source/treelist/svtabbx.cxx @@ -77,12 +77,12 @@ static void lcl_DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, { const OUString& rCollapsed = pBmpItem->GetBitmap1().GetStock(); const OUString& rExpanded = pBmpItem->GetBitmap2().GetStock(); - if (!rCollapsed.trim().isEmpty() || !rExpanded.trim().isEmpty()) + if (!o3tl::trim(rCollapsed).empty() || !o3tl::trim(rExpanded).empty()) { auto aColumn = rJsonWriter.startStruct(); - if (!rCollapsed.trim().isEmpty()) + if (!o3tl::trim(rCollapsed).empty()) rJsonWriter.put("collapsed", rCollapsed); - if (!rExpanded.trim().isEmpty()) + if (!o3tl::trim(rExpanded).empty()) rJsonWriter.put("expanded", rExpanded); } } diff --git a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx index 80badde4bcb3..b598c241e75e 100644 --- a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx +++ b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx @@ -291,7 +291,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte pCurrentVectorIndex.reset(); aIndexFolderResultVectorVector.clear(); - sal_Int32 replIdx = OUString( "#HLP#" ).getLength(); + sal_Int32 replIdx = strlen( "#HLP#" ); OUString replWith = "vnd.sun.star.help://"; int nResultCount = aCompleteResultVector.size(); diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 81772ac41644..7f6e60fbe344 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -303,7 +303,7 @@ bool OPropertyImport::encounteredAttribute(sal_Int32 nAttributeToken) const void OPropertyImport::characters(const OUString& _rChars ) { // ignore them (should be whitespace only) - OSL_ENSURE(_rChars.trim().isEmpty(), "OPropertyImport::Characters: non-whitespace characters!"); + OSL_ENSURE(o3tl::trim(_rChars).empty(), "OPropertyImport::Characters: non-whitespace characters!"); } bool OPropertyImport::handleAttribute(sal_Int32 nAttributeToken, const OUString& _rValue) @@ -370,7 +370,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > OPropertyElementsConte void OPropertyElementsContext::characters(const OUString& _rChars) { - OSL_ENSURE(_rChars.trim().isEmpty(), "OPropertyElementsContext::Characters: non-whitespace characters detected!"); + OSL_ENSURE(o3tl::trim(_rChars).empty(), "OPropertyElementsContext::Characters: non-whitespace characters detected!"); } #endif